【问题标题】:ExoPlayer - Is possible programmatically change the color of the DefaultTimeBar?ExoPlayer - 是否可以以编程方式更改 DefaultTimeBar 的颜色?
【发布时间】:2018-06-12 02:13:41
【问题描述】:

我覆盖 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 的颜色?

【问题讨论】:

标签: customization exoplayer programmatically


【解决方案1】:

使用以下方法获取时间栏参考:

 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))

【讨论】:

    猜你喜欢
    • 2012-07-07
    • 2015-12-06
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-21
    相关资源
    最近更新 更多