Skip to content
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

Allow overriding drawables locally (only for a specific PlayerView instance) #1200

Open
ziem opened this issue Mar 19, 2024 · 5 comments
Open
Assignees

Comments

@ziem
Copy link

ziem commented Mar 19, 2024

[REQUIRED] Use case description

My app has two players: video player and podcast player. Both should look different in terms of icons, buttons' positions, and spacing. Spacing and reordering buttons is easy, but it seems that the only option to replace icons is to do it globally1, for all PlayerViews.

Proposed solution

It would be great to have attributes similar to show_timeout2 for icons/resources used in the PlayerControlView.
e.g.:

  • play_resource_id
  • pause_resource_id
  • etc.

with the fallback to exo_styled_controls_play, exo_styled_controls_pause, .. if not present.

Alternatives considered

No alternatives were considered.


Ref.:

@oceanjules
Copy link
Contributor

Please correct me if I'm wrong. Do I understand that you want:

playResourceId = 
   a.getResourceId(R.styleable.PlayerView_play_resource_id, 
                  /* defValue= */ R.drawable.exo_styled_controls_play);

and then you can define various xml views

app:play_resource_id="R.drawable.personal_controls_play"

or

app:play_resource_id="R.drawable.personal_controls_play_new"

and

<drawable name="personal_controls_play">@drawable/personal_play_circle_filled</drawable>

<drawable name="personal_controls_play_new">@drawable/personal_play_square</drawable>

@ziem
Copy link
Author

ziem commented Mar 20, 2024

Yes, exactly

@oceanjules oceanjules self-assigned this Mar 23, 2024
@ziem
Copy link
Author

ziem commented Apr 15, 2024

Do you have any updates on this ticket?

@oceanjules
Copy link
Contributor

oceanjules commented May 8, 2024

Hi @ziem, apologies, I have been away for a month. I discussed this internally within the team and I don't see any issue with the proposed solution above. I will prioritise it next week and hopefully you can test it out in 1.4.0 alpha/beta

@ziem
Copy link
Author

ziem commented May 9, 2024

Awesome, thank you 🙂

copybara-service bot pushed a commit that referenced this issue Jun 3, 2024
Before this change:
The only way to customize the icons was to override the drawables, e.g.
* `exo_styled_controls_play`
* `exo_styled_controls_pause`

However, that would set the drawables globally and prevent users from customizing the icons **per** PlayerView.

After the change, it is possible to provide drawable icons in the xml layout directly via `<androidx.media3.ui.PlayerView>` and
* `app:play_icon="@drawable/...`
* `app:pause_icon="@drawable/...`
* `app:vr_icon="@drawable/...`
* `app:fullscreen_exit_icon="@drawable/...`
* `app:next_icon="@drawable/...`

Note:
Two buttons that are left out of this change are fast-forward and rewind. They are more complicated due to layout insertion and customization with seek back/forward increments in the TextView.

Issue: #1200
PiperOrigin-RevId: 639832741
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants