浏览代码

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