Slow to seek for HLS videos?

Viewed 204

I use HLS videos with ExoPlayer. Segments are broken down into 6 seconds each. I'm not sure if this is a problem with my implementation of HLS or if it's an issue with ExoPlayer.

My app has a feed of videos (in a RecyclerView). I've set it up such that when a video stops, it saves the position in a map and the player gets detached. However, if the user scrolls back up to view that same video, when I call exoPlayer.seekTo(position), it usually takes a second or two for the video to start playing again from the saved position.

What can I do to make sure that the video plays instantly? Would caching each video solve my problem here?

Thanks!

1 Answers

A couple of seconds to start up a video at a position in the middle is actually quite quick.

The player has to get the video header data, find the nearest place it can start decoding the video, e.g. an I frame, and then decode enough frames to start displaying.

One way to achieve something faster than this is to try to predict the videos a use may go to next and have them preloaded in a separate instance of a player. For example, you might have the last and the next video in the series pre-loaded if the user swipes from one video to another.

Related