我覆盖exoplayer的exo_playback_control_view.xml来自定义它,如下面的代码所示。 (exoplayer 版本 2.6.1)
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@id/exo_progress"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="26dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
app:buffered_color="#534b20"
app:played_color="#ffca28"
app:unplayed_color="#515151"
app:scrubber_drawable="@drawable/vod_seek_circle_thumb"
app:bar_height="@dimen/vod_playback_seekbar_line_size"/>
我只想在某些情况下对 buffered_color 和 unplayed_color 使用相同的颜色。 ex) 播放下载的视频
有没有办法以编程方式更改 unplayed_color 的颜色?
最佳答案
使用以下方法获取时间栏引用:
timeBar = simpleExoplayerView.findViewById(R.id.exo_progress)
然后,你可以使用这个:
timeBar?.setBackgroundColor(requireContext().getColor(R.color.white))
timeBar?.setScrubberColor(requireContext().getColor(R.color.white))
timeBar?.setPlayedColor(requireContext().getColor(R.color.white))
timeBar?.setUnplayedColor(requireContext().getColor(R.color.transparent))
timeBar?.setBufferedColor(requireContext().getColor(R.color.transparent))
关于customization - ExoPlayer - 是否可以通过编程方式更改 DefaultTimeBar 的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50808356/