loadVideo method

Future<void> loadVideo(
  1. String url
)

Loads the video with the given url.

The url must be a valid youtube video watch url. i.e. https://www.youtube.com/watch?v=VIDEO_ID

Implementation

Future<void> loadVideo(String url) {
  assert(
    RegExp(r'^https://(?:www\.|m\.)?youtube\.com/watch.*').hasMatch(url),
    'Only YouTube watch URLs are supported.',
  );

  final params = Uri.parse(url).queryParameters;
  final videoId = params['v'];

  assert(
    videoId != null && videoId.isNotEmpty,
    'Video ID is missing from the provided url.',
  );

  return loadVideoById(
    videoId: videoId!,
    startSeconds: double.tryParse(params['t'] ?? ''),
  );
}