Skip to content

Ignore the play headphones send as they disconnect - #165

Merged
elcapitantommy merged 1 commit into
mainfrom
claude/project-thread-ic3nsk
Oct 20, 2026
Merged

elcapitantommy merged 1 commit into
mainfrom
claude/project-thread-ic3nsk

Conversation

@elcapitantommy

Copy link
Copy Markdown
Owner

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.ts listens for devicechange on navigator.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

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
@elcapitantommy elcapitantommy self-assigned this Oct 20, 2026
@elcapitantommy
elcapitantommy merged commit 9c405e6 into main Oct 20, 2026
2 checks passed
@elcapitantommy
elcapitantommy deleted the claude/project-thread-ic3nsk branch October 20, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants