YoutubePlayerController.fromVideoId constructor

YoutubePlayerController.fromVideoId({
  1. required String videoId,
  2. YoutubePlayerParams params = const YoutubePlayerParams(),
  3. bool autoPlay = false,
  4. double? startSeconds,
  5. double? endSeconds,
})

Creates a YoutubePlayerController and initializes the player with videoId.

Implementation

factory YoutubePlayerController.fromVideoId({
  required String videoId,
  YoutubePlayerParams params = const YoutubePlayerParams(),
  bool autoPlay = false,
  double? startSeconds,
  double? endSeconds,
}) {
  final controller = YoutubePlayerController(params: params);

  if (autoPlay) {
    controller.loadVideoById(
      videoId: videoId,
      startSeconds: startSeconds,
      endSeconds: endSeconds,
    );
  } else {
    controller.cueVideoById(
      videoId: videoId,
      startSeconds: startSeconds,
      endSeconds: endSeconds,
    );
  }

  return controller;
}