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?
Set show_timeout
attribute to 0
Player.setControllerHideOnTouch(false)
is app:hide_on_touch="false"
–
Mccormac You can do it programmatically using these,
PlayerView.setControllerShowTimeoutMs(0);
PlayerView.setControllerHideOnTouch(false);
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" />
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;
}
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()
© 2022 - 2024 — McMap. All rights reserved.
mPlayerView.setControllerHideOnTouch(false)
user this to prevent controller to hide – Tacitus