0

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,
                      ),
)
);
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
Manish Tiwari
  • 1,806
  • 10
  • 42
  • 65

1 Answers1

0

add this code in initState

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