customization - ExoPlayer - 是否可以通过编程方式更改 DefaultTimeBar 的颜色?

标签 customization exoplayer programmatically

我覆盖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/

相关文章:

android - 如何暂停 ExoPlayer 2 播放和恢复(PlayerControl 已删除)

android - 如何使用 Exoplayer 播放输入流?

android - 如何在 ExoPlayer 中显示图像?

android - 动态改变渐变中心

php - Drupal 8 - 以编程方式禁用或启用主导航上的链接

java - 如何在 Spring Security 3 的用户登录中添加一些自己的逻辑

javascript - 通过修改 Ryan Fait 的代码来设置多个单选按钮的样式

ios - 具有行展开和折叠选项的 TableView 的最佳方法

java - y 轴上的自定义百分比阈值,间距不均匀

android - ConstraintLayout 以编程方式加权链