如何使 Exoplayer 控件始终可见?
How do I make the Exoplayer controls always visible?
ExoPlayer 开始播放几秒钟后,控件停止显示并出现黑色背景。如何确保控件始终可见?
将 show_timeout
属性设置为 0
如果您在 SimpleExoPlayerView
class 中看到以下方法,您需要提供负值以使控件始终可见。
/**
* 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;
}
只是为有需要的人发帖,试试这个。
请在 XML 视图中添加以下 2 行。
app:show_timeout="0"
app:hide_on_touch="false"
喜欢完整的例子。
<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" />
您可以使用这些以编程方式完成,
PlayerView.setControllerShowTimeoutMs(0);
PlayerView.setControllerHideOnTouch(false);
ExoPlayer 开始播放几秒钟后,控件停止显示并出现黑色背景。如何确保控件始终可见?
将 show_timeout
属性设置为 0
如果您在 SimpleExoPlayerView
class 中看到以下方法,您需要提供负值以使控件始终可见。
/**
* 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;
}
只是为有需要的人发帖,试试这个。
请在 XML 视图中添加以下 2 行。
app:show_timeout="0"
app:hide_on_touch="false"
喜欢完整的例子。
<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" />
您可以使用这些以编程方式完成,
PlayerView.setControllerShowTimeoutMs(0);
PlayerView.setControllerHideOnTouch(false);