seekTo method

Future<void> seekTo(
  1. int seconds
)

Moves the playback position to the given position in seconds.

NOTE: This method might throw an exception if the video cannot be seeked.

Implementation

Future<void> seekTo(int seconds) async {
  var position = seconds;
  if (seconds < 0) position = 0;
  final duration = videoInfo?.duration ?? 0;
  if (seconds > duration) position = duration;
  await _api.seekTo(position);
  // if the video is not playing, update onPlaybackPositionChanged
  if (_playbackStatus != PlaybackStatus.playing) {
    onPlaybackPositionChanged.value = position;
  }
}