The MPlaylist object is a powerful instrument to control the playback. It can handle Live sources like hardware devices or streams, mp://links or basic media files and can output data to NDI, WebRTC or hardware device.
In this article will highlight the detailed information about basic features that can manage MPlaylist like adding/removing the source, reorder, etc.
Adding the source
The source can be easily added to MPlaylist with PlaylistAdd method.
//Adding a file:
m_objPlaylist.PlaylistAdd(null, [FileName], "", ref nIndex, out MItem pFile);
//Adding a URL:
m_pPlaylist.PlaylistAdd(null, [URL], [Parameters], ref nIndex, out MItem pFile);
//Adding a Live:
m_pPlaylist.PlaylistAdd( null, "my_live", "live", ref nIndex, out MItem pLive);
//and then cast MItem to MLiveClass and set the device and formats like
//in this article[Link].
//or add the LiveClass directly
m_objPlaylist.PlaylistAdd(m_objMLive, "", "", ref index, out MItem item);
Removing the source
It's possible to remove a MItem directly with PlaylistRemove method
m_objPlaylist.PlaylistRemove([MItem]);
or remove the playlist item by index with PlaylistRemoveByIndex method.
m_objPlaylist.PlaylistRemoveByIndex([SelectedIndex], 0);
// 0 - remove single item.
// >0 - number of items to be removed is calculated to the end of playlist.
// <0 - clear all playlist items.
Getting the current position
The PlaylistPosGet method returns the index of playback item, the index of the next item and two time positions related to currently played item and the whole playlist. This method is useful for updating the status of the Playlist.
m_objPlaylist.PlaylistPosGet(out nIndex, out nNextIndex, out dblFileTime, out dblListTime);
Reordering the Playlist items
It's easy to do it with the PlaylistReorder method
m_objPlaylist.PlaylistReorder([index of item to be changed], [required position]);
// [required position] > 0 - duration to the end of the list. If the number is bigger
// then the index of the last item of the Playlist - the reordering item will be the
// last item.
// [required position] > 0 - position is changed in direction to beggining of Playlist.