ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

It is impossible to perform key-frame accurate initial (before prepare) seek

Open sruditsky opened this issue 3 years ago • 0 comments

Use case description

While playing an HLS stream it is possible to seekTo before the player is in Player.STATE_READY state and it is also possible to perform a key-frame accurate seeking (https://github.com/google/ExoPlayer/issues/2882).

However, it is not possible to perform a key-frame accurate seeking when the seekTo is called before the player is in Player.STATE_READY state.

The reason is that under such conditions ExoPlayerImplInternal.resolveSeekPositionUs is called when playingPeriodHolder.prepared is still false which means that seekParameters are ignored.

Proposed solution

The solution seems to be to repeat the resolveSeekPositionUs after playingPeriodHolder.prepared becomes equal true and video sample queue is created.

Alternatives considered

We are experimenting with repeating the seekTo in the app at the moment just after playlist is parsed. This somewhat works but because this involves several thread transitions (between the application and player threads) the results are not exactly perfect.

sruditsky avatar Jul 29 '22 14:07 sruditsky