예제 #1
0
 public void StopMusic()
 {
     if (m_MusicCurrentlyPlaying != null)
     {
         m_MusicCurrentlyPlaying.Stop();
         m_MusicCurrentlyPlaying.Dispose();
         m_MusicCurrentlyPlaying = null;
     }
 }
예제 #2
0
        public void PlayMusic(int id)
        {
            if (Settings.Audio.MusicOn)
            {
                if (id < 0) // not a valid id, used to stop music.
                {
                    StopMusic();
                    return;
                }

                if (!m_Music.ContainsKey(id))
                {
                    string name;
                    bool   loops;
                    if (MusicData.TryGetMusicData(id, out name, out loops))
                    {
                        m_Music.Add(id, new UOMusic(id, name, loops));
                    }
                    else
                    {
                        Tracer.Error("Received unknown music id {0}", id);
                        return;
                    }
                }

                ASound toPlay = m_Music[id];
                if (toPlay != m_MusicCurrentlyPlaying)
                {
                    // stop the current song
                    StopMusic();
                    // play the new song!
                    m_MusicCurrentlyPlaying = toPlay as UOMusic;
                    m_MusicCurrentlyPlaying.Play(false);
                }
            }
        }