Ver código fonte

Merge pull request #113 from CaiJingLong/fix-rotate-box-overlay

修正了全屏类型为rotateBox时, 快进, 音量方向不正确的问题.
Caijinglong 6 anos atrás
pai
commit
b04b388533

+ 6 - 6
example/pubspec.lock

@@ -1,5 +1,5 @@
 # Generated by pub
-# See https://www.dartlang.org/tools/pub/glossary#lockfile
+# See https://dart.dev/tools/pub/glossary#lockfile
 packages:
   analyzer:
     dependency: transitive
@@ -21,7 +21,7 @@ packages:
       name: async
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.1.0"
+    version: "2.2.0"
   boolean_selector:
     dependency: transitive
     description:
@@ -169,7 +169,7 @@ packages:
       name: pedantic
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "1.5.0"
+    version: "1.7.0"
   petitparser:
     dependency: transitive
     description:
@@ -204,7 +204,7 @@ packages:
       name: quiver
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "2.0.2"
+    version: "2.0.3"
   sky_engine:
     dependency: transitive
     description: flutter
@@ -251,7 +251,7 @@ packages:
       name: test_api
       url: "https://pub.flutter-io.cn"
     source: hosted
-    version: "0.2.4"
+    version: "0.2.5"
   typed_data:
     dependency: transitive
     description:
@@ -281,5 +281,5 @@ packages:
     source: hosted
     version: "2.1.15"
 sdks:
-  dart: ">=2.2.0 <3.0.0"
+  dart: ">=2.2.2 <3.0.0"
   flutter: ">=0.3.0 <2.0.0"

+ 40 - 0
lib/src/helper/full_screen_helper.dart

@@ -0,0 +1,40 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
+
+class FullScreenHelper {
+  static int getQuarterTurns(VideoInfo info, BuildContext context) {
+    Axis axis;
+
+    if (info.width == 0 || info.height == 0) {
+      axis = Axis.horizontal;
+    } else if (info.width > info.height) {
+      if (info.degree == 90 || info.degree == 270) {
+        axis = Axis.vertical;
+      } else {
+        axis = Axis.horizontal;
+      }
+    } else {
+      if (info.degree == 90 || info.degree == 270) {
+        axis = Axis.horizontal;
+      } else {
+        axis = Axis.vertical;
+      }
+    }
+
+    var mediaQueryData = MediaQuery.of(context);
+
+    int quarterTurns;
+
+    if (axis == Axis.horizontal) {
+      if (mediaQueryData.orientation == Orientation.landscape) {
+        quarterTurns = 0;
+      } else {
+        quarterTurns = 1;
+      }
+    } else {
+      quarterTurns = 0;
+    }
+
+    return quarterTurns;
+  }
+}

+ 1 - 0
lib/src/helper/ui_helper.dart

@@ -25,4 +25,5 @@ class UIHelper {
     }
     return renderObject.globalToLocal(offsetGlobal);
   }
+
 }

+ 14 - 1
lib/src/widget/controller_widget_builder.dart

@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
+import 'package:flutter_ijkplayer/src/helper/full_screen_helper.dart';
 import 'package:flutter_ijkplayer/src/helper/logutil.dart';
 import 'package:flutter_ijkplayer/src/helper/time_helper.dart';
 import 'package:flutter_ijkplayer/src/helper/ui_helper.dart';
@@ -234,7 +235,10 @@ class _DefaultIJKControllerWidgetState extends State<DefaultIJKControllerWidget>
     );
   }
 
+  int _overlayTurns = 0;
+
   Widget buildPortrait(VideoInfo info) {
+    _overlayTurns = FullScreenHelper.getQuarterTurns(info, context);
     return PortraitController(
       controller: controller,
       info: info,
@@ -273,11 +277,20 @@ class _DefaultIJKControllerWidgetState extends State<DefaultIJKControllerWidget>
     hideTooltip();
     _tipOverlay = OverlayEntry(
       builder: (BuildContext context) {
-        return IgnorePointer(
+        Widget w = IgnorePointer(
           child: Center(
             child: widget,
           ),
         );
+
+        if (this.widget.fullScreenType == FullScreenType.rotateBox && this.widget.currentFullScreenState && _overlayTurns != 0) {
+          w = RotatedBox(
+            child: w,
+            quarterTurns: _overlayTurns,
+          );
+        }
+
+        return w;
       },
     );
     Overlay.of(context).insert(_tipOverlay);