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);
            }
        }
        //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);
        }
        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 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);
        }
        public void PlayChatSongByIndex(int index)
        {
            Song tmp = ChatPlayList.First(song => song.Index == index);

            if (CurrentSong != tmp)
            {
                CurrentSong  = tmp;
                LastChatSong = CurrentSong;
                foreach (var item in ChatPlayList)
                {
                    item.IsSelected = false;
                }
                foreach (var item in StreamerPlaylist)
                {
                    item.IsSelected = false;
                }
                CurrentSong.IsSelected = true;
            }
            else
            {
                StartStopPlayer();
            }
        }
        public void AddToStreamerPlaylistFromChatPlaylistByIndex(int index)
        {
            string id = ChatPlayList.First(song => song.Index == index).Id;

            AddSong(CreateSongById(id));
        }
        public void CopyChatSongLinkByIndex(int index)
        {
            string link = ChatPlayList.First(song => song.Index == index).YoutubeLink;

            Clipboard.SetText(link);
        }
 public void DeleteChatSongByIndex(int index)
 {
     ChatPlayList.RemoveAt(index - 1);
 }
 public void ClearChatPlayList()
 {
     ChatPlayList.Clear();
     LastChatSong = null;
 }