3

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

<com.google.android.exoplayer2.ui.SimpleExoPlayerView
  android:id="@+id/video_view"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" />

结果:

在此处输入图像描述

要求:

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

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

4

3 回答 3

7

您可以设置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" />

您还可以定义自己的controller_layout_id布局,它应该为您提供对背景等所需的所有控制(可以使用默认布局作为起点)。

于 2018-01-26T15:35:49.000 回答
1

关于这个问题的“保持背景透明”方面,您可能将控件背景的背景设置为透明,但在播放控件视图上仍然看到黑色背景。

原因是......不是你的控件背景是黑色的。

这是布局中仍然可见/具有黑色背景的该死的快门视图

要更改 XML,请将以下属性添加到 PlayerView xml:

app:shutter_background_color="@color/transparent"

要完全删除视图,您可以执行以下操作:

((ViewGroup)shutterView.getParent()).removeView(shutterView);
于 2019-03-23T18:00:35.733 回答
0

在您的 onCreate() 方法上尝试此代码:

 int resId = getResources().getIdentifier("exo_shutter", "id", getPackageName());
 findViewById(resId).setBackgroundColor(ContextCompat.getColor(this, R.color.transparent));
于 2019-02-11T12:28:56.487 回答