private void LoadMenuMusic(ContentManager content) { DirectoryInfo directory = new DirectoryInfo(content.RootDirectory + "/" + MusicDirectory + "/Menu Music"); if (!directory.Exists) throw new DirectoryNotFoundException(); FileInfo[] files = directory.GetFiles("*.xnb*"); foreach (FileInfo file in files) { string key = Path.GetFileNameWithoutExtension(file.Name); MySong song = new MySong(MusicDirectory + "/Menu Music" + "/" + key); song.LoadContent(content); AddSong(MenuMusic, song, key); } }
private void PlaySong(MySong song) { // Only play the song if it is not already playing - otherwise just do nothing if (CurrentSongPlaying != song.Song.Name) { MediaPlayer.Play(song.Song); CurrentSongPlaying = song.Song.Name; MediaPlayer.Volume = ScreenManager.Settings.OptionsData.MusicVolume; } }
private void AddSong(Dictionary<string, MySong> songDictionary, MySong song, string key) { if (!songDictionary.ContainsValue(song) && !songDictionary.ContainsKey(key)) { songDictionary.Add(key, song); } }