David Smith
David Smith

Reputation: 303

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

The sound is created using:

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

Upvotes: 7

Views: 801

Answers (1)

Leo Chapiro
Leo Chapiro

Reputation: 13979

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.

Upvotes: 11

Related Questions