private void OnLcdTimer(object source, EventArgs e) { bool btn0Now = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono0); if (btn0Now && !btn0Before) { InitSpot(); } btn0Before = btn0Now; UpdateLcd(); scrollStep += 1; // toggle between "ARTIST - ALBUM" and "ALBUM" on line 1 bool btn3Now = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono3); if (btn3Now && !btn3Before) { showAlbum = !showAlbum; } btn3Before = btn3Now; // toggle animated lines within progress bar bool btn2Now = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono2); if (btn2Now && !btn2Before) { showAnimatedLines = !showAnimatedLines; } btn2Before = btn2Now; }
private void OnLcdTimer(object source, EventArgs e) { bool btnNow = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono0); if (btnNow && !btnBefore) { InitSpot(); } btnBefore = btnNow; UpdateLcd(); scrollStep += 1; }
private void CheckInput(object source, EventArgs e) { seeking = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono2); inControlMenu = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono3); if (inControlMenu && !seeking) { bool btn2InCtlNow = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono2); if (btn2InCtlNow && !btn2Before) { var error = api.PausePlayback(); if (error.HasError()) { showingError = true; errorString = error.Error.Message; hideErrorTimer = new Timer(); hideErrorTimer.Enabled = true; hideErrorTimer.Interval = 3000; hideErrorTimer.Tick += OnErrorHidden; } } btn2Before = btn2InCtlNow; bool btn1InCtlNow = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono1); if (btn1InCtlNow && !btn1Before) { var error = api.SkipPlaybackToNext(); if (error.HasError()) { showingError = true; errorString = error.Error.Message; hideErrorTimer = new Timer(); hideErrorTimer.Enabled = true; hideErrorTimer.Interval = 3000; hideErrorTimer.Tick += OnErrorHidden; } } btn1Before = btn1InCtlNow; bool btn0InCtlNow = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono0); if (btn0InCtlNow && !btn0Before) { var error = api.SkipPlaybackToPrevious(); if (error.HasError()) { showingError = true; errorString = error.Error.Message; hideErrorTimer = new Timer(); hideErrorTimer.Enabled = true; hideErrorTimer.Interval = 3000; hideErrorTimer.Tick += OnErrorHidden; } } btn0Before = btn0InCtlNow; return; } if (seeking && !btn2Before && cachedPlayback != null && cachedPlayback.CurrentlyPlayingType != TrackType.Ad) { // set seek position to current currentSeekPosition = (double)cachedPlayback.ProgressMs / cachedPlayback.Item.DurationMs; } btn2Before = seeking; if (seeking) { bool btn0InSeekNow = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono0); if (btn0InSeekNow && !btn0Before) { int toMs = (int)(currentSeekPosition * cachedPlayback.Item.DurationMs); var error = api.SeekPlayback(toMs); if (error.HasError()) { showingError = true; errorString = error.Error.Message; hideErrorTimer = new Timer(); hideErrorTimer.Enabled = true; hideErrorTimer.Interval = 3000; hideErrorTimer.Tick += OnErrorHidden; } seeking = false; btn0Before = true; return; } btn0Before = btn0InSeekNow; if (lcd.IsButtonPressed(LogiLcd.LcdButton.Mono1)) { currentSeekPosition -= seekSpeed; } if (lcd.IsButtonPressed(LogiLcd.LcdButton.Mono3)) { currentSeekPosition += seekSpeed; } if (currentSeekPosition > 1.0) { currentSeekPosition = 1.0; } else if (currentSeekPosition < 0.0) { currentSeekPosition = 0.0; } return; } bool btn0Now = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono0); if (btn0Now && !btn0Before) { var thisItem = cachedPlayback; if (thisItem == null || thisItem.Item == null) { return; } if (likedSongNotification || unlikedSongNotification) { likedSongNotification = unlikedSongNotification = false; btn0Before = btn0Now; disableLikedSongNotificationTimer.Enabled = false; return; } var ListedItem = new List <string>(1); likedOrUnlikedSong = thisItem.Item; ListedItem.Add(likedOrUnlikedSong.Id); if (cachedLikedTrack) { api.RemoveSavedTracks(ListedItem); likedSongNotification = false; unlikedSongNotification = true; } else { api.SaveTrack(likedOrUnlikedSong.Id); likedSongNotification = true; unlikedSongNotification = false; } disableLikedSongNotificationTimer = new Timer(); disableLikedSongNotificationTimer.Enabled = true; disableLikedSongNotificationTimer.Interval = 5000; disableLikedSongNotificationTimer.Tick += OnLikedSongNotificationFinished; } btn0Before = btn0Now; bool btn1Now = lcd.IsButtonPressed(LogiLcd.LcdButton.Mono1); if (btn1Now) { var playback = cachedPlayback; if (playback == null) { return; } if (playback.CurrentlyPlayingType == TrackType.Ad) { // doing calls later down here is bad return; } if (playback.Context == null) { } else if (playback.Context.Type == "playlist") { var playlist = cachedPlaylist; if (playlist == null) { return; } upNextPlaylistTrack = null; for (int i = 0; i < playlist.Tracks.Items.Count; i++) { if (playlist.Tracks.Items[i].Track.Uri == playback.Item.Uri) { // next track is it if (i == playlist.Tracks.Items.Count - 1) { upNextPlaylistTrack = playlist.Tracks.Items[0]; } else { upNextPlaylistTrack = playlist.Tracks.Items[i + 1]; } break; } } if (upNextPlaylistTrack == null) { return; } } else if (playback.Context.Type == "album") { upNextPlaylistTrack = null; var newAlbum = cachedAlbum; if (newAlbum == null) { return; } for (int i = 0; i < newAlbum.Tracks.Items.Count; i++) { if (playback.Item.Uri == newAlbum.Tracks.Items[i].Uri) { if (i == newAlbum.Tracks.Items.Count - 1) { upNextAlbumTrack = null; } else { upNextAlbumTrack = newAlbum.Tracks.Items[i + 1]; } } } } } showUpNext = btn1Now; }