Explorar o código

Start video at a certain position (#32)

Ben Hagen %!s(int64=7) %!d(string=hai) anos
pai
achega
abc601f3ec
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  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