Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing a sound in c++ ... However, the game stops while sound being played ... how can I stop this lag?

Tags:

c++

winapi

The sound is created using:

PlaySound(TEXT("C:\\hitBrick.wav"), NULL, SND_FILENAME);
like image 940
David Smith Avatar asked Apr 16 '13 13:04

David Smith


1 Answers

As Ville Krumlinde already said, use SND_ASYNC like this:

PlaySound(TEXT("C:\hitBrick.wav"), NULL, SND_FILENAME | SND_ASYNC);

Take a look: http://msdn.microsoft.com/en-us/library/windows/desktop/dd743680%28v=vs.85%29.aspx

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.

like image 88
Leo Chapiro Avatar answered Sep 29 '22 10:09

Leo Chapiro