-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[video_player] Remove KVO observer on AVPlayerItem on iOS #4683
Conversation
| - (void)testPlugin { | ||
| FLTVideoPlayerPlugin *plugin = [[FLTVideoPlayerPlugin alloc] init]; | ||
| XCTAssertNotNil(plugin); | ||
| } |
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 smoke test is no longer needed, the other tests also validate plugin instantiation.
| @property(nonatomic, readonly) BOOL disposed; | ||
| @property(nonatomic, readonly) BOOL isPlaying; | ||
| @property(nonatomic) BOOL isLooping; | ||
| @property(nonatomic, readonly) BOOL isInitialized; |
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.
BOOL
| - (void)play; | ||
| - (void)pause; | ||
| - (void)setIsLooping:(bool)isLooping; | ||
| - (void)updatePlayingState; |
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.
No need to declare methods in the interface when the methods are only used within the class.
| _isInitialized = false; | ||
| _isPlaying = false; | ||
| _disposed = false; |
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.
No need to set ivars to false in init. Should be NO anyway.
| [currentItem removeObserver:self forKeyPath:@"presentationSize"]; | ||
| [currentItem removeObserver:self forKeyPath:@"duration"]; |
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.
These two lines are the actual fix.
| @property(readonly, weak, nonatomic) NSObject<FlutterBinaryMessenger>* messenger; | ||
| @property(readonly, strong, nonatomic) NSMutableDictionary* players; | ||
| @property(readonly, strong, nonatomic) | ||
| NSMutableDictionary<NSNumber*, FLTVideoPlayer*>* playersByTextureId; |
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.
Lightweight generic, rename to indicate the key is the textureId.
| [self.playersByTextureId | ||
| enumerateKeysAndObjectsUsingBlock:^(NSNumber* textureId, FLTVideoPlayer* player, BOOL* stop) { | ||
| [self.registry unregisterTexture:textureId.unsignedIntegerValue]; |
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.
Use enumerateKeysAndObjectsUsingBlock instead of looking up the value inside the key loop.
| [player seekTo:[input.position intValue]]; | ||
| [_registry textureFrameAvailable:input.textureId.intValue]; | ||
| FLTVideoPlayer* player = self.playersByTextureId[input.textureId]; | ||
| [player seekTo:input.position.intValue]; |
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 didn't scrub this file for dot notation, just updated a few spots where it's inconsistent within the same line.
| return degrees + 360; | ||
| } | ||
| // Output degrees in between [0, 360[ | ||
| // Output degrees in between [0, 360] |
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.
Typo.
bb43277 to
fd76289
Compare
cyanglaz
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.
LGTM! Thanks for the clean-ups
| @@ -1,3 +1,7 @@ | |||
| ## 2.2.14 | |||
|
|
|||
| * Remove KVO observer on AVPlayerItem on iOS. | |||
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.
Nit: Removes
(Per the new CHANGELOG style guide for the repo)
In #4438 the
AVPlayerItempresentationSizeanddurationproperties are KVO observed, but the observation was not removed when the texture is disposed. Remove the observer.Also clean up a few things in the plugin, like using
BOOLinstead ofbool, lightweight generics, renameplayersdictionary to the more descriptiveplayersByTextureId, preferNS_INLINEtostatic inline.Fixes flutter/flutter#96849
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.