/// <summary> /// 双击歌曲项或右键点击播放 /// </summary> /// <param name="listBox"></param> private void DouClickSongItemExecute(Selector listBox) //由于PlayListItem在子类中无法改变,故放于此 { var songListItem = listBox.SelectedItem as SongListStyle; if (songListItem != null) { var targetSong = SongListModel.GetPlayingSong(songListItem.Song.Path); if (!targetSong.Equals(PlayingSong)) { PlayingSong = targetSong; } //PlayingSong = SongListModel.GetPlayingSong(songListItem.Song.Path); } PlayListItem.Clear(); PlayListItem = new List <SongListStyle>(InitialSongs); IsPlayListChanged = true; //播放列表被修改 PlayingListModel.ClearPlayingList(); PlayingListModel.SavePlayingList(PlayListItem.Select(i => i.Song).ToList()); if (ControlService.PlayState != PlayState.播放) { ControlService.PlayState = PlayState.播放; } else { ControlService.PlayService.MediaPlayer.Play(); } }
private void OnDelPlayList(ListBox listBox) { var songListItem = listBox.SelectedItem as SongListStyle; if (songListItem == null) { return; } var delSong = SongListModel.GetPlayingSong(songListItem.Song.Path); var songList = PlayListItem.Select(i => i.Song).ToList(); songList.Remove(delSong); PlayListItem = SongListModel.InitialSongList(songList); IsPlayListChanged = true; PlayingListModel.ClearPlayingList(); PlayingListModel.SavePlayingList(songList); //若删除的歌曲为正在播放的歌曲 if (delSong.Equals(PlayingSong)) { OnNext(); //播放下一曲 } }
private void OnAddPlayList(ListBox listBox) { var songList = PlayListItem.Select(i => i.Song).ToList(); var songListItem = listBox.SelectedItem as SongListStyle; if (songListItem == null) { return; } songList.Add(songListItem.Song); PlayListItem = SongListModel.InitialSongList(songList); IsPlayListChanged = true; PlayingListModel.ClearPlayingList(); PlayingListModel.SavePlayingList(songList); }
/// <summary> 播放选中标签的歌曲 </summary> private void PlaySongExecute() { PlayListItem.Clear(); var songList = InitialSongs.Select(i => i.Song).ToList(); PlayListItem = SongListModel.InitialSongList(songList); IsPlayListChanged = true; PlayingListModel.ClearPlayingList(); PlayingListModel.SavePlayingList(songList); if (ControlService.PlayState != PlayState.播放) { ControlService.PlayState = PlayState.播放; } }
private void ClearExecute() { PlayListItem = new List <SongListStyle>(); PlayingSong = new Song(); PlayingListModel.ClearPlayingList(); }