Skip to content

Commit

Permalink
Merge pull request #501 from tneotia/fix/video-aspect-ratio
Browse files Browse the repository at this point in the history
Fix video aspect ratio black bars
  • Loading branch information
ryan-berger authored Jan 17, 2021
2 parents 4b0898f + 640fd02 commit 632e597
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 632e597

Please sign in to comment.