Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.1+5

* [iOS] Fixed a memory leak in the video player plugin.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* [iOS] Fixed a memory leak in the video player plugin.
* [iOS] Fixed a memory leak with notification observing.


## 0.10.1+4

* Fixed syntax error in README.md.
Expand Down
31 changes: 17 additions & 14 deletions packages/video_player/ios/Classes/VideoPlayerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,23 @@ - (void)addObservers:(AVPlayerItem*)item {
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:playbackBufferFullContext];

[[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemDidPlayToEndTimeNotification
object:[_player currentItem]
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification* note) {
if (self->_isLooping) {
AVPlayerItem* p = [note object];
[p seekToTime:kCMTimeZero
completionHandler:nil];
} else {
if (self->_eventSink) {
self->_eventSink(@{@"event" : @"completed"});
}
}
}];
// Add an observer that will respond to itemDidPlayToEndTime
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(itemDidPlayToEndTime:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:item];
}

- (void)itemDidPlayToEndTime:(NSNotification*)note {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nits: renaming note -> notification

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure.

AVPlayerItem* p = [note object];
if (self->_isLooping) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nits: Same as below for _eventSink

Suggested change
if (self->_isLooping) {
if (_isLooping) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will update. Thanks for the feedback!

AVPlayerItem* p = [note object];
[p seekToTime:kCMTimeZero completionHandler:nil];
} else {
if (self->_eventSink) {
self->_eventSink(@{@"event" : @"completed"});
}
}
}

static inline CGFloat radiansToDegrees(CGFloat radians) {
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: video_player
description: Flutter plugin for displaying inline video with other Flutter
widgets on Android and iOS.
author: Flutter Team <flutter-dev@googlegroups.com>
version: 0.10.1+4
version: 0.10.1+5
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player

flutter:
Expand Down