Skip to content

Don't auto-resume playback on Bluetooth/headset connect#147

Open
symonbaikov wants to merge 1 commit into
paroj:edgefrom
symonbaikov:feature/no-resume-on-bluetooth-connect
Open

Don't auto-resume playback on Bluetooth/headset connect#147
symonbaikov wants to merge 1 commit into
paroj:edgefrom
symonbaikov:feature/no-resume-on-bluetooth-connect

Conversation

@symonbaikov

Copy link
Copy Markdown

Fixes issue #133: DSub was resuming the queue whenever a Bluetooth device connected, even when the user had explicitly paused or stopped playback (and even when the service had been force-stopped).

Three sources of the unwanted resume:

  1. MediaButtonIntentReceiver synthesized a KEYCODE_MEDIA_PLAY when the broadcast arrived with a null KeyEvent — exactly what Android delivers to the last active media app on Bluetooth connect. The synthesis is removed; null events are now ignored.

  2. MediaSession.Callback.onPlay() called downloadService.start() unconditionally. Likewise the KEYCODE_MEDIA_PLAY case in handleKeyEvent. Both are suppressed only when an audio output device was added in the last 3 seconds (tracked via AudioDeviceCallback). This catches the synthetic Bluetooth play without affecting explicit user taps in the notification, lockscreen, or Android Auto.

  3. PAUSED_TEMP (transient audio focus loss, e.g. a phone call) continues to auto-resume as before.

A new "Resume on Bluetooth connect" preference (default off) lets users restore the old behaviour if they want it.

Comment thread app/src/main/res/xml/changelog.xml Outdated
Fixes issue paroj#133: DSub was resuming the queue whenever a Bluetooth
device connected, even when the user had explicitly paused or stopped
playback (and even when the service had been force-stopped).

Three sources of the unwanted resume:

  1. MediaButtonIntentReceiver synthesized a KEYCODE_MEDIA_PLAY when
     the broadcast arrived with a null KeyEvent — exactly what Android
     delivers to the last active media app on Bluetooth connect. The
     synthesis is removed; null events are now ignored.

  2. MediaSession.Callback.onPlay() called downloadService.start()
     unconditionally. Likewise the KEYCODE_MEDIA_PLAY case in
     handleKeyEvent. Both are suppressed only when an audio output
     device was added in the last 3 seconds (tracked via
     AudioDeviceCallback). This catches the synthetic Bluetooth play
     without affecting explicit user taps in the notification,
     lockscreen, or Android Auto.

  3. PAUSED_TEMP (transient audio focus loss, e.g. a phone call)
     continues to auto-resume as before.

A new "Resume on Bluetooth connect" preference (default off) lets
users restore the old behaviour if they want it.
@symonbaikov symonbaikov force-pushed the feature/no-resume-on-bluetooth-connect branch from 38d3e0d to 472d576 Compare June 3, 2026 15:10
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