buildVideoPlayer method

Widget buildVideoPlayer (
  1. BuildMetadata meta,
  2. String url,
  3. {bool autoplay,
  4. bool controls,
  5. double height,
  6. bool loop,
  7. String posterUrl,
  8. double width}
)

Builds VideoPlayer.

Implementation

Widget buildVideoPlayer(
  BuildMetadata meta,
  String url, {
  bool autoplay,
  bool controls,
  double height,
  bool loop,
  String posterUrl,
  double width,
}) {
  final dimensOk = height != null && height > 0 && width != null && width > 0;
  final posterImgSrc = posterUrl != null ? ImageSource(posterUrl) : null;
  return VideoPlayer(
    url,
    aspectRatio: dimensOk ? width / height : 16 / 9,
    autoResize: !dimensOk,
    autoplay: autoplay,
    controls: controls,
    loop: loop,
    poster: posterImgSrc != null
        ? buildImage(
            meta,
            imageProvider(posterImgSrc),
            ImageMetadata(sources: [posterImgSrc]),
          )
        : null,
  );
}