Flutter Pod Player Exception: Try to seek video from progress bar then audio will be distorted and video will get stuck

469 Views Asked by At

I am able to load the YouTube video but when I was trying to seek video from the progress bar like in progress bar, tap anywhere to seek the video then it will get stuck, and audio will be distorted.

     @override
              void initState() {
                super.initState();
                controller = PodPlayerController(
                  playVideoFrom: PlayVideoFrom.youtube('https://youtu.be/TBTgQbjRsqg'),
                )..initialise().then((value) {
                    setState(() {
                      isVideoPlaying = controller.isVideoPlaying;
                    });
                  });
                controller.addListener(_listner);
              }
        
        void _listner() {
            if (controller.isVideoPlaying != isVideoPlaying) {
              isVideoPlaying = controller.isVideoPlaying;
            }
            if (mounted) setState(() {});
          }
        
          @override
          void dispose() {
            controller.removeListener(_listner);
            controller.dispose();
            super.dispose();
          }
        
        @override
      Widget build(BuildContext context) {
        return Scaffold(
      appBar: AppBar(title: const Text('Custom Player')),
      body: PodVideoPlayer(
                        alwaysShowProgressBar: alwaysShowProgressBar,
                        controller: controller,
                        matchFrameAspectRatioToVideo: true,
                        matchVideoAspectRatioToFrame: true,
                        videoTitle: videoTitle,
                      ),
)
);
    }
1

There are 1 best solutions below

0
video Agent On BEST ANSWER

add this code in initState

controller.addListener(() {
  if(controller.isVideoPlaying==false){
    controller.pause();
    return;
  }
});