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(); //播放下一曲 } }
/// <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(); } }
/// <summary> 初始化歌曲列表、播放列表和初始歌曲 </summary> private void InitialSongLists() { InitialSongs = SongListModel.InitialSongList(SongListModel.GetSongsDb()); PlayListItem = SongListModel.InitialSongList(PlayingListModel.GetPlayingList()); var firstOrDefault = PlayListItem.FirstOrDefault(); if (firstOrDefault != null) { PlayingSong = firstOrDefault.Song; ControlService.PlayService.SongPath = PlayingSong.Path; ControlService.PlayState = PlayState.暂停; } }
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.播放; } }
/// <summary> /// 先初始化构造函数,再初始化属性 /// </summary> public TagsSelectService() { SongListModel = new SongListModel(); PlayingListModel = new PlayingListModel(); ControlService = new ControlService(); PlayMode = PlayMode.列表循环; InitialSongs = new List <SongListStyle>(); PlayListItem = new List <SongListStyle>(); InitialSongLists(); PlayModeService = new PlayModeService(PlayMode); ControlService.PlayService.MediaPlayer.MediaEnded += MediaEnd; SelectTagsCommand = new DelegateCommand(OnSelectTags); PlaySongCommand = new DelegateCommand(PlaySongExecute); AddSongSetCommand = new DelegateCommand(OnAddSongSet); NextCommand = new DelegateCommand(OnNext); LastCommand = new DelegateCommand(OnLast); ModeChangeCommand = new DelegateCommand(OnModeChange); SelectTagCommand = new DelegateCommand <Button>(SelectTagExecute); TestCommand = new DelegateCommand(TestExecute); PlayPauseCommand = new DelegateCommand(OnPlayPause); }
private void ClearExecute() { PlayListItem = new List <SongListStyle>(); PlayingSong = new Song(); PlayingListModel.ClearPlayingList(); }