How do I change the position in the video in flutter?

Viewed 3160

I need a way to change the video position programmatically without scrubbing or using the default scrubber. However, the position value is not a setter so how would I be able to do this?

2 Answers

Assuming you're using the VideoPlayerController from the video_player package you can seek to the position you want programmatically by using the seekTo() method.

controller.seekTo(Duration(seconds: /*any second you want*/ ));

To start video where you left off earlier try below code:

controller..initialize().then((_){         
   setState(() {    
     controller.play();    
     controller.seekTo(controller.value.position + lastduration);
   });
});

It works for me

Related