I am using the Flutter video_player package here: https://pub.dev/packages/video_player
How do I get the duration of the video? I can see there is a position
property, so I would need that to get the current value in time.
But how do I get the total duration of the video? The video is from a URL
.
I am making a custom player so I need these two values.
For getting the Total duration you can use the video controller
VideoPlayerController _controller = VideoPlayerController.network('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
});
Duration durationOfVideo = _controller.value.duration;
You can also directly store the integer instead of duration as below image
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With