Пример #1
0
 private void LoadState()
 {
     if (Preference.isStateFileExist())
     {
         String Text = File.ReadAllText(Preference.stateFilePath);
         if (Text.Length != 0)
         {
             try
             {
                 JObject json = JObject.Parse(Text);
                 LoopState   = (LoopStates)int.Parse(json["loopState"].ToString());
                 RandomState = (RandomStates)int.Parse(json["randomState"].ToString());
                 int index = int.Parse(json["index"].ToString());
                 volume = float.Parse(json["volume"].ToString());
                 YoutubeSearchItem music = PlayList.List[index];
                 currentMusic           = music;
                 PlayerThumbnail.Source = new BitmapImage(new Uri(currentMusic.Thumbnail));
                 titleTextBlock.Text    = currentMusic.Title;
                 PlayList.randomSwap(currentMusic);
                 state = States.Stopped;
             }
             catch (Exception ex)
             {
                 Debug.WriteLine(ex);
             }
         }
     }
     else
     {
         loopState   = LoopStates.NotLoop;
         randomState = RandomStates.UnRandom;
     }
 }
Пример #2
0
 private void PlayListDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try {
         ListBoxItem       item         = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem;
         YoutubeSearchItem currentMusic = item.Content as YoutubeSearchItem;
         DataEventArgs     args         = new DataEventArgs();
         args.Data1 = currentMusic;
         playListDoubleClick?.Invoke(this, args);
         PlayList.randomSwap(currentMusic);
     } catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
 }