ChannelPlaying()

BlitzMax Forums/BlitzMax Programming/ChannelPlaying()

Tachyon(Posted 2007) [#1]
Has anyone else had any problems with ChannelPlaying() returning a false value? I can't reproduce my problem with sample code, but in the big project I have an Init_Music() routine that triggers my music_channel (via CueSound and ResumeChannel) and I can immediately confirm that it is playing via ChannelPlaying(music_channel), and I can hear it.

But then I do one pass through the main loop and my Update_Sound() routine returns a FALSE to ChannelPlaying(music_channel) even though I can of course hear it playing.

Been trying to track this problem down for 5 hours and just thought maybe someone else had a suggestion.


Tachyon(Posted 2007) [#2]
Hmm...removing an AllocChannel() in the Init_Music() routine fixed it. Now it reports properly that the channel is playing.

Sorry for the unnecessary post.


plash(Posted 2007) [#3]
Just for future references.. It also could have been that the channel wasn't global or didn't exist in the block that your channelplaying() function was called..


Tachyon(Posted 2007) [#4]
Wait...I still have a weird problem.

What would cause a channel to ignore being stopped via StopChannel()? I create a global Channel, then I play a .ogg through it (Title Music) and a bit later I try to stop the music (after the player selects new game) and it refuses to stop playing.

The code is literally:
Global TitleMusic:TSound = LoadSound("blah")
Global TitleChannel:TChannel = CueSound(TitleMusic)
ResumeChannel (TitleChannel)

...Jump out and do a bunch of menu related stuff here, return when player has decided to start new game...

StopChannel(TitleChannel)   <-- This does not stop the music!

This is one of those !$#@!! days where I spend 8 hours on something that just shouldn't be a problem.


Grey Alien(Posted 2007) [#5]
don't do it like that. Do it like this:

Global TitleChannel:TChannel = AllocChannel()
CueSound(TitleMusic, TitleChannel)
ResumeChannel (TitleChannel)
StopChannel(TitleChannel)
TitleChannel = null 'safety to stop you reusing it because StopChannel kills it but doesn't null it.



Tachyon(Posted 2007) [#6]
Thanks very much for the suggestion, Grey. I will convert my sound code over to your format and see if it helps.


Damien Sturdy(Posted 2007) [#7]
Grey-

Cheers- this would resolve an issue I was having with the code I worked on over the weekend :)


GfK(Posted 2007) [#8]
don't do it like that. Do it like this:




:D


Grey Alien(Posted 2007) [#9]
lol :-)