Thread: A question about the Playsound() function

  1. #1
    Registered User
    Join Date
    Nov 2008

    A question about the Playsound() function

    I got my sound to play with this code:

    #include <windows.h>
    #include <mmsystem.h>
    int main()
            PlaySound(TEXT("song.wav"), NULL, SND_ALIAS | SND_APPLICATION);
    But if I then wanted it for example to play in the background when the user were interracting with the program, that line doesn't allow me to do so. It seems it needs to finish the song, and then it will move to the next line but that is not what I hoped for.

    What I hoped for is that it reads that line and plays the song, and while it does so, it moves on, so the user can interract with the program while the song is playing.

    Is this possible?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    Perhaps this is what you want:
    Quote Originally Posted by MSDN
    SND_ASYNC The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Precisely! THANKS!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  5. Replies: 28
    Last Post: 07-16-2006, 11:35 PM