Example #1
0
        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);
                }
            }
        }
Example #2
0
 public void AddSong(Song song)
 {
     if (song != null)
     {
         StreamerPlaylist.Add(song);
     }
 }
Example #3
0
        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;
            }
        }