androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.54k stars 373 forks source link

Playback resumption not triggered with `KEY_EVENT_PLAY_PAUSE` #493

Open marcbaechinger opened 1 year ago

marcbaechinger commented 1 year ago

Media3 Version

Media3 1.1.0-alpha01

Devices that reproduce the issue

Devices on which playback resumption results in a KEY_EVENT_PLAY_PAUSE (or devices with a BT device that sends this?).

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Enable playback resumption, start playback and terminate the app.

Then trigger playback resumption that results in a KEY_EVENT_PLAY_PAUSE.

Expected result

Playback resumption is triggered (Callback.onPlaybackResumption()).

Actual result

Only player.prepare/play is called instead

See stack trace screenshot in 27

Media

All media

Bug Report

WSteverink commented 1 month ago

Hi there @marcbaechinger!

Is this still an issue?

I am trying to fix a bug for MediaResumption that occurs on some devices. My problem occurs in the following scenario :

  1. Play something
  2. Pause it
  3. Swipe app away from recents.
  4. See a dead/stale notification that does not trigger onPlaybackResumption

Thanks to some other comments/issues i found out that our Service seems to restart due to a crash. I managed to fix that with the latest version 1.4.0-rc01 that contains:

pauseAllPlayersAndStopSelf()

My MediaLibraryService does this now:

    override fun onTaskRemoved(rootIntent: Intent?) {
        super.onTaskRemoved(rootIntent)
        logDebug("onTaskRemoved()")

        pauseAllPlayersAndStopSelf()
        cleanUp()
    }

    override fun onDestroy() {
        super.onDestroy()
        logDebug("onDestroy()")
        cleanUp()
    }

Now that i use the new function pauseAllPlayerAndStopSelf the service does not seem to restart due to a crash anymore. I do still have a stale notification though and i see this happening in the logs:

 E  Remote failure in play.
                                                                                                    android.os.DeadObjectException
                                                                                                        at android.os.BinderProxy.transactNative(Native Method)
                                                                                                        at android.os.BinderProxy.transact(BinderProxy.java:584)
                                                                                                        at android.media.session.ISessionCallback$Stub$Proxy.onPlay(ISessionCallback.java:729)
                                                                                                        at com.android.server.media.MediaSessionRecord$SessionCb.play(MediaSessionRecord.java:1408)
                                                                                                        at com.android.server.media.MediaSessionRecord$ControllerStub.play(MediaSessionRecord.java:1743)
                                                                                                        at android.media.session.ISessionController$Stub.onTransact(ISessionController.java:523)
                                                                                                        at android.os.Binder.execTransactInternal(Binder.java:1339)
                                                                                                        at android.os.Binder.execTransact(Binder.java:1275)

I found this issue while doing some digging, so i am just wondering if this is the same problem. Thanks in advance!

WSteverink commented 1 month ago

After i did some extra digging i decided to create an issue for the above.

I think but i am not sure if both issues are related.