Переглянути джерело

Add option for overlays and orientations after fullscreen

Ben Hagen 6 роки тому
батько
коміт
0da5582560
1 змінених файлів з 17 додано та 7 видалено
  1. 17 7
      lib/src/chewie_player.dart

+ 17 - 7
lib/src/chewie_player.dart

@@ -125,13 +125,10 @@ class ChewieState extends State<Chewie> {
       Screen.keepOn(false);
     }
 
-    SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
-    SystemChrome.setPreferredOrientations([
-      DeviceOrientation.portraitUp,
-      DeviceOrientation.portraitDown,
-      DeviceOrientation.landscapeLeft,
-      DeviceOrientation.landscapeRight,
-    ]);
+    SystemChrome.setEnabledSystemUIOverlays(
+        widget.controller.systemOverlaysAfterFullScreen);
+    SystemChrome.setPreferredOrientations(
+        widget.controller.deviceOrientationsAfterFullScreen);
   }
 }
 
@@ -162,6 +159,13 @@ class ChewieController extends ChangeNotifier {
     this.allowedScreenSleep = true,
     this.isLive = false,
     this.allowFullScreen = true,
+    this.systemOverlaysAfterFullScreen = SystemUiOverlay.values,
+    this.deviceOrientationsAfterFullScreen = const [
+      DeviceOrientation.portraitUp,
+      DeviceOrientation.portraitDown,
+      DeviceOrientation.landscapeLeft,
+      DeviceOrientation.landscapeRight,
+    ],
   }) : assert(videoPlayerController != null,
             'You must provide a controller to play a video') {
     _initialize();
@@ -219,6 +223,12 @@ class ChewieController extends ChangeNotifier {
   /// Defines if the fullscreen control should be shown
   final bool allowFullScreen;
 
+  /// Defines the system overlays visible after exiting fullscreen
+  final List<SystemUiOverlay> systemOverlaysAfterFullScreen;
+
+  /// Defines the set of allowed device orientations after exiting fullscreen
+  final List<DeviceOrientation> deviceOrientationsAfterFullScreen;
+
   static ChewieController of(BuildContext context) {
     final _ChewieControllerProvider chewieControllerProvider =
         context.inheritFromWidgetOfExactType(_ChewieControllerProvider);