Skip to content

Fix a bug and add a feature for media resumption #2458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nift4
Copy link

@nift4 nift4 commented May 22, 2025

Fix a bug where media resumption would break if prepare() was called in onCreate()

Media resumption code relied on the assumption that if no media
controller sends any commands, the player will stay in STATE_IDLE.
This optimization however breaks if a developer calls prepare()
in or shortly after (in my case, which caused this to be a race)
onCreate(). Instead, use playWhenReady to determine whether we need
to do a query with effort, because playWhenReady really shouldn't
be set to true on device bootup. :)
SystemUI asks for resumption support while a session is active and just
started playing (playWhenReady=true), hence the optimization is still valid.


Formal API to allow apps to handle playback resumption themselves

This could previously be achieved by inspecting stack trace of
onPlaybackResumption() and then returning settable future that will
never be set, but this API adds a cleaner way and makes the caveats
of this clearer.

Issue: #1764

nift4 added 2 commits May 22, 2025 18:05
…in onCreate()

Media resumption code relied on the assumption that if no media
controller sends any commands, the player will stay in STATE_IDLE.
This optimization however breaks if a developer calls prepare()
in or shortly after (in my case, which caused this to be a race)
onCreate(). Instead, use playWhenReady to determine whether we need
to do a query with effort, because playWhenReady really shouldn't
be set to true on device bootup. :)
SystemUI asks for resumption support while a session is active and just
started playing (playWhenReady=true), hence the optimization is still valid.
This could previously be achieved by inspecting stack trace of
onPlaybackResumption() and then returning settable future that will
never be set, but this API adds a cleaner way and makes the caveats
of this clearer.

Issue: androidx#1764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant