Hi all!
Here's what I'm trying to do. I have an audio recording that the player can play at any time during the game. I want the current music to stop, let the audio recording play, and then continue the music from where it left off. Since the player can run this recording at any time, there is no way to know what background music will be playing.
In earlier versions of AGS, there was a command called "GetCurrentMusic()" which let me assign the currently playing music number to an integer. Since music is no longer called by using integers, this command is obsolete now. I'm trying to replicate this command in 3.2.1. My gut tells me the solution to this is very simple, but I've been trying to recreate this command for days and can't seem to manage it.
In v3.2.1, it seems that the only way to get the music file is to know what channel it's playing on first. But since I've just been using the Play() command and not assigning the music to any specific channel, this won't work for me.
Is there a way to do this? Or is this no longer a possibility in the latest version of AGS?
-Dave
Something like this should work:
AudioClip*GetCurrentMusic() {
int i;
AudioChannel*ac;
while (i < System.AudioChannelCount) {
ac = System.AudioChannels[i];
if (ac.PlayingClip != null) return ac.PlayingClip;
i++;
}
return null;
}
Ah, thanks! It works perfectly. I used this this code to set/call the music:
AudioClip *thisClip
thisClip=GetCurrentMusic();
thisClip.Stop();
//play recording
thisClip.Play();
Thanks for the help!