feat(player): complete MediaSession handlers + teardown - #27
Merged
Merged
Conversation
The lock screen / Control Center / CarPlay expose a stop control and 15s skip (seekbackward/seekforward) that had no handlers, so those affordances did nothing. The registration effect also never cleared its handlers, so when the queue emptied the lock screen stayed bound to the previous track's closures. - Register stop, seekbackward, seekforward (plus the existing seekto), each wrapped so an engine that doesn't support an action doesn't throw. - Tear all handlers down on cleanup and when nothing is loaded (also clear metadata), via a shared MEDIA_ACTIONS list. - Centralize playbackState as the single source of truth: 'none' when nothing is loaded, else mirror isPlaying — so iOS routes the next remote press to the correct action. Verified in-browser: playing sets metadata + playbackState 'playing', pausing sets 'paused', and all handlers register without throwing. Fixes #10. Fixes #11. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FkDKh1Uo1a4D7n5wCKdcKF
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.
Fixes #10. Fixes #11.
Problem
seekbackward/seekforward) that had no handlers, so those affordances did nothing.playbackStatewas set only fromisPlaying, so it never reflected the "nothing loaded" state.Fix
stop,seekbackward,seekforward(plus existingseekto), each wrapped so an engine that doesn't support an action doesn't throw.metadata), via a sharedMEDIA_ACTIONSlist.playbackStateas the single source of truth:'none'when nothing is loaded, else mirrorisPlaying— so iOS routes the next remote press to the correct action. Together with the reject-path sync from fix: reliable AirPods/lock-screen resume + correct the deploybasenote #23, this closes [MEDIUM] MediaSessionplaybackStatedesyncs whenaudio.play()rejects (swallowed catch) #11.Verification
Built clean; runtime smoke test:
metadata.titleset,playbackState"Last Stop",playing✅playbackStatepaused✅🤖 Generated with Claude Code
Generated by Claude Code