diff --git a/lib/mpv/src/player/mpv_player_native.dart b/lib/mpv/src/player/mpv_player_native.dart index 3707ec1f..1c459a40 100644 --- a/lib/mpv/src/player/mpv_player_native.dart +++ b/lib/mpv/src/player/mpv_player_native.dart @@ -317,6 +317,14 @@ class MpvPlayerNative implements MpvPlayer { await _methodChannel.invokeMethod('setVisible', {'visible': true}); _isVisible = true; + // Set start position if provided (must be set before loading file) + if (media.start != null && media.start!.inSeconds > 0) { + await setProperty('start', media.start!.inSeconds.toString()); + } else { + // Reset start position if not resuming + await setProperty('start', 'none'); + } + await command(['loadfile', media.uri, 'replace']); if (!play) { await setProperty('pause', 'yes'); diff --git a/lib/screens/video_player_screen.dart b/lib/screens/video_player_screen.dart index 6b14df58..aaf9cc59 100644 --- a/lib/screens/video_player_screen.dart +++ b/lib/screens/video_player_screen.dart @@ -542,7 +542,11 @@ class VideoPlayerScreenState extends State // Open video through MpvPlayer if (result.videoUrl != null) { - await player!.open(MpvMedia(result.videoUrl!)); + // Pass resume position if available + final resumePosition = widget.metadata.viewOffset != null + ? Duration(milliseconds: widget.metadata.viewOffset!) + : null; + await player!.open(MpvMedia(result.videoUrl!, start: resumePosition)); } // Update available versions from the playback data