From beb473dc354b2f92c6e462079ab00619646ef121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Braz=CC=87ewicz?= Date: Mon, 4 Oct 2021 16:27:02 +0200 Subject: [PATCH] auto detect fullscreen aspect ratio --- lib/src/configuration/better_player_configuration.dart | 5 +++++ lib/src/core/better_player_with_controls.dart | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/configuration/better_player_configuration.dart b/lib/src/configuration/better_player_configuration.dart index a493f9a78..9da409272 100644 --- a/lib/src/configuration/better_player_configuration.dart +++ b/lib/src/configuration/better_player_configuration.dart @@ -100,6 +100,10 @@ class BetterPlayerConfiguration { /// ignored. final bool autoDetectFullscreenDeviceOrientation; + ///Defines if player should auto detect full screen aspect ration of the video. + ///If [deviceOrientationsOnFullScreen] is true this is done automaticaly also. + final bool autoDetectFullscreenAspectRatio; + ///Defines flag which enables/disables lifecycle handling (pause on app closed, ///play on app resumed). Default value is true. final bool handleLifecycle; @@ -153,6 +157,7 @@ class BetterPlayerConfiguration { this.playerVisibilityChangedBehavior, this.translations, this.autoDetectFullscreenDeviceOrientation = false, + this.autoDetectFullscreenAspectRatio = false, this.handleLifecycle = true, this.autoDispose = true, this.expandToFill = true, diff --git a/lib/src/core/better_player_with_controls.dart b/lib/src/core/better_player_with_controls.dart index 506cbb76f..2891daedc 100644 --- a/lib/src/core/better_player_with_controls.dart +++ b/lib/src/core/better_player_with_controls.dart @@ -82,8 +82,10 @@ class _BetterPlayerWithControlsState extends State { double? aspectRatio; if (betterPlayerController.isFullScreen) { - if (betterPlayerController - .betterPlayerConfiguration.autoDetectFullscreenDeviceOrientation) { + if (betterPlayerController.betterPlayerConfiguration + .autoDetectFullscreenDeviceOrientation || + betterPlayerController + .betterPlayerConfiguration.autoDetectFullscreenAspectRatio) { aspectRatio = betterPlayerController.videoPlayerController?.value.aspectRatio ?? 1.0;