Parcourir la source

移除orientation插件,修复iOS横屏问题(待验证)

hwh97 il y a 6 ans
Parent
commit
20ea57b882

BIN
assets/dub_user_play/2.0x/bofang.png


BIN
assets/dub_user_play/2.0x/fangda.png


BIN
assets/dub_user_play/2.0x/shousuo.png


BIN
assets/dub_user_play/2.0x/stop.png


BIN
assets/dub_user_play/2.0x/zuojiantou.png


BIN
assets/dub_user_play/3.0x/bofang.png


BIN
assets/dub_user_play/3.0x/fangda.png


BIN
assets/dub_user_play/3.0x/shousuo.png


BIN
assets/dub_user_play/3.0x/stop.png


BIN
assets/dub_user_play/3.0x/zuojiantou.png


BIN
assets/dub_user_play/bofang.png


BIN
assets/dub_user_play/fangda.png


BIN
assets/dub_user_play/shousuo.png


BIN
assets/dub_user_play/stop.png


BIN
assets/dub_user_play/zuojiantou.png


+ 1 - 1
example/.flutter-plugins-dependencies

@@ -1 +1 @@
-{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"auto_orientation","dependencies":[]},{"name":"orientation","dependencies":[]},{"name":"screen","dependencies":[]},{"name":"sys_volume","dependencies":[]},{"name":"video_player","dependencies":[]},{"name":"wakelock","dependencies":[]}]}
+{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"auto_orientation","dependencies":[]},{"name":"screen","dependencies":[]},{"name":"sys_volume","dependencies":[]},{"name":"video_player","dependencies":[]},{"name":"wakelock","dependencies":[]}]}

+ 24 - 21
lib/src/cartoon_material_controls.dart

