Open simranthakkar1996 opened 2 months ago
It might have been a part of solving this issue https://github.com/androidx/media/issues/1200 with commits https://github.com/androidx/media/commit/f3444aee5f8b983429f5386a33377e3ccb55a715 and https://github.com/androidx/media/commit/d35bc176fff7d3cb8826be0d86ef8e6c6d8e8a62
int rewindDrawableResId = R.drawable.exo_styled_controls_simple_rewind;
rewindDrawableResId = a.getResourceId(R.styleable.PlayerControlView_rewind_icon, rewindDrawableResId);
ImageView rewButton = findViewById(R.id.exo_rew);
TextView rewButtonWithAmount = findViewById(R.id.exo_rew_with_amount);
if (rewButton != null) {
// For a simple rewind button without seek-back increment value
rewButton.setImageDrawable(getDrawable(context, resources, rewindDrawableResId));
rewindButton = rewButton;
rewindButtonTextView = null;
} else if (rewButtonWithAmount != null) {
// For a circular rewind button with the amount in the middle
rewButtonWithAmount.setTypeface(typeface);
rewindButtonTextView = rewButtonWithAmount;
rewindButton = rewindButtonTextView;
}
Are you trying to override the icon by having a local drawable?
Thanks for your solution, @oceanjules . I was able to override the drawables successfully, but now the rewind and fast-forward functionality is not working after the override.
@oceanjules Hi thanks for your reply but when I try to use exo_styled_controls_simple_rewind as you mentioned its different icon and I wanna override it with the custom one that I created on my side.
This is what I updated to use my custom drawables to override the default ones But its crashing the app with inflating error
Xml files
<ImageButton
android:id="@id/exo_rew_with_amount"
style="@style/PlayerControlButtonBaseStyle.RewButton" />
<ImageButton
android:id="@id/exo_ffwd_with_amount"
style="@style/PlayerControlButtonBaseStyle.FfwdButton" />
Styles.xml
<style name="PlayerControlButtonBaseStyle.RewButton">
<item name="android:src">@drawable/exo_styled_controls_simple_rewind</item>
</style>
<style name="PlayerControlButtonBaseStyle.FfwdButton">
<item name="android:src">@drawable/exo_styled_controls_simple_fastforward</item>
</style>
exo_rew_with_amoun
@simranthakkar1996 The resource ids, which you have used is not correct, try replacing them with "exo_styled_controls_rewind", "exo_styled_controls_fastforward".
@akshaysuryaprakash As @oceanjules mentioned they changed the drawables so I changed it as asked
On side note I was able to override with my custom drawable I hade to use new drawable names exo_styled_controls_simple_rewind exo_styled_controls_simple_fastforward
And the xml ids remains same as before Below is the updated version that worked for me to replace my drawables with the default exoplayer ones
Xml File
<ImageButton
android:id="@id/exo_rew"
style="@style/PlayerControlButtonBaseStyle.RewButton" />
<ImageButton
android:id="@id/exo_ffwd"
style="@style/PlayerControlButtonBaseStyle.FfwdButton" />
Styles.xml
<style name="PlayerControlButtonBaseStyle.RewButton">
<item name="android:src">@drawable/exo_styled_controls_simple_rewind</item>
</style>
<style name="PlayerControlButtonBaseStyle.FfwdButton">
<item name="android:src">@drawable/exo_styled_controls_simple_fastforward</item>
</style>
Also just one request @oceanjules It would be much better if id change details are added to the release notes that way its easier to find the solution
Thank You.
@simranthakkar1996
Your proposed solution here looks identical to the original post, other than maybe you renamed your local resources? If that is the case, then there is still an issue. Existing layouts that utilize PlayerControlView
's app:controller_layout_id
got clobbered in what ever change occurred.
For example, I use a custom layout with my own iconography for every element. I shouldn't have to update my layout for breaking changes like this.
E.g.
<ImageView
android:id="@+id/exo_prev"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="10dp"
android:padding="10dp"
android:scaleX="-1"
app:layout_constraintBottom_toBottomOf="@+id/exo_playa"
app:layout_constraintEnd_toStartOf="@+id/exo_rew"
app:layout_constraintTop_toTopOf="@+id/exo_playa"
app:srcCompat="@drawable/ic_exo_skip_track"
android:contentDescription="@string/content_description_audio_previous_track" />
My layout
vs. what I'm getting at runtime.
Though I can set these icons in the PlayerControlView
via
app:next_icon="@drawable/ic_exo_skip_track"
app:previous_icon="@drawable/ic_exo_skip_track"
app:fastforward_icon="@drawable/ic_exo_ffwd_15"
app:rewind_icon="@drawable/ic_exo_rew_5"
You are still clobbering any icon set using the ImageView
or ImageButton
widget, thus making my layout very awkward to work with.
It seems to me that the above mentioned commits may be ignoring how PlayerControlView app:controller_layout_id
might be getting used?
I updated media3 from 1.3.1 to 1.4.1 recently and it changed my rewind and forward buttons to the original ones.
I am guessing some ids might be changed as I am using my custom buttons but the id is not matching with the exoplayer ids
I was not able to find anything releated to this in the release notes for 1.4.1 so if we have anything documented that I can refer so that the ids are correct on our side that would be really helpful.
Thank You.