/// <summary> /// 上一曲 /// </summary> private void LastMusic() { List <MusicItemViewModel> selectedItem = MusicList.Where(i => i.IsSelected == true).ToList(); if (selectedItem.Count > 0) { Playing = selectedItem.First(); int index = MusicList.IndexOf(Playing); if (index >= 1) { Playing.IsSelected = false; Playing = MusicList[--index]; Playing.IsSelected = true; System.Threading.Thread.Sleep(100); PlayMusic(Playing.Music); } else { Playing.IsSelected = false; Playing = MusicList.Last(); Playing.IsSelected = true; System.Threading.Thread.Sleep(100); PlayMusic(Playing.Music); } PlayIcon = new BitmapImage(new Uri("/Image/full_pause.png", UriKind.Relative)); } }
public PlayerViewModel(Music selectedMusic) { SelectedMusic = selectedMusic; MusicList = SongService.GetInstance().Music; SongService.GetInstance().SetRecient(MusicList.IndexOf(SelectedMusic)); this._audioPlayer = CrossSimpleAudioPlayer.Current; this._audioPlayer.Load(GetStreamForFile()); this._audioPlayer.Play(); }
/// <summary> /// 下一曲 /// </summary> private void NextMusic() { List <MusicItemViewModel> selectedItem = MusicList.Where(i => i.IsSelected == true).ToList(); if (selectedItem.Count > 0) { Playing = selectedItem.First(); int index = MusicList.IndexOf(Playing); if (PlayOrder == 0) { if (index < MusicList.Count - 1) { Playing.IsSelected = false; Playing = MusicList[++index]; Playing.IsSelected = true; //System.Threading.Thread.Sleep(100); PlayMusic(Playing.Music); } else { Playing.IsSelected = false; Playing = MusicList.First(); Playing.IsSelected = true; //System.Threading.Thread.Sleep(100); PlayMusic(Playing.Music); } } else if (PlayOrder == 1) { Random random = new Random(); int select; do { select = random.Next(MusicList.Count); } while (select == index); Playing.IsSelected = false; Playing = MusicList[select]; playing.IsSelected = true; PlayMusic(Playing.Music); } PlayIcon = new BitmapImage(new Uri("/Image/full_pause.png", UriKind.Relative)); } }
private void ListDown() { if (SelectedMusic == null) { return; } int index = MusicList.IndexOf(SelectedMusic); if (index == MusicList.Count - 1) { return; } PlayerModel model = SelectedMusic.Clone() as PlayerModel; MusicList.Remove(SelectedMusic); MusicList.Insert(index + 1, model); SelectedIndex = MusicList.IndexOf(model); }