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.74k stars 417 forks source link

framework: Playback resumption setting `qs_media_resumption` is not respected #1090

Open Hurricos opened 9 months ago

Hurricos commented 9 months ago

Version

Media3 1.2.0

More version details

This is the Media3 library build which comes with AOSP 13.

Devices that reproduce the issue

Google Pixel 6a, LineageOS 20.

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

It is trivial to demonstrate the violation of documented behavior under any app supporting https://developer.android.com/media/media3/session/background-playback#resumption

The playback resumption feature can be turned on and off using the Settings app, under the Sound > Media options. The user can also access Settings by tapping the gear icon that appears after swiping on the expanded carousel.

From this point:

Expected result

Media does not play when the play button is pressed with qs_media_resumption disabled.

Actual result

App opens and media plays, despite the app being killed and playback resumption being disabled.

Media

This is a framework issue reproduceable with any app that implements Playback Resumption, including ExoPlayer.

Bug Report

Hurricos commented 9 months ago

To be clear, Media Resumption and Playback Resumption are asserted to be components of the same thing in https://github.com/androidx/media/issues/211#issuecomment-1805822872.

If this is not true, and it is not intended that Playback Resumption be able to be disabled, let me know and I'll file a separate issue.

I also realize the issue is not directly in this repository, but in the android_frameworks. I'm filing here, as here is where Media3 is documented.

marcbaechinger commented 9 months ago

The setting you are referring to is only about the media controls which offers the option to show a notification that allows resuming playback from the notification (media controls).

The Media3 library uses the playback resumption notification with its implementation besides playback resumption with MediaButtonEvents coming from Bluetooth or a hardware button.

Disabling Media Controls resumption is only supposed to disable the notification. Can you confirm that the notification is not shown when you disable resumption in the settings?

qs_media_resumption

The interesting bit of your report is the use of this variable qs_media_resumption. Can you shed some light on where this naming comes from? If you have extended knowledge about implementation details of this setting, for instance whether an app can get the value of this setting by API, please let us know.

Hurricos commented 9 months ago

Disabling Media Controls resumption is only supposed to disable the notification. Can you confirm that the notification is not shown when you disable resumption in the settings?

Off the top of my head, I absolutely can confirm this works.

The interesting bit of your report is the use of this variable qs_media_resumption. Can you shed some light on where this naming comes from?

I do not know. I assumed that Media3 and associated Android libraries were responsible for the naming, as you documented the functionality those settings control here.

Since you've worked heavily on this, I suspect you also did not know that qs_media_resumption was the setting name -- I'm guessing you feel that it's a misnomer?

Now, my business:

I don't agree with the tag, "won't fix: intended behavior". Correct me if I'm wrong, but this is the wording of the documentation you updated as part of issue #211:

https://developer.android.com/media/media3/session/background-playback#resumption

Playback resumption

Media buttons are hardware buttons found on Android devices and other peripheral devices, such as the play or pause button on a Bluetooth headset. Media3 handles media button inputs for you when the service is running.

:

https://developer.android.com/media/implement/surfaces/mobile#responding_to_playbackstate_actions

Media resumption allows users to restart previous sessions from the carousel without having to start the app. When playback begins, the user interacts with the media controls in the usual way.

The playback resumption feature can be turned on and off using the Settings app, under the Sound > Media options. The user can also access Settings by tapping the gear icon that appears after swiping on the expanded carousel.

I read this as: the playback resumption feature, which allows users to restart previous sessions from the carousel or using hardware buttons, without having to start the app, can be disabled by changing it under Sound > Media options.

Since this is not true, the behavior described by the documentation is not the intended behavior (disabling qs_media_resumption does not disable the resumption-upon-media-buton behavior), and documentation should be adjusted before closing this issue.

Leaving documentation aside, I can open a separate user-story for the problem that brought me here:

I imagine this sort of request would go to the maintainers of the Android Framework. I imagine the Media3 API just consumes those behaviors?

marcbaechinger commented 9 months ago

I agree that it would be nice to have this setting integrated with Media3. Thanks for elaborating!

qs_media_resumption seems to be the setting key in the Android source (here). I don't know whether an app can read that setting though, so I doubt Media3 would be able to take this into account. We should investigate this some further.

Feel free to file such a feature request if you want to. We'd probably have to comment on feasibility of apps reading that setting in a similar way.

The documentation reads correct to me. That the 'Media controls' page refers to the entire Media3 resumption feature is an interpretation that isn't intended and not obvious to me.

Hurricos commented 9 months ago

The documentation reads correct to me. That the 'Media controls' page refers to the entire Media3 resumption feature is an interpretation that isn't intended and not obvious to me.

The second link I pasted was incorrect: the link should have been to the Support media resumption link: https://developer.android.com/media/implement/surfaces/mobile#supporting-media

This should make it clearer how the documentation misleads: the second paragraph under Support media resumption indicates how the user can disable playback resumption; the paragraph immediately following it links here, which describes "Playback resumption" by saying:

Media buttons are hardware buttons found on Android devices and other peripheral devices, such as the play or pause button on a Bluetooth headset.

The fact that Support media resumption links to that part of media controls under the "Playback resumption" header is a good sign that media controls invoke playback resumption.

Not to get into the weeds.

RE: Apps reading this key: this isn't necessary. For example, the framework code under https://android.googlesource.com/platform/frameworks/base/+/f810d81839af38ee121c446105ca67cb12992fc6/packages/SystemUI/src/com/android/systemui/media which launches inactive apps upon handling the play button could read some setting and no-op if the app in question isn't launched.

Hurricos commented 9 months ago

Where should such a FR go? It's clear it belongs in the framework code, even though it's in your wheelhouse to document and implement the behavior.