ja2375 / FluTube

A Flutter plugin to facilitate embedding Youtube videos inside mobile apps.
MIT License
34 stars 17 forks source link

VideoPlayerController / ChewieController called on Dispose () #5

Closed elitedeveloper closed 5 years ago

elitedeveloper commented 5 years ago

Hi there! FluTube did a really good job where other plugins fails to do but I am having a strange issue and that is when ever I tries to change video URL Programmatically It shows error "VideoPlayer Controller called disposed". Note: Error Disappears when I call setState on onVideoStart. But this red error screen till video is loading is really annoying!

ja2375 commented 5 years ago

I will take a look on this. Thanks!

elitedeveloper commented 5 years ago

I will take a look on this. Thanks!

I fix it by modifying the source of FluTube! Normally Example work perfectly but when we fetch youtube links from API then this error appears. Moreover, sometimes this error got triggered due to Problem in VideoPlayer library so I have to write more code in FLuTube to handle these exceptions!

ja2375 commented 5 years ago

I think i'm not fully understanding you. Which API are you talking about? This plugin does not use any APIs.

Also, what code did you add/modify to fix this problem? If you solved this issue yourself and you think your fix could help others, you can make a pull request and it will be welcome.

elitedeveloper commented 5 years ago

I think i'm not fully understanding you. Which API are you talking about? This plugin does not use any APIs.

Also, what code did you add/modify to fix this problem? If you solved this issue yourself and you think your fix could help others, you can make a pull request and it will be welcome.

The problem is in videoPlayerController so in onWidgetUpdate you are disposing videoController and chewieController. so I just added: if(videoPlayerController !=null || chewieController !=null) { videoPlayerController .dispose(); chewieController .dispose(); } Moreover there are more issues in VideoPlayer library that is used by chewieController so to handle this add this code. videoController.addListener(() { if (videoController.value.hasError) { //handle by yourself } });

OR

videoController.addListener(() { if (videoController.value.hasError) widget.onVideoError(); //let User to handle by creating onVideoError Callback });

Sometimes performing these fixes also through Red Screen so handle this: chewieController.addListener(() { if (chewieController.videoPlayerController.value.hasError) widget.onVideoError(); });

I hope you get it!

ja2375 commented 5 years ago

Thanks for your contribution! You could send a pull request to add those changes as i don't have much time to do it. I will try thought. I like the idea of letting the user handle errors via a callback!

ja2375 commented 5 years ago

Hello, In the last commit i tried to apply what you said but i think it is not working. Could you please review the changes and tell me what is wrong? Or better just send a pull request? I don't have time right now to dig on this issue, so your help will be appreciated.

Thank you

elitedeveloper commented 5 years ago

Yeah, that's correct I review it and that's the same way I am doing!

elitedeveloper commented 5 years ago

Youtube does not allow to access copyright videos so as for your permission can I do changes in your plugin so it can fetch those videos and play in player!

ja2375 commented 5 years ago

So did your issue get fixed? Did you try the example app? I added a button to change video url but it is showing red screen when video gets changed, and also the onVideoError callback doesn't seem to be working for me.

Sure you can!

elitedeveloper commented 5 years ago

Roll back your commit as Error is in videoPlayer controller, and will be fixed soon according to them.

elitedeveloper commented 5 years ago

I have reviewed the example code, unfortunately, onVideoError is not working there. You should do roll back as it is not working.

ja2375 commented 5 years ago

Rollback done. Thanks!