ChannelPlaying()
BlitzMax Forums/BlitzMax Programming/ChannelPlaying()
| ||
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. |
| ||
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. |
| ||
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.. |
| ||
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. |
| ||
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. |
| ||
Thanks very much for the suggestion, Grey. I will convert my sound code over to your format and see if it helps. |
| ||
Grey- Cheers- this would resolve an issue I was having with the code I worked on over the weekend :) |
| ||
don't do it like that. Do it like this: :D |
| ||
lol :-) |