buildVideoPlayer method

Widget? buildVideoPlayer(
  1. BuildTree tree,
  2. String url, {
  3. required bool autoplay,
  4. required bool controls,
  5. double? height,
  6. required bool loop,
  7. String? posterUrl,
  8. double? width,
})
inherited

Builds VideoPlayer.

Implementation

Widget? buildVideoPlayer(
  BuildTree tree,
  String url, {
  required bool autoplay,
  required bool controls,
  double? height,
  required bool loop,
  String? posterUrl,
  double? width,
}) {
  final dimensOk = height != null && height > 0 && width != null && width > 0;
  final poster = posterUrl != null
      ? buildImage(tree, ImageMetadata(sources: [ImageSource(posterUrl)]))
      : null;
  return VideoPlayer(
    url,
    aspectRatio: dimensOk ? width / height : 16 / 9,
    autoResize: !dimensOk,
    autoplay: autoplay,
    controls: controls,
    errorBuilder: (context, _, error) =>
        onErrorBuilder(context, tree, error, url) ?? widget0,
    loadingBuilder: (context, _, child) =>
        onLoadingBuilder(context, tree, null, url) ?? widget0,
    loop: loop,
    poster: poster,
  );
}