OVERFLOW
OVERFLOW

Reputation: 181

How do I make the Exoplayer controls always visible?

A few seconds after the ExoPlayer starts playing, the controls stop showing and a black background appears. How do I make sure that the controls are always visible?

Upvotes: 17

Views: 16329

Answers (5)

Zain
Zain

Reputation: 40810

The other answers are correct to keep the player always visible (not hide automatically after a certain time):

// Programmatically
playerView.controllerShowTimeoutMs = 0
playerView.controllerHideOnTouch = false


// Equivalent XML
app:show_timeout="0"
app:hide_on_touch="false"

But, if those will not work for making it initially visible, for instance if the player is not already initialized/playing or in case you came back to the app after clearing it out from the recent apps while the player is still playing in background. In such cases the player controls will be hidden. To fix those cases you need to call showController()

playerView.showController()

Upvotes: 0

Isuru Bandara
Isuru Bandara

Reputation: 360

You can do it programmatically using these,

    PlayerView.setControllerShowTimeoutMs(0);
    PlayerView.setControllerHideOnTouch(false);

Upvotes: 4

Surendar D
Surendar D

Reputation: 5644

Just posting for someone how needs, Try this once.

Please add below 2 lines in the XML view.

 app:show_timeout="0"
 app:hide_on_touch="false"

Like full Example.

<com.google.android.exoplayer2.ui.PlayerView
        android:id="@+id/audio_view"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:isScrollContainer="false"
        app:controller_layout_id="@layout/exo_playback_control_view_audio"
        app:fastforward_increment="10000"
        app:show_timeout="0"
        app:hide_on_touch="false"
        app:resize_mode="fill"
        app:rewind_increment="10000"
        app:show_buffering="always" />

Upvotes: 3

ik024
ik024

Reputation: 3596

If you see the below method in SimpleExoPlayerView class, you need to provide negative value in order for the controls to visible always.

/**
* Sets the playback controls timeout. The playback controls are automatically hidden after this
* duration of time has elapsed without user input and with playback 
  or buffering in progress.
* @param controllerShowTimeoutMs The timeout in milliseconds. A non-
  positive value will cause the controller to remain visible indefinitely.
*/
public void setControllerShowTimeoutMs(int controllerShowTimeoutMs) {
       Assertions.checkState(controller != null);
       this.controllerShowTimeoutMs = controllerShowTimeoutMs;
}

Upvotes: 0

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

Reputation: 10330

Set show_timeout attribute to 0

Upvotes: 20

Related Questions