【发布时间】:2018-05-02 23:58:24
【问题描述】:
ExoPlayer 开始播放几秒钟后,控件停止显示并出现黑色背景。如何确保控件始终可见?
【问题讨论】:
ExoPlayer 开始播放几秒钟后,控件停止显示并出现黑色背景。如何确保控件始终可见?
【问题讨论】:
将show_timeout属性设置为0
【讨论】:
mPlayerView.setControllerHideOnTouch(false)用户这个防止控制器隐藏
Player.setControllerHideOnTouch(false) 是app:hide_on_touch="false"
您可以使用这些以编程方式完成,
PlayerView.setControllerShowTimeoutMs(0);
PlayerView.setControllerHideOnTouch(false);
【讨论】:
只是为需要的人发帖,试试这个。
请在 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" />
【讨论】:
如果您在SimpleExoPlayerView 类中看到以下方法,则需要提供负值以使控件始终可见。
/**
* 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;
}
【讨论】: