I have an mp3 player that sends MCI commands to play pause/ff/rw/stop the audio files etc and the only thing i can't figure out how to do is send an MCI command to tell it to play the next song when the current one's finished playing.
The songs are in a ListBox. I have no problems actually selecting the next song, I just need to find out when to play the next song on the playlist. I'd appreciate any help at all
Thank you :)
Sorry to dredge this up after a month or so, but I think I may have a nicer answer...
You can do the length in seconds thing, or you can have MCI notify you itself.
When you send your "play" command, tack on "notify" after the media's alias, and then pass your window's handle (I'm using System.Windows.Forms, hence the 'this.Handle'), like so:
uint playOk = mciSendString("play MediaFile notify", null, 0, this.Handle);
That tells MCI to send you a notification when the command completes or is interrupted. Then you can just filter the messages your window receives to see if anything you're interested comes through:
private const int MM_MCINOTIFY = 0x03b9;
private const int MCI_NOTIFY_SUCCESS = 0x01;
private const int MCI_NOTIFY_SUPERSEDED = 0x02;
private const int MCI_NOTIFY_ABORTED = 0x04;
private const int MCI_NOTIFY_FAILURE = 0x08;
protected override void WndProc(ref Message m)
{
if (m.Msg == MM_MCINOTIFY)
{
switch (m.WParam.ToInt32())
{
case MCI_NOTIFY_SUCCESS:
// success handling
break;
case MCI_NOTIFY_SUPERSEDED:
// superseded handling
break;
case MCI_NOTIFY_ABORTED:
// abort handling
break;
case MCI_NOTIFY_FAILURE:
// failure! handling
break;
default:
// haha
break;
}
}
base.WndProc(ref m);
}
This seems to be working just fine for me. I hope this helps. ;)