You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to avoid seeking to next item when pressing multiple times on the PLAY_PAUSE button in the media notification? #233
Hello,
I'm using media3 version 1.0.0-beta03. I observed the following behavior in the demo-session which uses the DefaultMediaNotificationProvider.
If you press quickly on the PLAY_PAUSE button in the media notification, it will automatically seek to the next item.
Is it a bug or an expected behavior? Is there a way to disable the "seek to next" behavior?
Currently, I overrided the onPlayerCommandRequest in the MediaLibrarySession.Callback to fix the issue but it does not work. It seems that the player command SEEK_TO_NEXT is sent when double tapping on the button PLAY_PAUSE.
override fun onPlayerCommandRequest(session: MediaSession, controller: MediaSession.ControllerInfo, playerCommand: Int): Int {
return when (playerCommand) {
Player.COMMAND_PLAY_PAUSE -> {
if (player.playWhenReady) {
player.pause()
} else {
player.play()
}
SessionResult.RESULT_INFO_SKIPPED
}
else -> super.onPlayerCommandRequest(session, controller, playerCommand)
}
}
Also, if I set the player command SEEK_TO_NEXT_MEDIA_ITEM in the media notification provider, it will be received as the player command SEEK_TO_NEXT in the method onPlayerCommandRequest...
Also, if I set the player command SEEK_TO_NEXT_MEDIA_ITEM in the media notification provider, it will be received as the player command SEEK_TO_NEXT in the method onPlayerCommandRequest...
The DefaultActionFactorymaps both COMMAND_SEEK_TO_NEXT_MEDIA_ITEM and COMMAND_SEEK_TO_NEXT to keyCode KEYCODE_MEDIA_NEXT, which will be mapped back to COMMAND_SEEK_TO_NEXT when the session handles the media button event.
This mapping is probably not ideal, and we're considering the enhancement around it.
Activity
tianyif commentedon Dec 21, 2022
Hi @aureliendrouet,
Thanks for reporting! This is reproducible from our end. It looks like this problem is due to https://github.com/androidx/media/blob/1.0.0-beta03/libraries/session/src/main/java/androidx/media3/session/MediaSessionLegacyStub.java#L226, which was a case ignored when the usage of
MediaSessionextended to the media notification. We will provide a fix soon!aureliendrouet commentedon Dec 22, 2022
Thank you. I am looking forward for the fix.
Do you have any idea about this?
tianyif commentedon Dec 22, 2022
The
DefaultActionFactorymaps bothCOMMAND_SEEK_TO_NEXT_MEDIA_ITEMandCOMMAND_SEEK_TO_NEXTto keyCodeKEYCODE_MEDIA_NEXT, which will be mapped back toCOMMAND_SEEK_TO_NEXTwhen the session handles the media button event.This mapping is probably not ideal, and we're considering the enhancement around it.
Double tap detection for Bluetooth media button events only
Double tap detection for Bluetooth media button events only
Chore/migrate media 1.0.2 (#10)