public static void PlayMusic(string musicName, bool searchForIntro, float newFadeInSpeed, float newFadeOutSpeed) { MediaPlayer.IsRepeating = true; var musicNameLower = musicName.ToLowerInvariant(); if (searchForIntro) { var introMusicNameLower = $"intro|{musicNameLower}"; if (MusicTrack.Contains(introMusicNameLower)) { if (GetCurrentMusic != musicNameLower && GetCurrentMusic != introMusicNameLower) { PlayMusic(introMusicNameLower, newFadeInSpeed, newFadeOutSpeed, false); } IntroContinue = musicNameLower; } else { PlayMusic(musicNameLower, newFadeInSpeed, newFadeOutSpeed); } } else { PlayMusic(musicNameLower, newFadeInSpeed, newFadeOutSpeed); } }
public static void Update(GameTime gameTime) { MusicTrack.Update(gameTime); if (IntroStarted && DateTime.Now > IntroEndTime) { IntroStarted = false; PlayMusic(IntroContinue); IntroContinue = ""; } }
public static void PlayMusic(string musicName, float newFadeInSpeed, float newFadeOutSpeed, bool loopTrack = true) { if (!MusicTrack.IsPlaying || musicName != MusicTrack.MusicNamePlaying) { if (musicName != IntroContinue || IntroStarted == false) { Logger.Debug($"Play [{musicName}]"); MusicTrack.Play(musicName, loopTrack); if (!loopTrack) //is intro { IntroEndTime = DateTime.Now + GetMusic(musicName, true).Duration; IntroEndTime = IntroEndTime.AddSeconds(-1); //Temporary workaround. Remove when the one second bug is fixed properly. IntroStarted = true; } else { IntroContinue = ""; IntroStarted = false; } } } }
public static void Mute(bool mute) => MusicTrack.Mute(mute);
public static void Resume() => MusicTrack.Resume();
public static void Pause(TimeSpan duration) => MusicTrack.Pause(duration);
public static void Pause() => MusicTrack.Pause();
public static void Stop() { MusicTrack.Stop(); IntroContinue = ""; IntroStarted = false; }
public static void PlayNoMusic() => MusicTrack.PlayNoMusic();
public static void ReloadMusic() => MusicTrack.ReloadMusic();
public static void LoadMusic(bool forceReplace = false) => MusicTrack.LoadMusic(forceReplace);
public static MusicClip GetMusic(string musicName, bool logErrors) => MusicTrack.GetMusic(musicName, logErrors);