pause method

Future<void> pause()

暂停

Implementation

Future<void> pause() async {
  if (_dispose) {
    return;
  }

  if (value.configuration.autoPlay) {
    // 可能还在初始化中, 需要关闭自动播放
    value = value.copyWith(configuration: value.configuration.copyWith(autoPlay: false));
  }

  if (videoPlayerValue?.isInitialized == true) {
    await value.videoPlayerController?.pause();

    value.playerEventStreamController.sink
        .add(BetterVideoPlayerEvent(value.playerKey, BetterVideoPlayerEventType.onPause));
  }
}