I updated my project exoplayer dependency, and i was updating my code with StylePlayerView (customized layout from exoplayer) reference, but when i executed my code the overrating about this 2 buttons PLAY and PAUSE, are not working, y use PLAY_PAUSE and works, but i want to customize this icons.. so if someone can help me, i really apreace it. psdt.- And sorry about mi english because i speak spanish.
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/customized_controller"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="@color/transparentBackground">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@+id/exo_rew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/replay"
android:layout_gravity="center"
style="@style/ExoMediaButton.Rewind"
android:src="@drawable/ic_replay_10" />
<ImageButton
android:id="@+id/exo_play_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/play"
android:visibility="gone"
android:layout_gravity="center"
style="@style/ExoMediaButton.Play"
android:src="@drawable/ic_play"/>
<ImageButton
android:id="@+id/exo_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/play"
android:layout_gravity="center"
android:visibility="visible"
style="@style/ExoMediaButton.Play"
android:src="@drawable/ic_play"/>
<ImageButton
android:id="@+id/exo_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/pause"
android:layout_gravity="center"
android:visibility="visible"
style="@style/ExoMediaButton.Pause"
android:src="@drawable/ic_pause" />
<ImageButton
android:id="@+id/exo_ffwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/fast_forward"
android:layout_gravity="center"
style="@style/ExoMediaButton.FastForward"
android:src="@drawable/ic_forward_30" />
</LinearLayout>
<TextView
android:id="@+id/exo_duration"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
android:textColor="@color/whitePrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@+id/exo_progress"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:buffered_color="@color/grey_accent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/exo_duration"
app:layout_constraintStart_toEndOf="@+id/exo_position"
app:played_color="@color/blueLight"
app:unplayed_color="@color/whiteSecondary"
tools:ignore="SpeakableTextPresentCheck" />
<ImageView
android:id="@+id/bt_fullscreen"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:contentDescription="@string/full_screen"
android:src="@drawable/ic_fullscreen_24"
app:layout_constraintBottom_toTopOf="@+id/exo_progress"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/exo_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
android:textColor="@color/whitePrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/bt_close_player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:contentDescription="@string/close"
android:paddingHorizontal="8dp"
android:src="@drawable/ic_chevron_left"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txvChapterTitle"
android:layout_width="0dp"
android:layout_height="0dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingHorizontal="8dp"
android:text="@string/title"
android:textColor="@color/whitePrimary"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/bt_close_player"
app:layout_constraintEnd_toStartOf="@+id/lnSettings"
app:layout_constraintStart_toEndOf="@+id/bt_close_player"
app:layout_constraintTop_toTopOf="@+id/bt_close_player" />
<LinearLayout
android:id="@+id/lnSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="@+id/bt_close_player"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/bt_close_player">
<ImageView
android:id="@+id/bt_settings"
android:layout_width="18dp"
android:layout_height="18dp"
android:contentDescription="@string/title_settings"
app:srcCompat="@drawable/ic_settings_24" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
I solved this issue for me by overriding the style and drawables. I created a new style on my values file like below:
<style name="ExoStyledControls.Button.Center.PlayPause">
<item name="android:src">@drawable/exo_styled_controls_pause</item>
<item name="android:contentDescription">@string/exo_controls_play_description</item>
<item name="android:padding">@dimen/exo_icon_padding</item>
</style>
<drawable name="exo_styled_controls_pause">@drawable/exo_styled_control_pause</drawable>
<drawable name="exo_styled_controls_play">@drawable/exo_styled_control_play</drawable>
The drawables exo_styled_control_play and exo_styled_control_pause should contain your own drawable code.
Do not forget to invalidate cache and restart if it doesn't work right away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With