Repository navigation
Ignore the play headphones send as they disconnect - #165
Merged
Merged
Conversation
The earlier fix only stopped plays the browser starts on the audio element by itself. On Android, Bluetooth headphones dropping out often send a "play" through the media session instead, the same route as the listener pressing play, so the music still came back out of the speaker. A media session play within a few seconds of an audio device change is now ignored, and one that lands just before the change is reported is undone. A device that is known to have gone pauses playback, as unplugging wired headphones does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016uTomBBsEAYGxqVqiM58P6
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.
Requested by Tom · project thread
Before: taking Bluetooth headphones out paused the music, but when they then disconnected, playback started again out of the phone speaker.
After: the music stays paused when headphones or a car drop out. Pressing play yourself still works as normal.
The earlier fix (2ececee) only stopped plays the browser starts on the audio element by itself. On Android, headphones dropping out often send a "play" through the media session, the same route as pressing play on the lock screen or headphones, which that fix lets through on purpose.
How: a new
src/lib/audioOutputs.tslistens fordevicechangeonnavigator.mediaDevices. A media session play within 4 seconds of a device change is ignored; one that lands just before the change is reported is undone. When the browser can see device ids and one has gone while playing, playback pauses, as unplugging wired headphones does. Trade-off: pressing play within 4 seconds of connecting headphones is ignored, so you'd press it again.Tests: five new PlayerRuntime tests (three fail without the change). Lint, typecheck and the full suite pass locally.
Generated by Claude Code