示例#1
0
 private async void OnPlayPauseClick(object sender, RoutedEventArgs e)
 {
     if (api.GetStatus().IsPlaying)
     {
         await api.Pause();
     }
     else
     {
         await api.Play();
     }
 }
示例#2
0
        private void Connect()
        {
            if (api != null)
            {
                api.OnTrackChange     -= OnTrackChange;
                api.OnPlayStateChange -= OnPlayStateChange;
                api.OnTrackTimeChange -= OnTrackTimeChange;
            }

            api = SpotifyApiFactory.GetSpotifyApi(config);
            api.Connect();

            if (api.IsConnected)
            {
                var status = api.GetStatus();
                UpdatePlayState(status.IsPlaying);
                UpdateDisplay(status.Track);
            }

            api.OnTrackChange     += OnTrackChange;
            api.OnPlayStateChange += OnPlayStateChange;
            api.OnTrackTimeChange += OnTrackTimeChange;
        }