Skip to content

Commit

Permalink
Fix video aspect ratio (huge black bars on top and bottom of video el…
Browse files Browse the repository at this point in the history
…ements)
  • Loading branch information
tneotia committed Jan 16, 2021
1 parent 4b0898f commit 640fd02
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/src/replaced_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,23 @@ class VideoContentElement extends ReplacedElement {
Widget toWidget(RenderContext context) {
final double _width = width ?? (height ?? 150) * 2;
final double _height = height ?? (width ?? 300) / 2;
return Container(
child: Chewie(
controller: ChewieController(
videoPlayerController: VideoPlayerController.network(
src.first ?? "",
return AspectRatio(
aspectRatio: _width / _height,
child: Container(
child: Chewie(
controller: ChewieController(
videoPlayerController: VideoPlayerController.network(
src.first ?? "",
),
placeholder: poster != null
? Image.network(poster)
: Container(color: Colors.black),
autoPlay: autoplay,
looping: loop,
showControls: showControls,
autoInitialize: true,
aspectRatio: _width / _height,
),
placeholder: poster != null
? Image.network(poster)
: Container(color: Colors.black),
autoPlay: autoplay,
looping: loop,
showControls: showControls,
autoInitialize: true,
aspectRatio: _width / _height,
),
),
);
Expand Down

0 comments on commit 640fd02

Please sign in to comment.