video_viewer
video_viewer copied to clipboard
seekTo not working
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(() {});
});
} `
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)
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
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: @.***>
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);
}
}
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: @.***>
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: @.***>
It exits but you have written it bad, check your linter
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