diff --git a/lib/src/player_with_controls.dart b/lib/src/player_with_controls.dart index f3c0120a7..84132018f 100644 --- a/lib/src/player_with_controls.dart +++ b/lib/src/player_with_controls.dart @@ -36,7 +36,7 @@ class PlayerWithControls extends StatelessWidget { return Stack( children: [ if (chewieController.placeholder != null) - chewieController.placeholder!, + _buildPlaceholder(chewieController, context) ?? Container(), InteractiveViewer( maxScale: chewieController.maxScale, panEnabled: chewieController.zoomAndPan, @@ -93,4 +93,21 @@ class PlayerWithControls extends StatelessWidget { ), ); } + + Widget? _buildPlaceholder( + ChewieController chewieController, BuildContext context) { + if (chewieController.placeholder == null) return null; + const aspectRatio = chewieController.videoPlayerController.value.aspectRatio; + 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!); + } }