Frage

I am making a game and I am trying to loop a MIDI file with mciSendString(). I have looked at CProgramming.com but the example's window objects were OWL and I couldn't port them. I also tried looking at Brian Gradin's question but the answer only contained two lines of code. I have looked on MSDN but that is like a reference and not a tutorial. Adding repeat doesn't play anything. This is the code that I have so far:

mciSendString("open PUG1.MID type sequencer alias music", NULL, 0, NULL);
mciSendString("play music", NULL, 0, NULL);

If you help then I will be sure to put you in the credits. Thank you! :)

EDIT: I have tried to handle the notify flag but my code will not work. It plays the theme once then it stops.

    //At the end of WM_CREATE...
    mciSendString("open MUSIC\\PUG2.MID type sequencer alias music", NULL, 0, NULL);
    mciSendString("play music", NULL, 0, NULL);
break;
case MM_MCINOTIFY:
    mciSendString("seek music to start", NULL, 0, NULL);
    mciSendString("play music", NULL, 0, NULL);
break;
War es hilfreich?

Lösung

You can use the notify flag be notified when the song ends.

This seems to work:

case WM_CREATE:
    mciSendString("open pickin0.mid type sequencer alias music", NULL, 0, NULL);
    mciSendString("play music notify", NULL, 0, hWnd);
    break;

case MM_MCINOTIFY:
    mciSendString("seek music to start", NULL, 0, NULL);
    mciSendString("play music notify", NULL, 0, hWnd);
    break;

You need to pass your window handle when you use the notify command so it can send the MM_MCINOTIFY command somewhere.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top