android - exoplayer android中的时间栏问题
问题描述
我正在尝试为 exoplayer 创建一个自定义控制器。一切正常,但我的 defaultTimeBar 有问题。我的时间栏不工作,即播放视频时看不到洗涤器头,时间栏的播放颜色也没有改变。我的自定义控制器的 xml 代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<LinearLayout
android:orientation="horizontal"
android:id="@+id/llSeekBar"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:padding="8dp"
android:gravity="center_vertical|center_horizontal"
android:layout_marginBottom="8dp"
android:background="@drawable/controller_background"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imvPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@drawable/ic_play" />
<TextView
android:id="@+id/txvStartDuration"
android:text="24:24"
android:layout_gravity="center"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@+id/defaultTimeBar"
android:layout_gravity="center"
android:layout_weight="4"
app:buffered_color="@color/white"
app:played_color="@color/red"
app:unplayed_color="@color/blue"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/txvDurationLeft"
android:text="24:24"
android:layout_gravity="center"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_marginEnd="16dp"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
我已经在我的 videoLayout 中实现了这个控制器,如下所示:
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/todayVideo"
app:player_layout_id="@layout/exo_styled_player_view"
app:controller_layout_id="@layout/custom_controller"
app:use_controller="true"
app:resize_mode="fit"
android:background="@color/black"
app:hide_on_touch="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:show_buffering="always" />
谁能告诉我为什么我的时间栏不工作?为什么我还需要做?请帮我。
解决方案
Exoplayer 控制器在其默认实现中具有预定义的 id,要制作自定义控制器,您必须为每个组件提供与默认实现完全相同的 id。
- 对于播放按钮,您必须使用 id
exo_play
- 暂停是
exo_pause
- 对于搜索栏,它是
exo_progress
- 对于计时器位置,它是
exo_position
- 对于视频持续时间,它是
exo_duration
使用这些 id 而不是您自己的,那么它会起作用。
推荐阅读
- php - 检查碳日期是否与 PHP 中的 YYYYMMDD HH:MM 匹配
- java - 创建具有“下载和运行”体验的 Java11 JavaFX 应用程序的正确方法是什么?
- .htaccess - 来自特定域的 Htaccess 页面重定向导致“ERR_TOO_MANY_REDIRECTS”
- pandas - 将 19 位时间戳转换为可读的毫秒格式
- r - R中数值积分的非光滑行为(函数“积分”)
- java - 无法在文本文件java循环中写入多行
- php - woocommerce_after_calculate_totals 无法更新购物车商品价格
- c++ - 为什么不能根据值字段直接使用 std::sort 对 std::map 进行排序
- swift - 为什么当路径满足时 NWPathMonitor 不给出路径更新?
- r - 同时拟合多个图