java 如何在 ExoPlayer2 中隐藏控制按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42263371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 06:29:34  来源:igfitidea点击:

How to hide control buttons in ExoPlayer2

javaandroidexoplayerexoplayer2.x

提问by Nurlan Kanimetov

How to hide all controllers in ExoPlayer2 (start button, pause, and so on) that they did not exist, and the screen was always full.

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

I looked, there is simpleExoPlayerView.setUseController(true)method;

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

But it deactivate the player ...

但它停用了播放器...

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

How to hide or delete these components?

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

回答by Junsu Lee

ExoPlayer-r2.2.0 used

ExoPlayer-r2.2.0 使用

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

or

或者

app:use_controller="false" in Layout

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

回答by karthik kolanji

Simply use this

简单地使用这个

exoPlayerView.setUseController(false);

回答by rsc

exoPlayerView.setUseController(false);

回答by Westy92

Kotlin:

科特林:

exoPlayerView.useController = false

Java:

爪哇:

exoPlayerView.setUseController(false);

回答by MarceloSouza

To solve this problem I did this:

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

Code in Kotlin

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()
                }
            }
        }
    }

回答by linkaipeng

PlayerView has a hideController method. you can call it like this:

PlayerView 有一个 hideController 方法。你可以这样称呼它:

mPlayerView.hideController();

mPlayerView.hideController();

回答by Dharan Aditya

controller.setVisibility(View.GONE);
controller.setVisibility(View.INVISIBLE); 

Use either of those to set visibilty. Android Documentation : Link

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