seel-channel / video_viewer

FLUTTER PACKAGE: Multiplatform minimalist video viewer with spectacular user experience.
https://pub.dev/packages/video_viewer
MIT License
54 stars 55 forks source link

seekTo not working #52

Open tuvia opened 2 years ago

tuvia commented 2 years ago

Hi, I have the following code (adapted a little, just to show the problem). The seekTo function sis not working. It always starts from beginning of video... I tried putting the seekTo call before initialising videoViewer and after. Any ideas of what might be happening? Thank you!

`VideoViewerController videoController = VideoViewerController(); Widget? videoViewer;

@override void initState() { super.initState();

  // initialize video
  videoViewer =
      VideoViewer(
          controller: videoController,
          autoPlay: true,
          source: {
    "video":
        VideoSource(video: VideoPlayerController.file(File(filePath))),
  });

  videoController.seekTo(Duration(milliseconds: filePosition));

  setState(() {});
});

} `

seel-channel commented 2 years ago

The seekTo it just available when the video has been started (It's asynchronous and you can addListener to VideoViewerController and check it out if it initialized)

seel-channel commented 2 years ago

For example, if you want to seek to 1:20 but the video is not started, then the max duration is zero and you are not able to do it

tuvia commented 2 years ago

Great!

How do you know inside the addlistener function that videoController is initialized?

Do you check videoController.mounted? Do you check videoController.isPlaying?

I suppose after the the check you can call seekTo. However there has to be some way to check for a one time condition I order to avoid a call to seekTo every time the listener is called...

Thank you for answering!!

Tuvia

On Mon, Jan 31, 2022, 1:10 AM Luis Felipe Murguia Ramos < @.***> wrote:

The seekTo it just available when the video has been started (It's asynchronous and you can addListener to VideoViewerController and check it out if it initialized)

— Reply to this email directly, view it on GitHub https://github.com/seel-channel/video_viewer/issues/52#issuecomment-1025359496, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABALFGZRG4CLVNVQTFWOJGTUYYDSHANCNFSM5NET3GMQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

seel-channel commented 2 years ago

VideoViewerController has video getter (VideoPlayerController).


 final controller = VideoViewerController();

 ... 

 controller.video.addListener(_videoListener);

 ... 

 void _videoListener() {
   if(controller.video.isInitialized) {
     controller.video.seekTo(Duration(seconds: 20));
  controller.video.removeListener(_videoListener);

   }
 }
tuvia commented 2 years ago

Got it, but when I try to run this code,

controller.video.isInitialized

the system says:

"The getter 'isInitilized' isn't defined for the type 'VideoPlayerController'. (Documentation)"

Any ideas? Thank you!

Rabino Tuvia Serber Beit Jabad La Plata

www.jabadlaplata.org.ar

El lun, 31 ene 2022 a la(s) 03:05, Luis Felipe Murguia Ramos ( @.***) escribió:

VideoViewerController has video getter (VideoPlayerController).

final controller = VideoViewerController();

...

controller.video.addListener(videoListener);

...

void _videoListener() { if(controller.video.isInitialized) { controller.seekTo(Duration(seconds: 20)); } }

— Reply to this email directly, view it on GitHub https://github.com/seel-channel/video_viewer/issues/52#issuecomment-1025408085, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABALFG3G67W33OLPHXTPJ4TUYYRBXANCNFSM5NET3GMQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

tuvia commented 2 years ago

Just in case, for video I'm using VideoViewer

Thank you, Tuvia

On Mon, Jan 31, 2022, 6:54 AM Beit Jabad La Plata < @.***> wrote:

Got it, but when I try to run this code,

controller.video.isInitialized

the system says:

"The getter 'isInitilized' isn't defined for the type 'VideoPlayerController'. (Documentation)"

Any ideas? Thank you!

Rabino Tuvia Serber Beit Jabad La Plata

www.jabadlaplata.org.ar

El lun, 31 ene 2022 a la(s) 03:05, Luis Felipe Murguia Ramos ( @.***) escribió:

VideoViewerController has video getter (VideoPlayerController).

final controller = VideoViewerController();

...

controller.video.addListener(videoListener);

...

void _videoListener() { if(controller.video.isInitialized) { controller.seekTo(Duration(seconds: 20)); } }

— Reply to this email directly, view it on GitHub https://github.com/seel-channel/video_viewer/issues/52#issuecomment-1025408085, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABALFG3G67W33OLPHXTPJ4TUYYRBXANCNFSM5NET3GMQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

seel-channel commented 2 years ago

It exits but you have written it bad, check your linter

raymclee commented 1 year ago

VideoViewerController has video getter (VideoPlayerController).

 final controller = VideoViewerController();

 ... 

 controller.video.addListener(_videoListener);

 ... 

 void _videoListener() {
   if(controller.video.isInitialized) {
     controller.video.seekTo(Duration(seconds: 20));
  controller.video.removeListener(_videoListener);

   }
 }

the code doesn't work for me. There is controller.video.value.isInitialized but not controller.video.isInitialized. but the state never change isInitialized to true