File tree Expand file tree Collapse file tree
app/src/main/java/com/lagradost/cloudstream3/ui/player Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1430,6 +1430,23 @@ class CS3IPlayer : IPlayer {
14301430 event(PlayerAttachedEvent (exoPlayer))
14311431 exoPlayer?.prepare()
14321432
1433+ // For offline fragmented MP4s, FLAG_MERGE_FRAGMENTED_SIDX builds the SIDX seek map
1434+ // incrementally as data is buffered. The initial seek resolves to the nearest merged
1435+ // entry (~first fragment, 3 s). On STATE_READY, re-seek to the actual saved position.
1436+ // This may only be reproducible on large and fairly long fragmented MP4 files with
1437+ // multiple sidx boxes.
1438+ if (onlineSource == null && playbackPosition > (exoPlayer?.duration ? : 0L )) {
1439+ exoPlayer?.addListener(object : Player .Listener {
1440+ private var seekApplied = false
1441+ override fun onPlaybackStateChanged (playbackState : Int ) {
1442+ if (seekApplied || playbackState != Player .STATE_READY ) return
1443+ seekApplied = true
1444+ exoPlayer?.seekTo(currentWindow, playbackPosition)
1445+ exoPlayer?.removeListener(this )
1446+ }
1447+ })
1448+ }
1449+
14331450 exoPlayer?.let { exo ->
14341451 event(StatusEvent (CSPlayerLoading .IsBuffering , CSPlayerLoading .IsBuffering ))
14351452 isPlaying = exo.isPlaying
You can’t perform that action at this time.
0 commit comments