diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index d2622405e..84fedd3aa 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) { android { namespace "com.example.example" - compileSdk 34 + compileSdk 35 compileOptions { sourceCompatibility JavaVersion.VERSION_17 diff --git a/example/lib/app/app.dart b/example/lib/app/app.dart index 6d58f29f6..a9cb2014a 100644 --- a/example/lib/app/app.dart +++ b/example/lib/app/app.dart @@ -110,6 +110,7 @@ class _ChewieDemoState extends State { _chewieController = ChewieController( videoPlayerController: _videoPlayerController1, autoPlay: true, + zoomAndPan: true, looping: true, progressIndicatorDelay: bufferDelay != null ? Duration(milliseconds: bufferDelay!) : null, diff --git a/lib/src/chewie_player.dart b/lib/src/chewie_player.dart index 5d76fdf6d..b118caf5f 100644 --- a/lib/src/chewie_player.dart +++ b/lib/src/chewie_player.dart @@ -383,6 +383,12 @@ class ChewieController extends ChangeNotifier { cupertinoProgressColors ?? this.cupertinoProgressColors, materialProgressColors: materialProgressColors ?? this.materialProgressColors, + zoomAndPan: zoomAndPan ?? this.zoomAndPan, + maxScale: maxScale ?? this.maxScale, + controlsSafeAreaMinimum: + controlsSafeAreaMinimum ?? this.controlsSafeAreaMinimum, + transformationController: + transformationController ?? this.transformationController, materialSeekButtonFadeDuration: materialSeekButtonFadeDuration ?? this.materialSeekButtonFadeDuration, materialSeekButtonSize: diff --git a/lib/src/player_with_controls.dart b/lib/src/player_with_controls.dart index 65d51a69b..d67e21f95 100644 --- a/lib/src/player_with_controls.dart +++ b/lib/src/player_with_controls.dart @@ -33,53 +33,61 @@ class PlayerWithControls extends StatelessWidget { ChewieController chewieController, BuildContext context, ) { - return Stack( - children: [ - if (chewieController.placeholder != null) - chewieController.placeholder!, - InteractiveViewer( - transformationController: chewieController.transformationController, - maxScale: chewieController.maxScale, - panEnabled: chewieController.zoomAndPan, - scaleEnabled: chewieController.zoomAndPan, - child: Center( + final playerNotifier = + Provider.of(context, listen: false); + return InteractiveViewer( + transformationController: chewieController.transformationController, + maxScale: chewieController.maxScale, + panEnabled: chewieController.zoomAndPan, + scaleEnabled: chewieController.zoomAndPan, + onInteractionUpdate: chewieController.zoomAndPan + ? (_) => playerNotifier.hideStuff = true + : null, + onInteractionEnd: chewieController.zoomAndPan + ? (_) => playerNotifier.hideStuff = false + : null, + child: Stack( + children: [ + if (chewieController.placeholder != null) + chewieController.placeholder!, + Center( child: AspectRatio( aspectRatio: chewieController.aspectRatio ?? chewieController.videoPlayerController.value.aspectRatio, child: VideoPlayer(chewieController.videoPlayerController), ), ), - ), - if (chewieController.overlay != null) chewieController.overlay!, - if (Theme.of(context).platform != TargetPlatform.iOS) - Consumer( - builder: ( - BuildContext context, - PlayerNotifier notifier, - Widget? widget, - ) => - Visibility( - visible: !notifier.hideStuff, - child: AnimatedOpacity( - opacity: notifier.hideStuff ? 0.0 : 0.8, - duration: const Duration( - milliseconds: 250, - ), - child: const DecoratedBox( - decoration: BoxDecoration(color: Colors.black54), - child: SizedBox.expand(), + if (chewieController.overlay != null) chewieController.overlay!, + if (Theme.of(context).platform != TargetPlatform.iOS) + Consumer( + builder: ( + BuildContext context, + PlayerNotifier notifier, + Widget? widget, + ) => + Visibility( + visible: !notifier.hideStuff, + child: AnimatedOpacity( + opacity: notifier.hideStuff ? 0.0 : 0.8, + duration: const Duration( + milliseconds: 250, + ), + child: const DecoratedBox( + decoration: BoxDecoration(color: Colors.black54), + child: SizedBox.expand(), + ), ), ), ), - ), - if (!chewieController.isFullScreen) - buildControls(context, chewieController) - else - SafeArea( - bottom: false, - child: buildControls(context, chewieController), - ), - ], + if (!chewieController.isFullScreen) + buildControls(context, chewieController) + else + SafeArea( + bottom: false, + child: buildControls(context, chewieController), + ), + ], + ), ); }