如何在ExoPlayer2中隐藏控制按钮

2022-09-01 02:14:23

如何在ExoPlayer2中隐藏所有控制器(开始按钮,暂停等),它们不存在并且屏幕总是满的。

我看了看,有方法;simpleExoPlayerView.setUseController(true)

但它会停用播放器...

public void setUseController (boolean useController) {
    this.useController = useController;
if (useController) {
      controller.setPlayer(player);
    } else {
      controller.hide();
      controller.setPlayer(null);
    }
}

如何隐藏或删除这些组件?


答案 1

使用ExoPlayer-r2.2.0

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

应用:use_controller=布局中的“假”

<...
    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"/>

答案 2

只需使用这个

exoPlayerView.setUseController(false);

推荐