Home > Software engineering >  How to know if the video reached the last position when using video_player in flutter?
How to know if the video reached the last position when using video_player in flutter?

Time:10-06

I am using video_player for displaying a video. I want to know the if the video reached the last position to display a replay icon and do some logic. How can we approach this in flutter.

CodePudding user response:

_videoController.addListener(() {                       //custom Listner
      setState(() {
        if (!_videoController.value.isPlaying &&_videoController.value.initialized &&
            (_videoController.value.duration ==_videoController.value.position)) { //checking the duration and position every time
          //Video Completed//
          // code here to show reply button//
        }
      });
    })
  • Related