Skip to content

How to avoid seeking to next item when pressing multiple times on the PLAY_PAUSE button in the media notification? #233

Closed
@aureliendrouet

Description

@aureliendrouet

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...

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions