How to play a background-sound (SND_ASYNC) ?
Posted: Mon Sep 09, 2019 5:01 pm
Hello,
I want to play a background-sound a defined time
without blocking any possible actions using < SND_ASYNC >
That doesn't work because
the function returns immediately after beginning the sound
FOR I := 1 TO 3 // play sound 3 times
SndPlaySound( "Test.wav", 1 ) // 0 works but is blocking all actions
NEXT
SND_SYNC The sound is played synchronously and the function does not return until the sound ends.
SND_ASYNC The sound is played asynchronously and the function returns immediately after beginning the sound.
To terminate an asynchronously-played sound, call sndPlaySound with cSndName set to 0.
SND_NODEFAULT If the sound can't be found, the function returns silently without playing the default sound.
SND_MEMORY The parameter specified by cSndName to an in-memory image of a waveform sound.
SND_LOOP The sound will continue to play repeatedly until sndPlaySound is called again with the cSndName parameter set to 0.
You must also specify the SND_ASYNC flag to loop sounds.
SND_NOSTOP If a sound is currently playing, the function will immediately return FALSE without playing the requested sound.
#define SND_SYNC 0
#define SND_ASYNC 1
#define SND_NODEFAULT 2
#define SND_MEMORY 4
#define SND_LOOP 8
#define SND_NOSTOP 16
is there any solution
regards
Uwe
I want to play a background-sound a defined time
without blocking any possible actions using < SND_ASYNC >
That doesn't work because
the function returns immediately after beginning the sound
FOR I := 1 TO 3 // play sound 3 times
SndPlaySound( "Test.wav", 1 ) // 0 works but is blocking all actions
NEXT
SND_SYNC The sound is played synchronously and the function does not return until the sound ends.
SND_ASYNC The sound is played asynchronously and the function returns immediately after beginning the sound.
To terminate an asynchronously-played sound, call sndPlaySound with cSndName set to 0.
SND_NODEFAULT If the sound can't be found, the function returns silently without playing the default sound.
SND_MEMORY The parameter specified by cSndName to an in-memory image of a waveform sound.
SND_LOOP The sound will continue to play repeatedly until sndPlaySound is called again with the cSndName parameter set to 0.
You must also specify the SND_ASYNC flag to loop sounds.
SND_NOSTOP If a sound is currently playing, the function will immediately return FALSE without playing the requested sound.
#define SND_SYNC 0
#define SND_ASYNC 1
#define SND_NODEFAULT 2
#define SND_MEMORY 4
#define SND_LOOP 8
#define SND_NOSTOP 16
is there any solution
regards
Uwe