Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play a particular video from ExoPlayer playlist android?

I'm using ExoPlayer to play a list of videos as playlist:

    MediaSource[] mediaSources = new MediaSource[mList.size()];
    for (int i = 0; i < mList.size(); i++) {
        mediaSources[i] = buildMediaSource(Uri.parse(mList.get(i));
    }

    MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
            : new ConcatenatingMediaSource(mediaSources);

    mExoPlayer.prepare(mediaSource);

Its working fine. But as per requirement I have to play a video in a particular position from the list when click. How can I achieve this?

Thanks!

like image 246
nadietp Avatar asked Aug 16 '17 08:08

nadietp


1 Answers

You may want to use seekTo(windowIndex, positionMs).

player.prepare(mediaSource);
player.seek(3, C.TIME_UNSET);
player.setPlayWhenReady(true);
like image 74
marcbaechinger Avatar answered Oct 01 '22 14:10

marcbaechinger