From c88e93d11ef9701e0627c974bf9f29da9e483685 Mon Sep 17 00:00:00 2001 From: Crazy Date: Tue, 27 Apr 2021 23:50:47 +0800 Subject: [PATCH 1/2] Fix the problem that the background image is revealed in the full screen --- lib/src/player_with_controls.dart | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/src/player_with_controls.dart b/lib/src/player_with_controls.dart index 88d4cb0de..bf0b050bf 100644 --- a/lib/src/player_with_controls.dart +++ b/lib/src/player_with_controls.dart @@ -41,7 +41,7 @@ class PlayerWithControls extends StatelessWidget { ChewieController chewieController, BuildContext context) { return Stack( children: [ - chewieController.placeholder ?? Container(), + _buildPlaceholder(chewieController, context) ?? Container(), Center( child: AspectRatio( aspectRatio: chewieController.aspectRatio ?? @@ -71,4 +71,21 @@ class PlayerWithControls extends StatelessWidget { ), ); } + + Widget? _buildPlaceholder( + ChewieController chewieController, BuildContext context) { + if (chewieController.placeholder == null) return null; + const aspectRatio = 16 / 9; + final size = MediaQuery.of(context).size; + double width; + if (size.width < size.height) { + return chewieController.placeholder; + } + width = size.height * aspectRatio; + + return Positioned.fill( + left: (size.width - width) / 2, + right: (size.width - width) / 2, + child: chewieController.placeholder!); + } } From 21d02e1bd123636258b813eedd5f3e8087a20160 Mon Sep 17 00:00:00 2001 From: "Devio.org" Date: Tue, 31 May 2022 22:44:57 +0800 Subject: [PATCH 2/2] Update player_with_controls.dart Get video aspectRatio --- lib/src/player_with_controls.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/player_with_controls.dart b/lib/src/player_with_controls.dart index bf0b050bf..e885605e3 100644 --- a/lib/src/player_with_controls.dart +++ b/lib/src/player_with_controls.dart @@ -75,7 +75,7 @@ class PlayerWithControls extends StatelessWidget { Widget? _buildPlaceholder( ChewieController chewieController, BuildContext context) { if (chewieController.placeholder == null) return null; - const aspectRatio = 16 / 9; + const aspectRatio = chewieController.videoPlayerController.value.aspectRatio; final size = MediaQuery.of(context).size; double width; if (size.width < size.height) {