Skip to content

Commit e867ad8

Browse files
committed
rewrite: Improved seeking experience when trying to go to invalid times
1 parent fa2c5b6 commit e867ad8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/core/services/video/video_service.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,13 @@ class VideoService {
167167
return true;
168168
}
169169

170-
bool seekTo(Duration newDuration) {
171-
if (newDuration > duration || newDuration < Duration.zero) return false;
172-
_player.seek(position: newDuration.inMilliseconds, flags: _seekFlags);
170+
bool seekTo(Duration newPosition) {
171+
if (newPosition > duration) {
172+
_player.seek(position: duration.inMilliseconds, flags: _seekFlags);
173+
} else if (newPosition < Duration.zero) {
174+
_player.seek(position: 0, flags: _seekFlags);
175+
}
176+
_player.seek(position: newPosition.inMilliseconds, flags: _seekFlags);
173177
return true;
174178
}
175179

0 commit comments

Comments
 (0)