fix: resume

This commit is contained in:
edde746
2025-12-02 15:46:19 +01:00
parent ae4673bde7
commit 8a826f0035
2 changed files with 13 additions and 1 deletions
@@ -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');
+5 -1
View File
@@ -542,7 +542,11 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen>
// 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