play method

Future<void> play()

Start video playback. Play will be triggered only if current lifecycle state is resumed.

Implementation

Future<void> play() async {
  if (videoPlayerController == null) {
    throw StateError("The data source has not been initialized");
  }

  if (_appLifecycleState == AppLifecycleState.resumed) {
    await videoPlayerController!.play();
    _hasCurrentDataSourceStarted = true;
    _wasPlayingBeforePause = null;
    _postEvent(BetterPlayerEvent(BetterPlayerEventType.play));
    _postControllerEvent(BetterPlayerControllerEvent.play);
  }
}