private async void OnPlayPauseClick(object sender, RoutedEventArgs e) { if (api.GetStatus().IsPlaying) { await api.Pause(); } else { await api.Play(); } }
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; }