ChannelPlaying bug!

BlitzPlus Forums/BlitzPlus Programming/ChannelPlaying bug!

Walter(Posted 2004) [#1]
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?


VIP3R(Posted 2004) [#2]
You need to post your code, the ChannelPlaying command works fine.


Regular K(Posted 2004) [#3]
[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.


VIP3R(Posted 2004) [#4]
That should be 'DebugLog(ChannelPlaying(Channel))'... ;)


Regular K(Posted 2004) [#5]
I dont use that command so I made the best guess.


Hotcakes(Posted 2004) [#6]
There may, on some cards, be a short delay between initialising the sound and playing the sound where ChannelPlaying will return 0.


Walter(Posted 2004) [#7]
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.


Walter(Posted 2004) [#8]
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.


Réno(Posted 2004) [#9]
post your code please.


VIP3R(Posted 2004) [#10]
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.


Walter(Posted 2004) [#11]
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



VIP3R(Posted 2004) [#12]
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 :)


Walter(Posted 2004) [#13]
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!