How to hide control buttons in ExoPlayer2

Nurlan Kanimetov picture Nurlan Kanimetov · Feb 16, 2017 · Viewed 27.2k times · Source

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

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

But it deactivate 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 delete these components?

Answer

Junsu Lee picture Junsu Lee · Mar 8, 2017

ExoPlayer-r2.2.0 used

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

or

app:use_controller="false" in 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"/>