Closed minty-boo closed 1 year ago
I looked at the code and I think that I know what can be changed to allow for this behavior that you are asking for where the playback status will toggle (pause if its playing, play if its paused) when Bluetooth is disconnected.
I have not tested this yet but I hope one of the devs can confirm that this should work.
In app/src/main/java/org/jellyfin/mobile/webapp/RemotePlayerService.kt#110
, there is a event handler when the Bluetooth is disconnected.
After
webappFunctionChannel.callPlaybackManagerAction(PLAYBACK_MANAGER_COMMAND_PAUSE)
on line 110
I added this:
val currentState = playbackState ?: return
val canSeek = (currentState.actions and PlaybackState.ACTION_SEEK_TO) != 0L
val isPlaying = currentState.state == PlaybackState.STATE_PLAYING
var position = currentState.position
setPlaybackState(!isPlaying,position,canSeek)
@SegiH can you also add, bluetooth ear bud controls? like tap to play and pause? Nothing happens when I do that. It should play or pause when I tap my ear buds.
I'm not sure if I will be able to add that specific feature.
Why not? I mean every video player have that feature function...
I looked at the code and I think that I know what can be changed to allow for this behavior that you are asking for where the playback status will toggle (pause if its playing, play if its paused) when Bluetooth is disconnected.
I have not tested this yet but I hope one of the devs can confirm that this should work.
In
app/src/main/java/org/jellyfin/mobile/webapp/RemotePlayerService.kt#110
, there is a event handler when the Bluetooth is disconnected.After
webappFunctionChannel.callPlaybackManagerAction(PLAYBACK_MANAGER_COMMAND_PAUSE)
on line 110
Would that mean that if I connect a random device while Jellyfin not playing, the playback would start? I don't think that this is helpful. I think the natural default would be to stop playback once a Bluetooth device disconnects.
Right now, this is not the case, even though it's stated in the code: https://github.com/jellyfin/jellyfin-android/blob/master/app/src/main/java/org/jellyfin/mobile/webapp/RemotePlayerService.kt#L110
.. I think the natural default would be to stop playback once a Bluetooth device disconnects.
This is what I intended to suggest. Perhaps I should have clarified after @SegiH their suggestion.
In my opinion this should be the default behaviour. Though I cannot speak for others' preferences, or possible edge cases. Hence, the suggestion to make the behaviour customizable (likely just a toggle to enable/disable the behaviour, not to toggle the playback state).
Right now, this is not the case, even though it's stated in the code
Perhaps this is due to the code checking for STATE_AUDIO_CONNECTED
, which docs state is used for SCO (low BW, e.g. handset profile), rather than A2DP. Maybe checking the (dis)connected state and profile (handset or A2DP in either event), would fix this issue and result in the intended behaviour?
Excuse me sausage-fingering the close button.
Describe the feature you'd like Automatically pause music/video playback on Bluetooth headphones/earbuds/speaker disconnect (optionally allow behaviour to be toggled).
Additional context Most other streaming services' apps implement this behaviour, which is preferable for music listening; e.g. if the device is in a back pocket/bag, and TWS earphones are placed into their case (thus disconnecting), it currently continues to play the content over the device's built-in speaker(s).
Though, edge cases (e.g. switching to showing another person what you're watching/listening to, from it playing solely on the Bluetooth device) may exist, hence the toggleability suggestion.