Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

flutter

dart

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?

like image 425
Coder Avatar asked Dec 23 '18 17:12

Coder


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*/ ));

like image 92
Miguel Ruivo Avatar answered Nov 03 '22 01:11

Miguel Ruivo


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

like image 22
Nandakishor Dhanaji Valakunde Avatar answered Nov 03 '22 01:11

Nandakishor Dhanaji Valakunde