【问题标题】:How do I make the Exoplayer controls always visible?如何使 Exoplayer 控件始终可见?
【发布时间】:2018-05-02 23:58:24
【问题描述】:

ExoPlayer 开始播放几秒钟后,控件停止显示并出现黑色背景。如何确保控件始终可见?

【问题讨论】:

    标签: android exoplayer


    【解决方案1】:

    show_timeout属性设置为0

    【讨论】:

    • 一碰玩家,它会隐藏控制器,mPlayerView.setControllerHideOnTouch(false)用户这个防止控制器隐藏
    • xml 等效项或Player.setControllerHideOnTouch(false)app:hide_on_touch="false"
    【解决方案2】:

    您可以使用这些以编程方式完成,

        PlayerView.setControllerShowTimeoutMs(0);
        PlayerView.setControllerHideOnTouch(false);
    

    【讨论】:

      【解决方案3】:

      只是为需要的人发帖,试试这个。

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

      【讨论】:

        【解决方案4】:

        如果您在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;
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-11-11
          • 2021-04-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-02-01
          • 1970-01-01
          相关资源
          最近更新 更多