Skip to content

Pressing Play/Pause button twice on remote devices triggers Command_Seek_To_Next #962

Closed

Description

@charlesEnigma

Version

Media3 1.1.1

More version details

No response

Devices that reproduce the issue

Fire Tv Stick 4k Max (2nd Gen) running Fire OS 8.1.0.2 = Android 11
Sony Bravia A95L running Android 12
Sony Bravia A95K running Android 11

Devices that do not reproduce the issue

Devices without Play/Pause button

Reproducible in the demo app?

No

Reproduction steps

Issue is the same as this issue: #233

We're seeing the issue on devices with a Play/Pause button on their remote. The issue is pressing the Play/Pause twice is triggering the COMMAND_SEEK_TO_NEXT command inside Media3 MediaSession. Originally we created a workaround for this issue since this was a known bug: androidx/media#233. Our workaround is causing an issue on FireTV for the Next voice command so we are removing the workaround but notice this issue persists.

Our app is using Media3 version 1.1.1.

Any suggestions on how to prevent MediaSession from triggering COMMAND_SEEK_TO_NEXT when Play/Pause button is pressed twice?

Expected result

Pressing Play/Pause multiple times plays or pauses playback.

Actual result

The next episode command is triggered.

Media

Not applicable

Bug Report

Activity

  1. charlesEnigma commented on Jan 11, 2024

    @charlesEnigma
    Author

    Closing ticket. This issue is resolved with 1.2.0

  2. charlesEnigma commented on Jan 11, 2024

    @charlesEnigma
    Author

    Sorry, for the confusion. When updating to version 1.2.0 our workaround was re-enabled so it appeared to be fixed but after removing the workaround we are seeing the issue in version 1.2.0 as well.

  3. self-assigned this
    on Jan 12, 2024
  4. tianyif commented on Jan 12, 2024

    @tianyif
    Contributor

    Hi @charlesEnigma,

    Starting from 1.2.0, MediaSession.Callback.onMediaButtonEvent has been added so you can override the default implementation and handle media buttons in a custom way. Could you please try this and see if it can solve your problem?

  5. tianyif commented on Jan 12, 2024

    @tianyif
    Contributor

    I'm re-tagging it as "bug" as we should figure out why the remote device doesn't resolve the double tap as next, because if it does, the remote device can define the behaviour of the tapping rather than the library or apps.

  6. marcbaechinger commented on Jan 16, 2024

    @marcbaechinger
    Contributor

    I think the issue is related to TV remotes that sends key events over Bluetooth. This may be a GoogleTV remote or a generic D-pad TV remote like for instance for a Sony Bravia.

    The double-click detection seems to be most useful on mobile devices when a user has connected a BT headset to the device. I think it's justifiable to simply disable double-click detection on TV devices.

    @charlesEnigma Any thoughts whether this would help for your case?

  7. charlesEnigma commented on Jan 16, 2024

    @charlesEnigma
    Author

    @tianyif,

    I will try overriding MediaSession.Callback.onMediaButtonEvent and see if we can handle the media buttons in a custom way.

    @marcbaechinger,
    Yes, disabling double-click detection on TV devices would help our use case. By disabling double-click detection on TV devices we would simply be preventing the users from rapidly pressing buttons correct? For example, the user presses the "play/pause" button waits at least 2 seconds, and presses the "play/pause" button again triggering the "play/pause" functionality.

  8. marcbaechinger commented on Jan 17, 2024

    @marcbaechinger
    Contributor

    By disabling double-click detection on TV devices we would simply be preventing the users from rapidly pressing buttons correct?

    The library doesn't swallow events after this change. All events will be delivered but the events won't be translated to a skip next event but the events arrive at the player resulting in pausing then playing again which is what the user intended to do with pressing twice.

  9. marcbaechinger commented on Jan 17, 2024

    @marcbaechinger
    Contributor

    I'm closing this issue as it is fixed with the commit above. Please open a new issue if required.

  10. charlesEnigma commented on Jan 18, 2024

    @charlesEnigma
    Author

    @tianyif and @marcbaechinger ,

    I was able to override KEYCODE_MEDIA_PLAY_PAUSE using [MediaSession.Callback.onMediaButtonEvent].

    override fun onMediaButtonEvent(
                session: MediaSession,
                controllerInfo: MediaSession.ControllerInfo,
                intent: Intent
            ): Boolean {
    
                val keyEvent: KeyEvent? = intent.getParcelableExtra<KeyEvent>(Intent.EXTRA_KEY_EVENT)
                val keyCode = keyEvent?.keyCode
                when (keyCode) {
                    KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE  -> {
                        if(keyEvent.action == KeyEvent.ACTION_UP) {
                            if (session.player.playWhenReady) {
                                session.player.pause()
                            } else {
                                session.player.play()
                            }
                        }
                        return true
                    }
                    else ->  return super.onMediaButtonEvent(session, controllerInfo, intent)
                }
            }
    

    Questions:

    1. Disable double-click detection on TV devices is this something the developer is expected to implement or will this be included in future versions of media3?
  11. marcbaechinger commented on Jan 19, 2024

    @marcbaechinger
    Contributor

    The commit referenced above implements this and this will be part of the next release.

  12. charlesEnigma commented on Jan 22, 2024

    @charlesEnigma
    Author

    @marcbaechinger,

    Awesome and thank you. The team will be looking forward to the next release. :-)

  13. locked and limited conversation to collaborators on Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions