How to hide control buttons in ExoPlayer2

How to hide all controllers in ExoPlayer2 (start button, pause, etc.) that they did not exist, and the screen was always full.

I looked, there is a simpleExoPlayerView.setUseController(true) method;

But he deactivates the player ...

 public void setUseController (boolean useController) {    this.useController = useController; if (useController) { controller.setPlayer(player); } else { controller.hide(); controller.setPlayer(null); } } 

How to hide or remove these components?

+6
source share
5 answers

Used by ExoPlayer-r2.2.0

 videoView.hideController(); videoView.setControllerVisibilityListener(new PlaybackControlView.VisibilityListener() { @Override public void onVisibilityChange(int i) { if(i == 0) { videoView.hideController(); } } }); 

or

app: use_controller = "false" in the layout

 <... xmlns:app="http://schemas.android.com/apk/res-auto" ...> <com.google.android.exoplayer2.ui.SimpleExoPlayerView android:layout_width="match_parent" android:layout_height="match_parent" app:use_controller="false"/> 
+16
source

To solve this problem, I did the following:

Code in Kotlin

 simpleExoPlayerView.setControllerVisibilityListener { visibility -> val layout = activity.findViewById<LinearLayout>(R.id.ll_customPlayBackControlView) if (layout.tag != "IN_ANIMATION") { when (visibility) { View.GONE -> { layout.tag = "IN_ANIMATION" ex_fragmentVideoView.showController() layout.animate().alpha(0F).setDuration(450L).withEndAction({ ex_fragmentVideoView.hideController(); layout.tag = "" }).start() } View.VISIBLE -> { layout.animate().alpha(1F).setDuration(450L).start() } } } } 
+2
source
 controller.setVisibility(View.GONE); controller.setVisibility(View.INVISIBLE); 

Use any of these to install visibilty. Android Documentation: Link

+1
source
 exoPlayerView.setUseController(false); 
0
source

Just use it

 exoPlayerView.setUseController(false); 
0
source

Source: https://habr.com/ru/post/1015017/


All Articles