ChannelPlaying bug!
BlitzPlus Forums/BlitzPlus Programming/ChannelPlaying bug!
| ||
| I loaded a wav or ogg and I want to know when it's finished playing but ChannelPlaying() always returns 0. So, how can I workaround it? |
| ||
| You need to post your code, the ChannelPlaying command works fine. |
| ||
| [CODE] Sound=LoadSound("sound.wav") ; Load the sound Channel=PlaySound(Sound) DebugMessage(ChannelPlaying(Channel)) [/CODE] I just did a small example, I didnt test it but it should give you an idea. |
| ||
| That should be 'DebugLog(ChannelPlaying(Channel))'... ;) |
| ||
| I dont use that command so I made the best guess. |
| ||
| There may, on some cards, be a short delay between initialising the sound and playing the sound where ChannelPlaying will return 0. |
| ||
| Thanks for your infos. My sound is about 5 s. Maybe it's too short for ChannelPlaying. I will try it on a longer sound and will tell you. |
| ||
| I tried with a mp3 file (6 minutes length) and I still have the same problem: ChannelPlaying always returns 0. The most strange is that when I tried with Blitz3D demo: ChannelPlaying bugs : Memory Access Violation!! What do you think about that? My sound card is not compatible with Blitz? However I never had pb with commercial games full of sounds. |
| ||
| post your code please. |
| ||
| Yeah Walter, if you could post your code or even just a sample to show the bug you're getting it will help everyone assist you. Might be worth posting your system specs too. |
| ||
All along the music, the value 0 is displayed:
Graphics(640,480,0,2)
SetBuffer BackBuffer()
snd=LoadSound("zic.mp3")
PlaySound(snd)
While Not KeyHit(1)
Cls()
Text 0,0,ChannelPlaying(snd)
Flip()
Wend
|
| ||
| Ah, now the problem is obvious, you're not using the command correctly. This is how it should be (as MrSAK showed earlier):
Graphics(640,480,0,2)
SetBuffer BackBuffer()
snd=LoadSound("zic.mp3")
chan=PlaySound(snd) ; <<<< You have to assign the Playsound to a channel variable
While Not KeyHit(1)
Cls
Text 0,0,ChannelPlaying(chan) ; <<<< now you check the channel variable (not the snd)
Flip
Wend
It's a bit confusing at first, but once you play around with it everything becomes clear. Note: I've used 'chan' here but it can be anything you like... chan, channel, chan_snd Hope this helps :) |
| ||
| Aaaahhh!! ok! :) Yes, it's a bit confusing. It's not like with the movie: chan=OpenMovie("...") and MoviePlaying(chan) where you use the channel of the open function. For the sound, I didn't noticed MrSak used the channel of the Play function. I'm really not careful. Sorry for my careless mistake. Thank you all guys, I'm reassured now! |