Skip to content

[video_player_avfoundation] Fix playback speed doesn't get persisted on iOS after reinitializing with new VideoPlayerController #3720

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

Conversation

vmalyi
Copy link

@vmalyi vmalyi commented Apr 16, 2023

Note: this PR replaces accidentally closed #3515.

This PR fixes the flutter/flutter#100351 by using the playImmediately(atRate:) instead of play() because calling play() has an effect of setting back the rate to 1.0 which is unwanted in case of VideoPlayerController's reinitialization.

Using playImmediately(atRate:) is safe even with slower internet connections because AVPlayer automatically compensates eventual lack of media in the buffer by simply behaving as if it has encountered a stall during playback.

Considering that updatePlayingState() function which, in turn, invokes the playImmediately(atRate:), is only called when handling "pause" or "play" events or in AVPlayerItemStatusReadyToPlay state, it's safe for user experience to use the playImmediately(atRate:) instead of play().

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

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

carrying over the stamp from previous PR

@stuartmorgan-g stuartmorgan-g requested a review from tarrinneal May 2, 2023 19:48
@tarrinneal
Copy link
Contributor

Seems that this pr is failing some critical tests (video assets can be played).

I will be happy to provide a second review once those tests are passing.

@vmalyi
Copy link
Author

vmalyi commented May 3, 2023

Seems that this pr is failing some critical tests (video assets can be played).

I will be happy to provide a second review once those tests are passing.

I've just checked which tests have been failed and they seem to be unrelated to the contents of this PR.

Any chance that someone could restart the Mac_arm64 ios_platform_tests_shard_1 master and see if it fixes the issue?

Thanks!

@tarrinneal
Copy link
Contributor

Seems that this pr is failing some critical tests (video assets can be played).
I will be happy to provide a second review once those tests are passing.

I've just checked which tests have been failed and they seem to be unrelated to the contents of this PR.

Any chance that someone could restart the Mac_arm64 ios_platform_tests_shard_1 master and see if it fixes the issue?

Thanks!

I've already re-ran in a couple times to make sure. You're certain the changes you made couldn't have affected those tests?

@vmalyi
Copy link
Author

vmalyi commented May 3, 2023

Sorry, I can't invest time now to investigate the reason behind the failing tests.

@vmalyi vmalyi closed this May 3, 2023
@willsmanley
Copy link

anybody have context on the updated status of this fix? thank you for putting this work in so far

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants