Looping Sounds

If you specify the SND_LOOP and SND_ASYNC flags for the fdwSound parameter of the PlaySoundIMKKV6 function, the sound will continue to play repeatedly as shown in the following example:

PlaySound("C:\\SOUNDS\\BELLS.WAV", NULL, SND_LOOP | SND_ASYNC);

 

If you want to loop a sound, you must play it asynchronously; you cannot use the SND_SYNC flag with the SND_LOOP flag. A looped sound will continue to play until you call PlaySound to play another sound. To stop playing a sound (looped or asynchronous) without playing another sound, use the following statement:

PlaySound(NULL, NULL, 0);