gpt4 book ai didi

android - StylePlayerView Controller xml 覆盖播放和暂停按钮不起作用

转载 作者:行者123 更新时间:2023-12-05 00:00:33 24 4
gpt4 key购买 nike

我更新了我的项目 exoplayer 依赖项,并且我正在使用 StylePlayerView(来自 exoplayer 的自定义布局)引用更新我的代码,但是当我执行我的代码时,关于这 2 个按钮 PLAY 和 PAUSE 的高估不起作用,你使用 PLAY_PAUSE 和有效,但我想自定义此图标。所以如果有人可以帮助我,我真的很感激。psdt.- 抱歉我说的是英语,因为我说西类牙语。

<?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>

最佳答案

我通过覆盖样式和可绘制对象解决了这个问题。我在我的值文件上创建了一个新样式,如下所示:

<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>

可绘制对象 exo_styled_control_play 和 exo_styled_control_pause 应包含您自己的可绘制对象代码。

如果它不能立即工作,请不要忘记使缓存失效并重新启动。

关于android - StylePlayerView Controller xml 覆盖播放和暂停按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71355529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com