小编Sud*_*eep的帖子

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>
Run Code Online (Sandbox Code Playgroud)

我在我的 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" />
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么我的时间栏不起作用?我还需要做什么?请帮我。

android custom-controls kotlin exoplayer

2
推荐指数
1
解决办法
1998
查看次数

标签 统计

android ×1

custom-controls ×1

exoplayer ×1

kotlin ×1