private bool UpdateSongInfo() { var status = _spotifyClient.GetStatus(); var track = status?.Track; if (track == null) { return(false); } _trackLength = track.Length; TrackProgressChanged?.Invoke(this, CalculateTrackPercentange(status.PlayingPosition)); TrackInfoChanged?.Invoke(this, new TrackInfoChangedEventArgs { TrackName = track.TrackResource.Name, Artist = track.ArtistResource.Name, AlbumArt = track.GetAlbumArt(AlbumArtSize.Size640) }); if (status.Playing) { TrackPlaying?.Invoke(this, EventArgs.Empty); } else { TrackPaused?.Invoke(this, EventArgs.Empty); } return(true); }
private void ResetState() { TrackInfoChanged?.Invoke(this, new TrackInfoChangedEventArgs { TrackName = "", AlbumArt = null }); TrackPaused?.Invoke(this, EventArgs.Empty); TrackProgressChanged?.Invoke(this, 0); }
private void SetBlankState() { TrackInfoChanged?.Invoke(this, new TrackInfoChangedEventArgs()); TrackPaused?.Invoke(this, EventArgs.Empty); TrackProgressChanged?.Invoke(this, 0); _currentIsPlaying = false; _currentArtist = null; _currentSong = null; }
private void SpotifyClientOnOnPlayStateChange(object sender, PlayStateEventArgs playStateEventArgs) { if (playStateEventArgs.Playing) { TrackPlaying?.Invoke(this, EventArgs.Empty); } else { TrackPaused?.Invoke(this, EventArgs.Empty); } }
private void CheckSpotifyTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs) { try { var spotifyTitle = _spotifyControls.GetSpotifyTitle(); // Spotify not open if (string.IsNullOrEmpty(spotifyTitle)) { // Already blanked if (!_spotifyRunning) { return; } SetBlankState(); _spotifyRunning = false; return; } _spotifyRunning = true; if (spotifyTitle == NotPlayingTitle) { // already paused if (!_currentIsPlaying) { return; } TrackPaused?.Invoke(this, EventArgs.Empty); _currentIsPlaying = false; return; } ExtractTitle(spotifyTitle); } finally { _checkSpotifyTimer.Enabled = true; } }
private void NotifyPlayerState() { var playing = _itunesControls.IsPlaying; if (_isPlaying == playing) { return; } if (playing) { TrackPlaying?.Invoke(this, EventArgs.Empty); } else { TrackPaused.Invoke(this, EventArgs.Empty); } _isPlaying = playing; }
private void NotifyState() { var isPlaying = _ipc.GetPlayState().HasFlag(MusicBeeIPC.PlayState.Playing); if (isPlaying == _isPlaying) { return; } if (isPlaying) { TrackPlaying?.Invoke(this, EventArgs.Empty); } else { TrackPaused?.Invoke(this, EventArgs.Empty); } _isPlaying = isPlaying; }