How to skip a playlist item?
You can specify "skip" property to "true" for the item you'd like to skip in a playlist.
Something like this:
MItem item;
myPlaylist.PlaylistGetByIndex(1, ..., out item);
(item as IMProps).PropsSet("skip", "true");
How to play a random playlist item?
1. You have to initialize event.
m_objPlaylist.OnEvent += new IMEvents_OnEventEventHandler(m_objFile_OnEvent);
2. I choose the List for illustrative purposes as the source that contains all order numbers of the Playlist items.
public List<int> list = new List<int>();
void CountList()
{
int count = 0;
double dur = 0;
m_objPlaylist.PlaylistGetCount(out count, out dur);
for (int i = 0; i < count; i++)
{
list.Add(i);
}
}
3. A method that returns the random position.
private int randomPos;
private int GetRanPos() { int ans; Random ran = new Random(); int z = ran.Next(0, list.Count); ans = list[z]; list.Remove(list[z]); return ans; }
4. Then you have to monitor the event that raises at the moment when the item is over. And then change a position of the Playlist to random. (More information about the events you can find in this article - Events).
private void M_objPlaylist_OnEventSafe(string bsChannelID, string bsEventName, string bsEventParam, object pEventObject)
{
Marshal.ReleaseComObject(pEventObject);
if (list.Count == 0)
{
Random.Checked = false;
CountList();
}
if (Random.Checked)
{
if (bsEventName == "EOF")
{
randomPos = GetRanPos();
m_objPlaylist.PlaylistPosSet(randomPos, 0, 0);
m_objPlaylist.FilePlayStart();
}
}
}