I've got a c++ game I'm working on, and I need it to play some music in the background while the user is playing. I looked up how to use PlaySound() and put it in my program. The .wav file loads and plays perfectly, but at the same time, doesn't let my program run along side the music. (making the program wait till the song is finished before continuing execution)

I was wondering if this is an error, or if this is simply what happens when PlaySound() is called?

Because I would hate to start a whole thread just to run a song and keep the game progressing at the same time.

Thanks for your help! :)

You need to create a thread to run your sound file.

PlaySound("file.wav",NULL,SND_FILENAME|SND_ASYNC);

Note the flag SND_ASYNC, which means that the file will play asynchronously during process execution (it won't block). So if you set this flag, it will play the file without 'pausing'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.