Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChewieController #99

Merged
merged 24 commits into from
Jan 24, 2019
Merged

Conversation

cbenhagen
Copy link
Collaborator

@cbenhagen cbenhagen commented Jan 16, 2019

This is an attempt in fixing #1 by implementing a ChewieController which is internally accessed by an InheritedWidget.

TODO:

  • Check if playback hack is still needed and if yes, add it back in
  • VideoPlayer tries to access disposed VideoController after we changed and disposed it in the ChewieController
  • Add data to be rendered on all the Widgets, probably as Listenables, such as ChangeNotifier or ValueNotifier.
  • Update changelog
  • Document how to migrate from Chewie < 1.0.0

fixes #1
fixes #23
fixes #49

@cbenhagen
Copy link
Collaborator Author

@brianegan I know it still has some rough edges but if you have time it would be awesome if you could have a quick look at the changes and tell me if this is the direction you'd like this to go.

@brianegan
Copy link
Collaborator

Other than a couple small nitpicks, this is exactly the direction I was thinking of going. Really well done :D :D :D

@brianegan
Copy link
Collaborator

brianegan commented Jan 16, 2019

Two more things: As part of this PR, could you please add yourself to the list of authors in the pubspec.yaml? I'll also give you uploader rights for this repo so once this is ready to roll you can go ahead and publish it to pub if you'd like :)

@cbenhagen
Copy link
Collaborator Author

Done :)

@brianegan
Copy link
Collaborator

brianegan commented Jan 16, 2019

Cool, just added that email as an uploader as well. You should get a confirmation email to that address!

Only thing I'd ask: Please update the CHANGELOG as well when ya push new versions to let folks know what's changed. Other than that, not too much to publishing new versions!

Thanks again for all the contributions :) Seems like more and more folks are using this library, great to make it better.

@cbenhagen
Copy link
Collaborator Author

Sure! I will also not push bigger changes without discussing them first. And then we should always guide the users how to migrate. Thank you for that great package!

We can switch back to using ValueNotifier when we have a lot more values and it is more convenient to change and notify with one `value.copyWith(foo='bar')` instead of explicitly having to call notifyListeners(). Until then the code is just much cleaner without so much boiler plate.
@cbenhagen
Copy link
Collaborator Author

@brianegan, you once mentioned to "add data to be rendered on all the Widgets, probably as Listenables, such as ChangeNotifier or ValueNotifier". What do you think, should we add this to this release? If yes, what data did you have in mind?

More finegraned customisation of exisiting controls to be added later.
@brianegan
Copy link
Collaborator

brianegan commented Jan 17, 2019

Nope, this covers it -- the idea was to give something folks can listen to for data updates -- in this case, the ChewieController does the job, and Widgets can get the info they need from that controller (or the nested VideoController)!

Awesome work! I'll do a final review :)

@cbenhagen
Copy link
Collaborator Author

@brianegan I got more plans for Chewie like supporting multiple versions of a clip as well as playlists. I guess they can both be added without breaking the API again by adding named constructors and internally switching to always having a list(of lists) of VideoControllers but setting one as the current videoPlayerController. So unless you see any breaking changes ahead, you could do a final review of this PR so we can publish this.

@cbenhagen cbenhagen changed the title WIP: ChewieController ChewieController Jan 20, 2019
Copy link
Collaborator

@brianegan brianegan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small details and a bug report! Looking great overall:)

Bug Report:

  • Run Example, Tap "Full Screen" Button, Tap android back button, tap "Full Screen" Button again -- broken state. We probably aren't handling the Android Back Button properly here, which can return a "null" value and might be throwing an error if that isn't checked.

lib/src/chewie_controller.dart Outdated Show resolved Hide resolved
pubspec.yaml Outdated Show resolved Hide resolved
chewieController = ChewieControllerProvider.of(context);
controller = chewieController.videoPlayerController;

_dispose();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike initState, didChangeDependencies can run multiple times throughout the lifecycle of the Widget. Therefore, we may want to add some logic around this _dispose / initialize code: Only run that dispose and init IF the controller has changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it was also reinitializing when the theme changed. fc1bc16 fixes that.

lib/src/chewie_controller.dart Outdated Show resolved Hide resolved
And make the provider private
@cbenhagen
Copy link
Collaborator Author

Bug Report:

  • Run Example, Tap "Full Screen" Button, Tap android back button, tap "Full Screen" Button again -- broken state. We probably aren't handling the Android Back Button properly here, which can return a "null" value and might be throwing an error if that isn't checked.

Nice catch! Fixed in cd20458.

Copy link
Collaborator

@brianegan brianegan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo! Again, fantastic work 🎉 😄 👏

This Looks Good To Me. Feel free to merge and ship when you think it's ready!

@cbenhagen
Copy link
Collaborator Author

Just noticed that I need a gmail account to upload. Please add my personal mail as uploader: c.ben.hagen@gmail.com

@brianegan
Copy link
Collaborator

brianegan commented Jan 24, 2019 via email

@cbenhagen cbenhagen merged commit 58931ed into fluttercommunity:master Jan 24, 2019
@cbenhagen cbenhagen deleted the ChewieController branch January 25, 2019 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fullscreen events Launch video in fullscreen through a custom button. Make the code more manageable
2 participants