Detect end of music

BlitzPlus Forums/BlitzPlus Programming/Detect end of music

Grey Alien(Posted 2005) [#1]
I'm sure I saw someone ask a similar thing about playsound recently to no avail ... is there any way to detect the end of a music track so you can play another one! i.e. Use playmusic, when the track stops, play the next one.

thx


Arem(Posted 2005) [#2]
if not channelplaying(channel)
channel=playmusic("nextmusic.mp3")
end if


Grisu(Posted 2005) [#3]
yepp, thats it. Or "channelplaying(chn)=0"

See my game Cardwar that does this.


Grey Alien(Posted 2005) [#4]
Thanks guys, that's great!


Rob Farley(Posted 2005) [#5]
Just another thing, if you don't need the track to start the instant the previous one stops you don't have to poll the channel playing every game loop. I know it's obvious, but thought I'd mention it.


Grey Alien(Posted 2005) [#6]
thanks Rob but I do want it to play one after the other like a CD player. I might program a 1-2 sec delay between each track though.

I presume the same command works for samples played with PlaySound too.


VIP3R(Posted 2005) [#7]
You presume correctly Grey Alien, as long as you assign them to a channel ;)