2

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.

1 Answer 1

5

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.

1
  • Hello @Praveen, I'm using these ids from the start and it's working fine but if I'm playing a live youtube video, then the progress bar doesn't even have a scrubber, other than this, exo_rew and exo_ffwd buttons are also disabled, what can be an issue? May 8 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.