如何在Exoplayer中为下一个,上一个,后退和前进添加侦听器 [英] How to add Listener for next , previous , rewind and forward in Exoplayer

查看:243
本文介绍了如何在Exoplayer中为下一个,上一个,后退和前进添加侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ExoPlayer,我想自定义ExoPlayer并监听下一个,上一个,后退,前进的事件,以便当用户单击下一个按钮时,将播放播放列表中的下一个视频,而当使用上一个时,则使用上一个播放列表中的视频将被播放,依此类推.我正在使用自定义布局,它会更改设计,但不会监听这些事件(下一个,上一个等).这是我的代码:-

I am working on ExoPlayer, I want to customize the ExoPlayer and listen for the Event next, previous, rewind, forward so that when the user clicks the next button next video in the Playlist will be playing and when using previous the previous video in the playlist will be playing and so on. I am using the Custom Layout, it changes the design but not listen for these events(next, previous etc). here is my code:-

<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()方法,但是我希望每个按钮都具有侦听器,以便执行适当的操作?

I have added the list of Mediasource in ConcatenatingMediaSource. It is working but I am to change the layout also, that why I need a listener for every control in ExoPlayer. I see this link. So I know onPositionDiscontinuity() method calls every time when the user clicks on next, previous, rewind, forward button in ExoPlayer But I want listener for each button so I can perform the appropriate action??

谢谢

推荐答案

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

I use this link to customize the ExoPlayer for previous, next etc. You can implement your own logic to track all of these Events. It works for me.

这篇关于如何在Exoplayer中为下一个,上一个,后退和前进添加侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