Check if sound playing
BlitzMax Forums/BlitzMax Programming/Check if sound playing
| ||
This is probably simple, but there's nothing on it in the help. If I have a sound come on randomely, say, a five-second sound, how do I keep the sound from re-playing before its done? Something like: If mysound IsNotAlreadyPlaying Then PlaySound mysound End If Must be a simple flag or something I can't find? -Rob |
| ||
Type in "ChannelPlaying" in the editor and press F1 twice. This will bring you to the description for the function which is used to determine if something is playing. |
| ||
an advise additional to the help example: to use ChannelPlaying it is important to have a valid channel before testing it in the main loop. So alloc the channel first with CueSound() before testing it with ChannelPlaying(): Graphics 800,600 Sound:TSound = LoadSound ("test.ogg") Global Channel:TChannel=CueSound(Sound) Repeat Delay 100 Print "ChannelPlaying(channel)="+ChannelPlaying(channel) If ChannelPlaying(Channel)=0 Print "Resume" Channel=PlaySound(Sound) EndIf Until KeyHit(Key_Escape) |