media icon indicating copy to clipboard operation
media copied to clipboard

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

Open ziem opened this issue 1 year ago • 5 comments

[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.:

  • [1] https://exoplayer.dev/ui-components.html#overriding-drawables
  • [2] https://github.com/androidx/media/blob/release/libraries/ui/src/main/java/androidx/media3/ui/PlayerControlView.java#L102-L166

ziem avatar Mar 19 '24 11:03 ziem

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>

oceanjules avatar Mar 19 '24 15:03 oceanjules

Yes, exactly

ziem avatar Mar 20 '24 06:03 ziem

Do you have any updates on this ticket?

ziem avatar Apr 15 '24 10:04 ziem

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

oceanjules avatar May 08 '24 22:05 oceanjules

Awesome, thank you 🙂

ziem avatar May 09 '24 06:05 ziem