Search code examples
c++wavplaysound

PlaySound() works for 1 sound, is there a function for more?


Tried looking for the answer but all I could find was to add another library like OpenAL and such. (all I use except windows.h is glut)

I wrote a multi thread program to check if it is possible that one thread will keep playing the main theme and the 2nd one will play the sound effects but unfortunately it does not work...


Solution

  • Have you tried the MCI library?

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd742874(v=vs.85).aspx

    Here's how I do it:

    mciSendString(L"open ../mp3/announce_start.mp3 alias announce", 0, 0, 0 );
    mciSendString(L"play announce wait", 0, 0, 0 );
    

    If you want your sound file to repeat, try

    mciSendString(L"play announce repeat wait", 0, 0, 0 );