Skip to content

Make SimpleBasePlayer.State public #2128

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

Closed
bubenheimer opened this issue Feb 11, 2025 · 1 comment
Closed

Make SimpleBasePlayer.State public #2128

bubenheimer opened this issue Feb 11, 2025 · 1 comment
Assignees

Comments

@bubenheimer
Copy link

bubenheimer commented Feb 11, 2025

Use case description

I am implementing a custom Player in Kotlin, based on SimpleBasePlayer. I'd like to delegate some functionality to other classes outside of the class extending SimpleBasePlayer. Those classes are not capable of contributing to SimpleBasePlayer.State updates in a reasonable manner—via SimpleBasePlayer.State.Builder—because SimpleBasePlayer.State is protected. Everything relevant to updating State has to go inside a single giant monolith with objects, inner classes, and nested classes. The file has 1000+ lines.

For example, I have an AudioFocusChangeListener class that contributes to changing State. I am unable to move it outside the SimpleBasePlayer child class.

Proposed solution

Make SimpleBasePlayer.State public, which will in turn permit usage of SimpleBasePlayer.State.Builder outside of child classes of SimpleBasePlayer.

For example, this would support passing a lambda with a State.Builder argument around. The SimpleBasePlayer child can remain responsible for applying the updates.

state, getState(), and invalidateState() can remain private or protected, which is what actually matters.

Alternatives considered

Move AudioFocusChangeListener class back into the giant monolith.

@tonihei
Copy link
Collaborator

tonihei commented Feb 18, 2025

I agree this makes sense. We were initially hesitant because the idea is to build the state on demand in getState to match the backend implementation of the actual player, so you'd never need to pass around or store this State anywhere. But this is of course a bit too simplistic for actual usages :)

copybara-service bot pushed a commit that referenced this issue Feb 18, 2025
This ensures it's easier to handle these State updates in other
helper classes if needed.

Issue: #2128

#cherrypick

PiperOrigin-RevId: 728264396
@tonihei tonihei closed this as completed Feb 19, 2025
oceanjules pushed a commit that referenced this issue Mar 3, 2025
This ensures it's easier to handle these State updates in other
helper classes if needed.

Issue: #2128

PiperOrigin-RevId: 728264396
(cherry picked from commit f1c62c1)
@androidx androidx locked and limited conversation to collaborators Apr 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants