How do I set duration of a video in ExoPlayer?

509 Views Asked by At

I need to set duration of a video for a thumbnail to 5 seconds and loop it. I got the loop part, but I can't find documentation for setting specific duration

I tried exoPlayer.seek(duration) but that didn't work

1

There are 1 best solutions below

0
On

You may use ClippingMediaSource:

ClippingMediaSource​(MediaSource mediaSource, long startPositionUs, long endPositionUs)

Creates a new clipping source that wraps the specified source and provides samples between the specified start and end position.

You can convert to have a new media source and set this new media source for your ExoPlayer:

// Create a new media source with your specified period
val newMediaSource = ClippingMediaSource(mediaSource, 0, 5_000_000)