-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[video_player] Validate size only when assets contain video tracks on iOS #4639
[video_player] Validate size only when assets contain video tracks on iOS #4639
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Seems the duration for audios on iOS will always be |
This comment has been minimized.
This comment has been minimized.
// Due to the duration calculation accurancy between platforms, | ||
// the milliseconds on Web will be a slightly different from natives. | ||
// The audio was made with 44100 Hz, 192 Kbps CBR, and 32 bits. | ||
if (kIsWeb) { |
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.
It's 5.041625 sec. The web takes 5.042
and natives take 5.041
.
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.
I've done some debuggin steps, and the root cause of this difference is from here:
milliseconds: (videoElement.duration * 1000).round(), |
The
videoElement.duration
reports 5.041633
from the engine, and it seems to be the precision issue of the web platform. If we want to make them equal, we might use toInt()
here.
I don't think this actually resolves flutter/flutter#47105 as claimed in the PR description; using I'm conflicted about this PR. The change itself is simple, but adding tests asserting that audio works sets a problematic precedent. What if a new platform we want to support has different APIs for supporting video and audio; are we now saying we require audio support in that implementation too? When there are inevitably new issues or feature requests that are specific to audio, will those all suddenly be valid? I think where I come down on this is that because the mismatch with Android is currently a source of confusion, and the incremental cost is extremely low here, I'm inclined to take this PR, but:
@jmagman Does that sound good to you? |
SGTM |
That's more like it used to be supported implicitly, but someday it becomes invalid. I'll update the above suggestions. If we're targeting flutter/flutter#47015, it actually resolves 2/3, with basic audio playing. I agree with the support range part, then the PR is more like an enhancement (validate size only with video) plus a fix (with more reliable duration obtain). |
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.
This LGTM with comment nit.
By adding a more specific type check, we can expand the support range of the video_player on iOS from videos to all supported media types. This is from the documentation of
AVSimplePlayer
: AVSimplePlayer/AVSPDocument.m#139Resolves flutter/flutter#38480, flutter/flutter#90429, or more issues related to iOS audio playing.
Related to flutter/flutter#47105, flutter/flutter#75636.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).