How do I script to tell if music is playing in the music channel/folder.
I'm trying to do something like: If music playing {do nothing} else {aSomething.Play();}
I've tried playing around with the IsPlaying property and with Type property after looking in manual. But my experiments are failing.
Let's say you have a global AudioChannel* variable named bgm.
Once you do
bgm = aSomeBackgroundMusic.Play();
you can now do something like
if (bgm.IsPlaying) ...
Here's a thread about having a piece of music play continuously in several rooms: https://www.adventuregamestudio.co.uk/forums/index.php?topic=50363.msg
If you need to know if *any* music plays, then
bool IsSoundTypePlaying(int sound_type)
{
for (int i = 0; i < System.AudioChannelCount; i++)
{
AudioChannel *ch = System.AudioChannel[i];
if (ch.IsPlaying && ch.PlayingClip.Type == sound_type) return true;
}
return false;
}
Usage:
if (IsSoundTypePlaying(eAudioTypeMusic))
Thanks to both of you. This is really helpful.