我设法为我的exoplayer创建了一个自定义控制器。在此布局中,我放置了一些我希望能够控制的按钮和一些其他元素(添加一些事件,更改文本等)。我必须上什么课?如何将控制器与自定义逻辑“链接”?这是我到目前为止所做的:
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/player"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:show_buffering="when_playing"
app:controller_layout_id="@layout/customController"/>
在customController.xml中,我有类似这样的内容:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="100dp"
android:layout_gravity="bottom"
android:orientation="vertical">
<TextView
android:id="@+id/fileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change me!"/>
谢谢!
您应该将自定义布局按钮ID更改为exo播放器使用的默认ID。然后以编程方式设置自定义布局。然后它将起作用。