-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[video_player] Fix playback speed resetting on iOS #4331
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
@googlebot I fixed it! |
…copy of playback speed setting it on player to preserve value
b64345d to
3d62e8e
Compare
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Comments inline, but this will also need tests (and a version update), per the checklist and contribution guide.
packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m
Outdated
Show resolved
Hide resolved
| [_player play]; | ||
|
|
||
| // fix to always set playback speed accurately | ||
| [self setPlaybackSpeed:_internalPlaybackSpeed]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always needed here? My impression from comments in the issue was that calling it from the completion handler of the seek method would likely be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuartmorgan which completion handler are you referring to? I only see a seekTo method in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuartmorgan I see. I tried moving the call inside the completionHandler block of the seekTo method as follows:
[_player seekToTime:CMTimeMake(location, 1000)
toleranceBefore:kCMTimeZero
toleranceAfter:kCMTimeZero
completionHandler:^(BOOL finished) {
[self setPlaybackSpeed:_internalPlaybackSpeed];
}];
but the issue of the playback speed resetting to 1.0 came back. Therefore that is not equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. So presumably then it's the playbackLikelyToKeepUpContext and/or AVPlayerItemStatusReadyToPlay codepath that's resolving this? In which case perhaps the underlying issue is that AVPlayer automatically resets the playback speed when the buffer is insufficient.
packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m
Outdated
Show resolved
Hide resolved
96e69d4 to
3d62e8e
Compare
|
@stuartmorgan / @creativecreatorormaybenot I've realized that while this modification fixes the playback speed issue it causes a negative side-effect. When an unbuffered range of the video stream is played back, the video player can lose volume (go mute) and become unstable. Once it gets in this state it does not recover. Therefore looks like there's still more work, unfortunately. |
Does setting it back only for
It is very likely that your approach would racily have the same behavior. There's no guarantee that some fraction of 500ms is enough time to create sufficient buffer to avoid an overrun. |
|
@creativecreatorormaybenot you are correct your PR does fix this issue on the iOS platform and does not add any of the negative side-effects the native fix above introduced. I played around for a bit but didn't come up with a native-only solution here. For now I've added your code to my fork so we can patch this issue for users. |
|
@alexagat yeah, that is what we are also doing in production, using our own fork of the plugin. |
|
If there's no way to automatically handle this in the plugin that doesn't have the potential to cause playback issues, the other option would be to add an event that would report playback speed changes back to the Dart side, so that UIs could update, and users could change it back themselves. But I would expect that there's a way to determine the relevant state to handle this correctly. Does observing |
|
@stuartmorgan I have one concern with this part:
You were saying that my fix was a hack. But your proposal is not? If I look at this from a different perspective, this means that users of the problem would need to integrate the hack (changing the playback speed after the change has been reported to the Dart side).
That would be my preferred choice as well.. |
There are two possibilities here:
Your PR was sort of attempting to do 1, but in a very hacky way. I'm saying that either we need to do 1 correctly, or if 1 is impossible we should do 2. If 2 is the only option it's not a hack, it a reflection of the limitations of the platform that the plugin is wrapping. |
|
@alexagat Are you still planning on updating this PR based on the discussion above? |
|
@stuartmorgan I am not planning to update this PR and it should probably be closed. I never got the iOS implementation to work as desired and ended up using the code change from #3404 to resolve the bug. |
|
Which is why is still think it should be merged 👍 It is not perfect but the best from a cost <> value perspective. |
|
Closing per the above; thanks for the investigation so far. This should serve as a good starting point for future attempts to fix the issue. |
This stabilizes the behavior of the
video_playerpackage such that callingseekTodoes not reset the playback speed to1.0on the iOS platform.List which issues are fixed by this PR. You must list at least one issue.
Pre-launch Checklist
dart format.)[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.