Reputation: 2634
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:
Requirement:
How to keep SimpleExoPlayerView
background as transparent, instead of Black background [as still, I'm getting] (see above Screenshot)
How to keep SimpleExoPlayerView
always visible (as still it appears and then disappear, until I touch again)
Upvotes: 3
Views: 7248
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
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
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