ExoPlayer修改播放器UI

旧项目中使用ExoPlayer来播放音乐,记录一下ExoPlayer修改播放器UI…

思路:原理比较简单,采用资源替换的方式。

荔枝:项目中采用com.google.android.exoplayer2.ui.PlayerControlView​默认的播放ui,修改的方式有两种

      1.全局替换,可以把把exoplayer中exo_player_control_view.xml复制过来改改

      2.单一替换,新建一个播放器layout,赋值给`PlayerControlView`​,例如:
<com.google.android.exoplayer2.ui.PlayerControlView
    android:id="@+id/player_control_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:controller_layout_id="@layout/my_player_controller"
    app:repeat_toggle_modes="all|none|one"
    app:show_shuffle_button="true"
    app:show_timeout="0" />

需要注意的是控件id要保持和exoplayer原本的一样,其中进度条可能有点坑,采用的是DefaultTimeBar(不是SeekBar),有些样式通过xml比较难实现,只能复制一个出来改代码。最后附上项目中的ui效果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/wangadping/article/details/128640792