feat: Fire TV and Bluetooth media remote keys in the player (#68 part) - #133
Merged
Conversation
Reported: "On Fire Stick the remote button rewind/ffwd/play/pause buttons don't work with the player." Root cause: Only `Key.MediaPlayPause` / `MediaPlay` / `MediaPause` was handled in PlayerScreen.kt, and only inside the `if (showSubtitleMenu)` branch \u2014 so media keys did nothing unless the user had already opened the audio/subtitle menu. `Key.MediaRewind`, `MediaFastForward`, `MediaNext`, `MediaPrevious`, and `MediaStop` were not handled at all, anywhere. Fire TV Stick remotes ship with dedicated FF/RW/Play buttons and Amazon explicitly recommends apps handle them via the standard KeyEvent constants. Bluetooth A2DP headsets and keyboards also produce these keys. ARVIO was dropping all of them on the floor. Fix: add a top-level media-key dispatch at the very start of the player `.onKeyEvent` handler, BEFORE the error / menu / overlay branches. Each key returns `true` immediately so it always wins regardless of whether a menu is open. Handles: - `Key.MediaPlayPause` \u2192 toggle play/pause, show controls. - `Key.MediaPlay` \u2192 play, show controls. - `Key.MediaPause` \u2192 pause, show controls. - `Key.MediaStop` \u2192 pause and exit the player (equivalent to Back). - `Key.MediaRewind` \u2192 seek back 10 seconds via existing queueControlsSeek. - `Key.MediaFastForward` \u2192 seek forward 10 seconds. - `Key.MediaNext` \u2192 jump to the next episode (TV only). Uses the same onPlayNext lambda the existing Next Episode button uses, so the binge-group / source-preservation logic is identical. - `Key.MediaPrevious` \u2192 jump to the previous episode (TV only, guarded by `episodeNumber > 1`). The existing `Key.MediaPlayPause` branch inside the subtitle menu remains in place as a harmless safety net \u2014 it becomes unreachable in practice because the top-level dispatch already returns true, but leaving it means a future change to the top handler can't accidentally break media keys inside the subtitle menu. Closes the Fire TV remote part of #68. The other parts of #68 (subtitle timing sync, in-player episode picker) are scoped separately. Subtitle offset is already being shipped in PR #108.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the Fire TV remote part of #68. (Subtitle timing sync is in PR #108; in-player episode picker is scoped separately.)
Problem
On Fire TV Stick and Bluetooth media remotes, the dedicated FF/RW/Play/Pause/Next/Prev buttons did nothing during playback. Only
Key.MediaPlayPause/MediaPlay/MediaPausewere handled in PlayerScreen.kt, and only inside theif (showSubtitleMenu)branch \u2014 so media keys were silently dropped unless the user had already opened the audio/subtitle menu, which is the opposite of the normal use case.Fix
Added a top-level media-key dispatch at the very start of the player
.onKeyEventhandler, BEFORE the error / menu / overlay branches. Each key returnstrueimmediately so it always wins regardless of which overlay is open.MediaPlayPauseMediaPlayMediaPauseMediaStopMediaRewindqueueControlsSeek)MediaFastForwardMediaNextonPlayNextlambda \u2014 same binge-group / source-preservation logic as the in-UI Next Episode button)MediaPreviousepisodeNumber > 1)Single file, 69 lines added, 0 removed. The existing
MediaPlayPausebranch inside the subtitle menu is left as a harmless safety net \u2014 it becomes unreachable in practice but protects against future regressions to the top handler.Test plan
truefor media keys, other keys fall through to the existing handlers).