Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Rebuild VideoPlayer once VideoPlayerController finishes initialization. #767

Merged
merged 2 commits into from
Sep 6, 2018

Conversation

nichtverstehen
Copy link
Contributor

This eliminates the races in VideoPlayer plugin initialization.

Otherwise if VideoPlayer is built shortly after the controller starts initialization and doesn't yet have _textureId filled the widgets renders as an empty Container and never rebuilds to show the video later.
Copy link
Contributor

@sigurdm sigurdm left a comment

Choose a reason for hiding this comment

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

LGTM!

This needs a version bump in pubspec/changelog.

This ensure that initialization events that are generated in `onPlayerStateChanged` before the Dart side has chance to subscribe to the channel are queued and eventually delivered.

Fixes flutter/flutter#21483.
@nichtverstehen
Copy link
Contributor Author

Updated the changelog and pubspec.

Copy link
Contributor

@sigurdm sigurdm left a comment

Choose a reason for hiding this comment

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

Still LGTM

@nichtverstehen
Copy link
Contributor Author

Sigurd, are you able to merge this?

@sigurdm sigurdm merged commit f100277 into flutter:master Sep 6, 2018
@sigurdm
Copy link
Contributor

sigurdm commented Sep 6, 2018

Seems I still have access!

@sigurdm
Copy link
Contributor

sigurdm commented Sep 6, 2018

I'll publish a new version as well

@nichtverstehen
Copy link
Contributor Author

Thank you!

@cbenhagen
Copy link
Contributor

@nichtverstehen This breaks switching the VideoPlayerController for some reason. At least it does so in the example of the Chewie video player plugin. As soon as you switch the controller no video frames will ever be rendered again.

Do you have any ideas why? Before I dig any deeper..

@nichtverstehen
Copy link
Contributor Author

Oops, it's obvious in retrospect. We should react to didUpdateWidget, not initState. Let me prepare a fix.

nichtverstehen added a commit to nichtverstehen/plugins that referenced this pull request Sep 6, 2018
…hanges.

This fixes a bug introduced in flutter#767: if a State is attached to a new widget it never switched to the new controller.

Also this change makes sure to remove listeners during deinitialization.
nichtverstehen added a commit to nichtverstehen/plugins that referenced this pull request Sep 6, 2018
…hanges.

This fixes a bug introduced in flutter#767: if a State is attached to a new widget it never switched to the new controller.

Also this change makes sure to remove listeners during deinitialization.
@nichtverstehen
Copy link
Contributor Author

Sent #769.

nichtverstehen added a commit to nichtverstehen/plugins that referenced this pull request Sep 7, 2018
…hanges.

This fixes a bug introduced in flutter#767: if a State is attached to a new widget it never switched to the new controller.

Also this change makes sure to remove listeners during deinitialization.
nichtverstehen added a commit to nichtverstehen/plugins that referenced this pull request Sep 7, 2018
…hanges.

This fixes a bug introduced in flutter#767: if a State is attached to a new widget it never switched to the new controller.

Also this change makes sure to remove listeners during deinitialization.
sigurdm pushed a commit that referenced this pull request Sep 11, 2018
* Update textureId in VideoPlayer widget when the attached controller changes.

This fixes a bug introduced in #767: if a State is attached to a new widget it never switched to the new controller.

Also this change makes sure to remove listeners during deinitialization.

* Add tests for conditions identified in flutter/flutter#21483.

This is a breaking change since it reduces the public interface of VideoPlayerController to make it easier to fake it in the test (and hide unnecessary implementation details).
andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
…n. (flutter#767)

* Rebuild VideoPlayer once VideoPlayerController finishes initialization.

Otherwise if VideoPlayer is built shortly after the controller starts initialization and doesn't yet have _textureId filled the widgets renders as an empty Container and never rebuilds to show the video later.

* Queue VideoPlayer events in the EventSink.

This ensure that initialization events that are generated in `onPlayerStateChanged` before the Dart side has chance to subscribe to the channel are queued and eventually delivered.

Fixes flutter/flutter#21483.
andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
…er#769)

* Update textureId in VideoPlayer widget when the attached controller changes.

This fixes a bug introduced in flutter#767: if a State is attached to a new widget it never switched to the new controller.

Also this change makes sure to remove listeners during deinitialization.

* Add tests for conditions identified in flutter/flutter#21483.

This is a breaking change since it reduces the public interface of VideoPlayerController to make it easier to fake it in the test (and hide unnecessary implementation details).
andreidiaconu added a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
ryanheise pushed a commit to ryanheise/background_video_player that referenced this pull request Sep 29, 2019
* Update textureId in VideoPlayer widget when the attached controller changes.

This fixes a bug introduced in flutter/plugins#767: if a State is attached to a new widget it never switched to the new controller.

Also this change makes sure to remove listeners during deinitialization.

* Add tests for conditions identified in flutter/flutter#21483.

This is a breaking change since it reduces the public interface of VideoPlayerController to make it easier to fake it in the test (and hide unnecessary implementation details).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
4 participants