Sophie
Sophie

Reputation: 2634

SimpleExoPlayerView customization to keep background transparent and controls always visible

I'm using ExoPlayer to play audio songs, here is how my SimpleExoPlayerView looks like:

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
  android:id="@+id/video_view"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" />

Result:

enter image description here

Requirement:

  1. How to keep SimpleExoPlayerView background as transparent, instead of Black background [as still, I'm getting] (see above Screenshot)

  2. How to keep SimpleExoPlayerView always visible (as still it appears and then disappear, until I touch again)

Upvotes: 3

Views: 7248

Answers (3)

dell116
dell116

Reputation: 5905

In reference to the "keep background transparent" aspect of this question, you may be setting the background of the controls background as transparent, but still seeing a black background on your playback control view.

Reason being....it's not your controls background that's black.

It's the darn shutterView in the layout that's still visible / has a black color background

To change in XML add the following attribute to your PlayerView xml:

app:shutter_background_color="@color/transparent"

To remove the view entirely you can do:

((ViewGroup)shutterView.getParent()).removeView(shutterView);

Upvotes: 1

Azamat Mahkamov
Azamat Mahkamov

Reputation: 1090

Try this code on your onCreate() method:

 int resId = getResources().getIdentifier("exo_shutter", "id", getPackageName());
 findViewById(resId).setBackgroundColor(ContextCompat.getColor(this, R.color.transparent));

Upvotes: 0

John O&#39;Reilly
John O&#39;Reilly

Reputation: 10330

You can set show_timeout to 0 to avoid controls being hidden (also might want to set hide_on_touch to false as well)

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
           android:id="@+id/video_view"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           app:show_timeout="0"
           app:hide_on_touch="false"
           app:controller_layout_id="@layout/exo_playback_control_view" />

You can also define your own controller_layout_id layout which should give you all the control you need over background etc (can use default one as starting point).

Upvotes: 7

Related Questions