예제 #1
0
        //out methods
        public string AddChatSong(string idOrYoutubeLink, string viewer)
        {
            string resp = "";

            //_player.Dispatcher.Invoke()
            //App.Current.Dispatcher.Invoke(() =>
            //{
            _player.Dispatcher.Invoke(() =>
            {
                Song song = CreateSongById(idOrYoutubeLink);
                if (song != null)
                {
                    try
                    {
                        song.Image.Freeze();
                    }
                    catch
                    {
                    }
                    song.Viewer = viewer;
                    ChatPlayList.Add(song);
                    int qeuePosition;
                    if (ChatPlayList.Count == 1)
                    {
                        qeuePosition = 0;
                    }
                    else if (LastChatSong == null)
                    {
                        qeuePosition = ChatPlayList.Count;
                    }
                    else
                    {
                        qeuePosition = ChatPlayList.Count - LastChatSong.Index;
                    }
                    resp = $"Song {song.Title} . Was added, you position in qeue : #{qeuePosition}";
                }
                else
                {
                    resp = "";
                }
            });

            //});
            return(resp);
        }
예제 #2
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;
            }
        }
예제 #3
0
        public string AddFirstChatSong(string idOrYoutubeLink, string viewer)
        {
            string resp = "";

            //App.Current.Dispatcher.Invoke(() =>
            //{
            _player.Dispatcher.Invoke(() =>
            {
                Song song = CreateSongById(idOrYoutubeLink);
                if (song != null)
                {
                    try
                    {
                        song.Image.Freeze();
                    }
                    catch (Exception e)
                    {
                    }

                    song.Viewer      = viewer;
                    int qeuePosition = 0;
                    if (LastChatSong == null)
                    {
                        ChatPlayList.Add(song);
                    }
                    else
                    {
                        ChatPlayList.Insert(LastChatSong.Index, song);
                    }

                    resp = $"Song {song.Title} . Was added out of turn! you position in qeue : #{qeuePosition+1}";
                }
                else
                {
                    resp = "";
                }
            });
            // });
            return(resp);
        }