如何在Exoplayer中为下一个,上一个,后退和前进添加侦听器

Pan*_*egi 5 controls android listener exoplayer

我正在使用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">
Run Code Online (Sandbox Code Playgroud)

我在ConcatenatingMediaSource中添加了Mediasource列表。它正在工作,但我也要更改布局,这就是为什么我需要ExoPlayer中每个控件的侦听器的原因。我看到这个 链接。因此,我知道每次用户单击ExoPlayer中的下一个,上一个,快退,前进按钮时,都会调用onPositionDiscontinuity()方法,但是我希望每个按钮都具有侦听器,以便执行适当的操作?

谢谢

Pan*_*egi 3

我使用此链接来自定义 ExoPlayer 的上一个、下一个等。您可以实现自己的逻辑来跟踪所有这些事件。这个对我有用。