浏览代码

Add showControlsOnInitialize property

Ben Hagen 6 年之前
父节点
当前提交
ab9277d580
共有 3 个文件被更改,包括 19 次插入11 次删除
  1. 5 1
      lib/src/chewie_player.dart
  2. 6 4
      lib/src/cupertino_controls.dart
  3. 8 6
      lib/src/material_controls.dart

+ 5 - 1
lib/src/chewie_player.dart

@@ -178,6 +178,7 @@ class ChewieController extends ChangeNotifier {
     this.materialProgressColors,
     this.placeholder,
     this.overlay,
+    this.showControlsOnInitialize = true,
     this.showControls = true,
     this.customControls,
     this.errorBuilder,
@@ -213,7 +214,10 @@ class ChewieController extends ChangeNotifier {
   /// Whether or not the video should loop
   final bool looping;
 
-  /// Whether or not to show the controls
+  /// Weather or not to show the controls when initializing the widget.
+  final bool showControlsOnInitialize;
+
+  /// Whether or not to show the controls at all
   final bool showControls;
 
   /// Defines customised controls. Check [MaterialControls] or

+ 6 - 4
lib/src/cupertino_controls.dart

@@ -435,11 +435,13 @@ class _CupertinoControlsState extends State<CupertinoControls> {
       _startHideTimer();
     }
 
-    _initTimer = Timer(Duration(milliseconds: 200), () {
-      setState(() {
-        _hideStuff = false;
+    if (chewieController.showControlsOnInitialize) {
+      _initTimer = Timer(Duration(milliseconds: 200), () {
+        setState(() {
+          _hideStuff = false;
+        });
       });
-    });
+    }
   }
 
   void _onExpandCollapse() {

+ 8 - 6
lib/src/material_controls.dart

@@ -21,7 +21,7 @@ class _MaterialControlsState extends State<MaterialControls> {
   double _latestVolume;
   bool _hideStuff = true;
   Timer _hideTimer;
-  Timer _showTimer;
+  Timer _initTimer;
   Timer _showAfterExpandCollapseTimer;
   bool _dragging = false;
 
@@ -80,7 +80,7 @@ class _MaterialControlsState extends State<MaterialControls> {
   void _dispose() {
     controller.removeListener(_updateState);
     _hideTimer?.cancel();
-    _showTimer?.cancel();
+    _initTimer?.cancel();
     _showAfterExpandCollapseTimer?.cancel();
   }
 
@@ -286,11 +286,13 @@ class _MaterialControlsState extends State<MaterialControls> {
       _startHideTimer();
     }
 
-    _showTimer = Timer(Duration(milliseconds: 200), () {
-      setState(() {
-        _hideStuff = false;
+    if (chewieController.showControlsOnInitialize) {
+      _initTimer = Timer(Duration(milliseconds: 200), () {
+        setState(() {
+          _hideStuff = false;
+        });
       });
-    });
+    }
   }
 
   void _onExpandCollapse() {