我正在开发ExoPlayer,希望能够自定义ExoPlayer并监听下一个、上一个、快进、快退等事件,这样当用户点击“下一个”按钮时,将播放播放列表中的下一个视频,在使用“上一个”时,将播放播放列表中的上一个视频,以此类推。我正在使用自定义布局,它改变了设计但不能监听这些事件(下一个、上一个等)。以下是我的代码:-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="200dp"
app:resize_mode="fill"
app:controller_layout_id="@layout/custom_controls"
app:player_layout_id="@layout/custom_player_view"
app:surface_type="texture_view"/>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_marginTop="220dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
我已经在ConcatenatingMediaSource中添加了Mediasource列表。它能够工作,但我还需要改变布局,因此我需要一个ExoPlayer中每个控件的监听器。我看到了这个链接。所以我知道当用户点击ExoPlayer中的下一首、上一首、快退、快进按钮时,onPositionDiscontinuity()方法会被调用。但我需要每个按钮的监听器,以便我可以执行适当的操作?
谢谢