SimpleExoPlayerView自定义可保持背景透明和控件始终可见

Sop*_*hie 2 android android-layout exoplayer exoplayer2.x

我正在ExoPlayer播放音频歌曲,这是我的SimpleExoPlayerView样子:

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
  android:id="@+id/video_view"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

结果:

在此处输入图片说明

需求:

  1. 如何保持SimpleExoPlayerView背景透明,而不是黑色背景 [仍然,我得到](请参见上面的屏幕截图

  2. 如何保持SimpleExoPlayerView始终可见(它仍然出现然后消失,直到我再次触摸)

Joh*_*lly 5

您可以设置show_timeout为0,以避免控制被隐藏(也可能需要设置hide_on_touch为false以及)

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
           android:id="@+id/video_view"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           app:show_timeout="0"
           app:hide_on_touch="false"
           app:controller_layout_id="@layout/exo_playback_control_view" />
Run Code Online (Sandbox Code Playgroud)

您也可以定义自己的controller_layout_id布局,应该给你所有你需要在后台等(可以使用默认的一个作为起点)的控制。