seekTo method
Move player to specific position/moment of the video.
Implementation
Future<void> seekTo(Duration moment) async {
if (videoPlayerController == null) {
throw StateError("The data source has not been initialized");
}
if (videoPlayerController?.value.duration == null) {
throw StateError("The video has not been initialized yet.");
}
await videoPlayerController!.seekTo(moment);
_postEvent(PipFlutterPlayerEvent(PipFlutterPlayerEventType.seekTo,
parameters: <String, dynamic>{_durationParameter: moment}));
final Duration? currentDuration = videoPlayerController!.value.duration;
if (currentDuration == null) {
return;
}
if (moment > currentDuration) {
_postEvent(PipFlutterPlayerEvent(PipFlutterPlayerEventType.finished));
} else {
cancelNextVideoTimer();
}
}