seekTo method

Future<void> seekTo(
  1. Duration position
)

seek the current video position

Implementation

Future<void> seekTo(Duration position) async {
  if (position >= duration.value) {
    position = duration.value - const Duration(milliseconds: 100);
  }
  if (position < Duration.zero) {
    position = Duration.zero;
  }
  _position.value = position;
  customDebugPrint(
      "position in seek function is ${_position.value.toString()}");
  customDebugPrint(
      "duration in seek function is ${duration.value.toString()}");

  if (duration.value.inSeconds != 0) {
    customDebugPrint(
        "video controller duration ${_videoPlayerController!.value.duration.toString()}");

    await _videoPlayerController?.seekTo(position);
    customDebugPrint("position after seek is ${_position.value.toString()}");

    // _checkIfSeekIsSuccess(position);

    // if (playerStatus.stopped) {
    //   play();
    // }
  } else {
    // _timerForReSeek(position);
  }
}