play method

Future<void> play()

播放

Implementation

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

  if (videoPlayerValue?.isInitialized == true) {
    if (videoPlayerValue?.isPlaying ?? false) {
      return;
    }

    // 开始播放
    await value.videoPlayerController?.play();

    if (_dispose) {
      return;
    }

    // 发送开始播放事件
    _playerEventStreamController.sink.add(BetterVideoPlayerEvent(value.playerKey, BetterVideoPlayerEventType.onPlay));

    if (value.wifiInterrupted) {
      // 去掉 Wifi 中断提醒
      value = value.copyWith(wifiInterrupted: false);
      _connectivitySubscription?.cancel();
    }
  }
}