-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[video_player] Initialize player when size and duration become available #4438
Conversation
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.
LGTM with comment nits.
AVPlayerItem* item = (AVPlayerItem*)object; | ||
if (item.status == AVPlayerItemStatusReadyToPlay) { | ||
// When the player item is ready, it still may not have determined its presentation size or | ||
// duration. When these properties are finally set, initialize the player. |
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.
Maybe s/initialize the player/re-check whether it's fully initiailized/. Due to the poor naming of sendInitialized
I thought this would send initialization multiple times, and possibly too early (when only one or the other but not both were set).
The real problem is the method name, but adjusting the comment would help.
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 updated the comment, and the method to setupEventSinkIfReadyToPlay
.
packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m
Outdated
Show resolved
Hide resolved
8330e70
to
c1a7c0d
Compare
* master: [ci.yaml] Main branch support (flutter#4440) [video_player] Initialize player when size and duration become available (flutter#4438) [webview_flutter] Implement zoom enabled for ios and android (flutter#4417) Partial revert of "upgraded usage of BinaryMessenger (flutter#4451)" (flutter#4453)
…ideo_src_on_same_controller * commit '76e84c0679dbab7bfaaaa553b17bb0dbdb9a3c33': (537 commits) [video_player] Initialize player when size and duration become available (flutter#4438) [webview_flutter] Implement zoom enabled for ios and android (flutter#4417) Partial revert of "upgraded usage of BinaryMessenger (flutter#4451)" (flutter#4453) Implement Android WebView api with pigeon (Java portion) (flutter#4441) [in_app_purchase] Update to the latest pkg:json_serializable (flutter#4434) Implement Android WebView api with pigeon (Dart portion) (flutter#4435) upgraded usage of BinaryMessenger (flutter#4451) [flutter_plugin_tools] Fix pubspec-check on Windows (flutter#4428) Use OpenJDK 11 in CI jobs (flutter#4419) [google_sign_in] remove the commented out code in tests (flutter#4442) [webview] Fix typos in the README (flutter#4249) [google_sign_in] add serverAuthCode to GoogleSignInAccount (flutter#4180) [ci] Update macOS Cirrus image to Xcode 13 (flutter#4429) [shared_preferences] Switch to new analysis options (flutter#4384) [flutter_plugin_android_lifecycle] remove placeholder dart file (flutter#4413) [camera] Run iOS methods on UI thread by default (flutter#4140) [ci] Always run all `format` steps (flutter#4427) [flutter_plugin_tools] Fix license-check on Windows (flutter#4425) [google_maps_flutter] Clean Java test, consolidate Marker example. (flutter#4400) [image_picker][android] suppress unchecked warning (flutter#4408) ... # Conflicts: # packages/video_player/video_player/pubspec.yaml # packages/video_player/video_player_web/lib/video_player_web.dart # packages/video_player/video_player_web/pubspec.yaml
Consistently on iOS 15 the
AVPlayerItem.status
isAVPlayerItemStatusReadyToPlay
, but thepresentationSize
is zero.So it falls through here, and there's never another attempt to initialize the video.
plugins/packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m
Lines 326 to 328 in 3f94042
Instead, KVO on
presentationSize
andduration
, thensendInitialized
ifAVPlayerItemStatusReadyToPlay
.From the
presentationSize
docs:duration
:Additionally, update the iOS UI tests to actually play the video, check closed captioning, and adjust playback speed.
Fixes flutter/flutter#91975
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).