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

Start video at a certain position (#32)

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

+ 8 - 0
lib/src/chewie_player.dart

@@ -21,6 +21,9 @@ class Chewie extends StatefulWidget {
   /// Play the video as soon as it's displayed
   /// Play the video as soon as it's displayed
   final bool autoPlay;
   final bool autoPlay;
 
 
+  /// Start video at a certain position
+  final Duration startAt;
+
   /// Whether or not the video should loop
   /// Whether or not the video should loop
   final bool looping;
   final bool looping;
 
 
@@ -51,6 +54,7 @@ class Chewie extends StatefulWidget {
     this.aspectRatio,
     this.aspectRatio,
     this.autoInitialize = false,
     this.autoInitialize = false,
     this.autoPlay = false,
     this.autoPlay = false,
+    this.startAt,
     this.looping = false,
     this.looping = false,
     this.cupertinoProgressColors,
     this.cupertinoProgressColors,
     this.materialProgressColors,
     this.materialProgressColors,
@@ -133,6 +137,10 @@ class _ChewiePlayerState extends State<Chewie> {
     if (widget.autoPlay) {
     if (widget.autoPlay) {
       await _controller.play();
       await _controller.play();
     }
     }
+
+    if (widget.startAt != null) {
+      await _controller.seekTo(widget.startAt);
+    }
   }
   }
 
 
   @override
   @override