public void LoadStreamerPlaylistFromFile() { OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = "Text Files(Text Files(*.bin)|*.bin|All(*.*)|*" }; if (openFileDialog.ShowDialog() == true) { try { string stringPlaylist = ""; using (BinaryReader reader = new BinaryReader(File.Open(openFileDialog.FileName, FileMode.OpenOrCreate))) { stringPlaylist = reader.ReadString(); } StreamerPlaylist.Clear(); ObservableCollection <Song> tmp = JsonConvert.DeserializeObject <ObservableCollection <Song> >(stringPlaylist); foreach (var item in tmp) { StreamerPlaylist.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public void PlayStreamerSongByIndex(int index) { Song tmp = StreamerPlaylist.First(song => song.Index == index); if (CurrentSong != tmp) { CurrentSong = tmp; LastStreamerSong = CurrentSong; foreach (var item in StreamerPlaylist) { item.IsSelected = false; } foreach (var item in ChatPlayList) { item.IsSelected = false; } CurrentSong.IsSelected = true; _timer.Elapsed += _timer_Elapsed; _timer.Start(); } else { StartStopPlayer(); } }
public void AddSong(Song song) { if (song != null) { StreamerPlaylist.Add(song); } }
public void PlayNextSong() { bool nextChatSong = false; if (ConfigSet.Config.PlayerConfig.ChatPlaylistOn) { if (ChatPlayList.Count != 0) { if (LastChatSong != null) { if (LastChatSong.Index < ChatPlayList.Count) { int needindex = LastChatSong.Index + 1; Song tmp = ChatPlayList.First(song => song.Index == needindex); int index = tmp.Index; PlayChatSongByIndex(index); nextChatSong = true; } } else { PlayChatSongByIndex(1); nextChatSong = true; } } } else { nextChatSong = false; } if (StreamerPlaylist.Count != 0 && nextChatSong == false) { int index = 1; if (LastStreamerSong != null) { if (LastStreamerSong.Index == StreamerPlaylist.Count) { index = 1; } else { int needindex = LastStreamerSong.Index + 1; Song tmp = StreamerPlaylist.First(song => song.Index == needindex); index = tmp.Index; } } PlayStreamerSongByIndex(index); } }
public void PlayPreviousSong() { if (StreamerPlaylist.Count != 0) { int index = 0; if (CurrentSong.Index == 1) { index = StreamerPlaylist.Count; } else { int needindex = CurrentSong.Index - 1; Song tmp = StreamerPlaylist.First(song => song.Index == needindex); index = tmp.Index; } PlayStreamerSongByIndex(index); } }
public void PlayerLoaded() { string stringConfig = ""; if (!File.Exists(ConfigSet.PlayerSaveFilePath)) { PlayerClosed(); } using (BinaryReader reader = new BinaryReader(File.Open(ConfigSet.PlayerSaveFilePath, FileMode.OpenOrCreate))) { stringConfig = reader.ReadString(); } PlayerSaveObject tmp = JsonConvert.DeserializeObject <PlayerSaveObject>(stringConfig); foreach (var item in tmp.StreamerPlayList) { StreamerPlaylist.Add(item); } if (StreamerPlaylist.Count != 0) { StreamerPlaylist[tmp.LastStreamerSong.Index - 1].IsSelected = true; LastStreamerSong = StreamerPlaylist[tmp.LastStreamerSong.Index - 1]; } CurrentSong = null; foreach (var item in tmp.ChatPlayList) { ChatPlayList.Add(item); } if (ChatPlayList.Count != 0) { ChatPlayList[tmp.LastChatSong.Index - 1].IsSelected = true; LastChatSong = ChatPlayList[tmp.LastChatSong.Index - 1]; if (LastChatSong.Index < ChatPlayList.Count) { CurrentSong = LastChatSong; } } if (CurrentSong == null) { CurrentSong = LastStreamerSong; } }
public void CopyStreamerSongLinkByIndex(int index) { string link = StreamerPlaylist.First(song => song.Index == index).YoutubeLink; Clipboard.SetText(link); }
public void DeleteStreamerSongByIndex(int index) { StreamerPlaylist.RemoveAt(index - 1); }
public void ClearStreamerPlayList() { StreamerPlaylist.Clear(); }