Exemple #1
0
        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);
            }
        }
Exemple #2
0
 public static void Update(GameTime gameTime)
 {
     MusicTrack.Update(gameTime);
     if (IntroStarted && DateTime.Now > IntroEndTime)
     {
         IntroStarted = false;
         PlayMusic(IntroContinue);
         IntroContinue = "";
     }
 }
Exemple #3
0
 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;
             }
         }
     }
 }
Exemple #4
0
 public static void Mute(bool mute) => MusicTrack.Mute(mute);
Exemple #5
0
 public static void Resume() => MusicTrack.Resume();
Exemple #6
0
 public static void Pause(TimeSpan duration) => MusicTrack.Pause(duration);
Exemple #7
0
 public static void Pause() => MusicTrack.Pause();
Exemple #8
0
 public static void Stop()
 {
     MusicTrack.Stop();
     IntroContinue = "";
     IntroStarted  = false;
 }
Exemple #9
0
 public static void PlayNoMusic() => MusicTrack.PlayNoMusic();
Exemple #10
0
 public static void ReloadMusic() => MusicTrack.ReloadMusic();
Exemple #11
0
 public static void LoadMusic(bool forceReplace = false) => MusicTrack.LoadMusic(forceReplace);
Exemple #12
0
 public static MusicClip GetMusic(string musicName, bool logErrors) => MusicTrack.GetMusic(musicName, logErrors);