playButtonCallback method

Future<void> playButtonCallback()

Callback for the play button. 播放按钮的回调

Normally it only switches play state for the player. If the video reaches the end, then click the button will make the video replay. 一般来说按钮只切换播放暂停。当视频播放结束时,点击按钮将从头开始播放。

Implementation

Future<void> playButtonCallback() async {
  try {
    if (isPlaying.value) {
      videoController.pause();
    } else {
      if (videoController.value.duration == videoController.value.position) {
        videoController
          ..seekTo(Duration.zero)
          ..play();
      } else {
        videoController.play();
      }
    }
  } catch (e, s) {
    handleErrorWithHandler(e, onError, s: s);
  }
}