Sudeep
Sudeep

Reputation: 129

Problem with timebar in exoplayer android

I am trying to create a custom controller for exoplayer. Everything is working fine but i have a problem with the defaultTimeBar. My timebar is not working i.e. when video is played no scrubber head can be seen and played color for timebar is also not changed. My xml code for custom controller can be seen below:

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

I have implemented this controller in my videoLayout as follow :

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

can anybody please tell me why my timebar is not working? why else do i need to do? please help me.

Upvotes: 2

Views: 2451

Answers (1)

Praveen
Praveen

Reputation: 3484

Exoplayer controller has predefined ids in their default implementation, For making a custom controller you have to give each component their ids exactly as the default implementation.

  • For the play button you have to use id exo_play
  • For pause it's exo_pause
  • For seekbar it's exo_progress
  • For timer position it's exo_position
  • For video duration it's exo_duration

Use these ids instead of your own then it'll work.

Upvotes: 6

Related Questions