private bool CueAlreadyExists(MusicCue cue) { return(CueAlreadyExists(cue.TrackName, cue.CueName)); }
public void Play(MusicCue track) { // Set volume immediately if starting a song from silence if (!IsBgmPlaying) { Volume = TargetVolume; } // Resume the existing track if (track.Resume && CueAlreadyExists(track)) { // If this track is already playing normally or // fading back in, do nothing if (!(Music[track.TrackName].IsPlaying && !Music[track.TrackName].IsFadeOut)) { Restore(track.TrackName, track.FadeIn); } return; } // Pause any other playing tracks PauseOther(track.TrackName); StopPlayingTrack(track.TrackName); SoundEffectInstance instance = null; try { instance = get_music(track.CueName); } catch (FileNotFoundException e) { #if DEBUG Print.message("Tried to play nonexistant BGM: " + track.CueName); #endif } catch (ContentLoadException e) { #if DEBUG Print.message("Tried to play nonexistant BGM: " + track.CueName); #endif } #if __ANDROID__ catch (Java.IO.FileNotFoundException e) { } #endif if (instance != null) { Music.Add(track.TrackName, new MusicInstance(instance, track.CueName, this.BgmVolume)); if (track.FadeIn) { Music[track.TrackName].FadeIn(this.DefaultFadeInTime); } Music[track.TrackName].RefreshVolume(this.BgmVolume); Music[track.TrackName].Play(); } if (Music.Count > SIMULTANEOUS_TRACKS) { throw new Exception(); } }
private bool TrackPlayingCue(MusicCue cue) { return(TrackPlayingCue(cue.TrackName, cue.CueName)); }