buildVideoPlayer method
Widget?
buildVideoPlayer(
- BuildTree tree,
- String url, {
- required bool autoplay,
- required bool controls,
- double? height,
- required bool loop,
- String? posterUrl,
- 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,
);
}