Exoplayer - Need help attaching this download image from custom layout to activity so i can define on click events

220 Views Asked by At

I am trying to attach a download button to Exoplayer's simple layout by adding an image view near fullscreen image view like this -

 <ImageView
    android:id="@+id/bt_download"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@drawable/ic_file_download_white"
    android:scaleType="fitCenter"/>

   <ImageView
    android:id="@+id/bt_fullscreen"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@drawable/exo_controls_fullscreen_enter"
    android:scaleType="fitCenter"/>

Here is the custom_controller.xml in which I have attached this image.

<?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:background="#80000000"
 android:layout_width="match_parent"
 android:layout_height="match_parent">

 <LinearLayout
  android:orientation="horizontal"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerInParent="true">

  <ImageView
   android:id="@+id/exo_rew"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/exo_controls_rewind"
   android:layout_marginEnd="16dp"/>

  <ImageView
   android:id="@+id/exo_play"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/exo_controls_play"/>

  <ImageView
   android:id="@+id/exo_pause"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/exo_controls_pause"/>

  <ImageView
   android:id="@+id/exo_ffwd"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:src="@drawable/exo_controls_fastforward"
   android:layout_marginStart="16dp"/>

 </LinearLayout>

 <LinearLayout
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_alignParentBottom="true">

  <LinearLayout
   android:gravity="bottom"
   android:orientation="horizontal"
   android:padding="8dp"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content">

   <TextView
    android:textColor="@android:color/white"
    android:id="@+id/exo_position"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

   <TextView
    android:textColor="#ffcbcdc8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="/"
    android:layout_marginStart="4dp"
    android:layout_marginEnd="4dp"/>

   <TextView
    android:textColor="#ffcbcdc8"
    android:id="@+id/exo_duration"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1.0"/>
    
    <ImageView
    android:id="@+id/bt_download"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@drawable/ic_file_download_white"
    android:scaleType="fitCenter"/>

   <ImageView
    android:id="@+id/bt_fullscreen"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@drawable/exo_controls_fullscreen_enter"
    android:scaleType="fitCenter"/>

  </LinearLayout>

  <com.google.android.exoplayer2.ui.DefaultTimeBar
   android:id="@+id/exo_progress"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_marginTop="-8dp"
   app:buffered_color="#ff95989f"
   app:played_color="#ffff0000"
   app:unplayed_color="#ff45424e"/>

 </LinearLayout>

</RelativeLayout>

here is the image of how the media controller looks after adding this image

so now when i am calling this button from player activity with btDownload = player_view.findViewById(R.id.bt_download); the compiler is saying -

btDownload cannot be resolved to a variable

while the similar method btFullScreen = player_view.findViewById(R.id.bt_fullscreen); is working fine for full screen button(image), can anyone help me identify this problem ?, and can someone please explain me why this is happening with the download button only ? .

0

There are 0 best solutions below