@@ -802,29 +802,32 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
 
   Widget _buildProgressBar() {
     return Expanded(
-      child: MaterialVideoProgressBar(
-        controller,
-        onDragStart: () {
-          setState(() {
-            _dragging = true;
-          });
+      child: Padding(
+        padding: EdgeInsets.only(bottom: 3),
+        child: MaterialVideoProgressBar(
+          controller,
+          onDragStart: () {
+            setState(() {
+              _dragging = true;
+            });
 
-          _hideTimer?.cancel();
-        },
-        onDragEnd: () {
-          setState(() {
-            _dragging = false;
-          });
+            _hideTimer?.cancel();
+          },
+          onDragEnd: () {
+            setState(() {
+              _dragging = false;
+            });
 
-          _startHideTimer();
-        },
-        colors: chewieController.materialProgressColors ??
-            ChewieProgressColors(
-                playedColor: Color(0xFFC7000B),
-                handleColor: Color(0xFFC7000B),
-                bufferedColor: Color(0x5AC7000B),
-                backgroundColor: Color(0x5AFFFFFF)),
-        millionSec: updateDragDuration?.inMilliseconds,
+            _startHideTimer();
+          },
+          colors: chewieController.materialProgressColors ??
+              ChewieProgressColors(
+                  playedColor: Color(0xFFEF765E),
+                  handleColor: Color(0xFFEF765E),
+                  bufferedColor:  Color(0x5AEF765E),
+                  backgroundColor: Color(0x5AFFFFFF)),
+          millionSec: updateDragDuration?.inMilliseconds,
+        ),
       ),
     );
   }

+ 0 - 9
lib/src/chewie_player.dart

@@ -6,7 +6,6 @@ import 'package:chewie/src/player_with_controls.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 import 'package:flutter/widgets.dart';
-import 'package:orientation/orientation.dart';
 import 'package:video_player/video_player.dart';
 import 'package:wakelock/wakelock.dart';
 
@@ -146,12 +145,10 @@ class ChewieState extends State<Chewie> {
 
     SystemChrome.setEnabledSystemUIOverlays([]);
     /// ?????????????????????????????????????
-    if (isAndroid) {
       SystemChrome.setPreferredOrientations([
         DeviceOrientation.landscapeLeft,
         DeviceOrientation.landscapeRight,
       ]);
-    }
 
     if (!widget.controller.allowedScreenSleep) {
       Wakelock.enable();
@@ -356,12 +353,6 @@ class ChewieController extends ChangeNotifier {
 
   void toggleFullScreen() {
     _isFullScreen = !_isFullScreen;
-    if (Platform.isIOS) {
-      OrientationPlugin.forceOrientation(isFullScreen
-          ? DeviceOrientation.landscapeRight
-          : DeviceOrientation.portraitUp
-      );
-    }
     notifyListeners();
   }
 

+ 3 - 0
lib/src/chewie_progress_colors.dart

@@ -5,14 +5,17 @@ class ChewieProgressColors {
     Color playedColor: const Color.fromRGBO(255, 0, 0, 0.7),
     Color bufferedColor: const Color.fromRGBO(30, 30, 200, 0.2),
     Color handleColor: const Color.fromRGBO(200, 200, 200, 1.0),
+    Color handleInsideColor: const Color.fromRGBO(255, 255, 255, 1.0),
     Color backgroundColor: const Color.fromRGBO(200, 200, 200, 0.5),
   })  : playedPaint = Paint()..color = playedColor,
         bufferedPaint = Paint()..color = bufferedColor,
         handlePaint = Paint()..color = handleColor,
+        handleInsidePaint = Paint()..color = handleInsideColor,
         backgroundPaint = Paint()..color = backgroundColor;
 
   final Paint playedPaint;
   final Paint bufferedPaint;
   final Paint handlePaint;
+  final Paint handleInsidePaint;
   final Paint backgroundPaint;
 }

+ 33 - 24
lib/src/i2_material_controls.dart

@@ -118,6 +118,7 @@ class MaterialControlsState extends State<I2MaterialControls> {
             if (_verticalMode != null && endDy != null && startDy != null) {
               double value;
               if (_verticalMode == VerticalMode.Bright) {
+                if (currentBright == null) return;
                 if (endDy > startDy) {
                   // 降低操作 竖屏环境?????
                   value = (currentBright - (endDy - startDy) / MediaQuery.of(context).size.height) < 0
@@ -131,6 +132,7 @@ class MaterialControlsState extends State<I2MaterialControls> {
                 }
                 Screen.setBrightness(value);
               } else {
+                if (currentVolume == null) return;
                 if (endDy > startDy) {
                   // 降低操作 竖屏环境?????
                   value = (currentVolume - (endDy - startDy) / MediaQuery.of(context).size.height) < 0
@@ -382,12 +384,17 @@ class MaterialControlsState extends State<I2MaterialControls> {
 //              height: 44.0 + MediaQuery.of(context).padding.top != 0 ? MediaQuery.of(context).padding.top : 0,
           width: MediaQuery.of(context).size.width,
 //          margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top != 0 ? MediaQuery.of(context).padding.top : 0),
-          padding: EdgeInsets.only(left: 13,),
           child: Row(
             children: <Widget>[
               GestureDetector(
                   onTap: onTapBack,
-                  child: Image(image: AssetImage("assets/dub_user_play/zuojiantou.png", package: 'chewie'), width: 20, height: 20,)
+                  behavior: HitTestBehavior.opaque,
+                  child: Container(
+                    alignment: Alignment.center,
+                    width: 50,
+                    height: 40,
+                    child: Image(image: AssetImage("assets/dub_user_play/zuojiantou.png", package: 'chewie'), width: 20, height: 20,),
+                  )
               ),
             ],
           )
@@ -704,35 +711,37 @@ class MaterialControlsState extends State<I2MaterialControls> {
 
   Widget _buildProgressBar() {
     return Expanded(
-      child: MaterialVideoProgressBar(
-        controller,
-        onDragStart: () {
-          setState(() {
-            _dragging = true;
-          });
+      child: Padding(
+        padding: EdgeInsets.only(bottom: 3),
+        child: MaterialVideoProgressBar(
+          controller,
+          onDragStart: () {
+            setState(() {
+              _dragging = true;
+            });
 
-          _hideTimer?.cancel();
-        },
-        onDragEnd: () {
-          setState(() {
-            _dragging = false;
-          });
+            _hideTimer?.cancel();
+          },
+          onDragEnd: () {
+            setState(() {
+              _dragging = false;
+            });
 
-          _startHideTimer();
-        },
-        colors: chewieController.materialProgressColors ??
-            ChewieProgressColors(
-                playedColor: Color(0xFFC7000B),
-                handleColor: Color(0xFFC7000B),
-                bufferedColor:  Color(0x5AC7000B),
-                backgroundColor: Color(0x5AFFFFFF)),
-        millionSec: updateDragDuration?.inMilliseconds,
+            _startHideTimer();
+          },
+          colors: chewieController.materialProgressColors ??
+              ChewieProgressColors(
+                  playedColor: Color(0xFFEF765E),
+                  handleColor: Color(0xFFEF765E),
+                  bufferedColor:  Color(0x5AEF765E),
+                  backgroundColor: Color(0x5AFFFFFF)),
+          millionSec: updateDragDuration?.inMilliseconds,
+        ),
       ),
     );
   }
 
   void onTapBack() {
-    print("onTapBack");
     if (chewieController.isFullScreen) {
       chewieController.toggleFullScreen();
     } else {

+ 7 - 2
lib/src/material_progress_bar.dart

@@ -134,7 +134,7 @@ class _ProgressBarPainter extends CustomPainter {
 
   @override
   void paint(Canvas canvas, Size size) {
-    final height = 2.0;
+    final height = 6.0;
 
     canvas.drawRRect(
       RRect.fromRectAndRadius(
@@ -179,8 +179,13 @@ class _ProgressBarPainter extends CustomPainter {
     );
     canvas.drawCircle(
       Offset(playedPart, size.height / 2 + height / 2),
-      height * 3,
+      height * 1.2,
       colors.handlePaint,
     );
+    canvas.drawCircle(
+      Offset(playedPart, size.height / 2 + height / 2),
+      height * 0.6,
+      colors.handleInsidePaint,
+    );
   }
 }

+ 0 - 3
pubspec.yaml

@@ -16,9 +16,6 @@ dependencies:
   screen:
     git:
       url: https://github.com/hwh97/flutter_screen.git
-  orientation:
-    git:
-      url: https://github.com/hwh97/flutter_orientation.git
   sys_volume:
     git:
       url: https://github.com/hwh97/flutter_volume.git