如何隐藏ExoPlayer2中的控制按钮

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

我看了一下,里面有simpleExoPlayerView.setUseController(true)方法;

但它会关闭播放器…

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

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

使用ExoPlayer-r2.2.0

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

要么

布局中的app:use_controller =“false”

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

为了解决这个问题,我做了这个:

代码在Kotlin

 simpleExoPlayerView.setControllerVisibilityListener { visibility -> val layout = activity.findViewById<LinearLayout>(R.id.ll_customPlayBackControlView) if (layout.tag != "IN_ANIMATION") { when (visibility) { View.GONE -> { layout.tag = "IN_ANIMATION" ex_fragmentVideoView.showController() layout.animate().alpha(0F).setDuration(450L).withEndAction({ ex_fragmentVideoView.hideController(); layout.tag = "" }).start() } View.VISIBLE -> { layout.animate().alpha(1F).setDuration(450L).start() } } } } 
 controller.setVisibility(View.GONE); controller.setVisibility(View.INVISIBLE); 

使用其中任何一个来设置visibilty。 Android文档: 链接