This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[video_player] [iOS] Fixed a memory leak in the video player plugin. #1660
Merged
cyanglaz
merged 13 commits into
flutter:master
from
shihchanghsiungsonos:pull-request-2
Jul 29, 2019
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6c5c142
[video_player] [iOS] Fixed a memory leak in the video player plugin.
shihchanghsiungsonos fb7fb82
Fix format issue
shihchanghsiungsonos ef51441
Merge branch 'master' of github.com:flutter/plugins into pull-request-2
shihchanghsiungsonos c7bfc2d
Merge branch 'master' of github.com:flutter/plugins into pull-request-2
shihchanghsiungsonos e822967
[video_player] [iOS] Fixed a memory leak in the video player plugin.
shihchanghsiungsonos cbc1d45
Merge branch 'master' of github.com:flutter/plugins into pull-request-2
shihchanghsiungsonos 16bd875
[video_player] [iOS] Fixed a memory leak in the video player plugin.
shihchanghsiungsonos 348014c
Merge branch 'master' of github.com:flutter/plugins into pull-request-2
shihchanghsiungsonos 7049698
bump version to 0.10.1+5
shihchanghsiungsonos bbf5440
Merge branch 'master' of github.com:flutter/plugins into pull-request-2
shihchanghsiungsonos a9df1ae
Update with cyanglaz's feedback
shihchanghsiungsonos 029be7d
Merge branch 'master' into pull-request-2
01e04c7
Update pubspec.yaml
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ @interface FLTVideoPlayer : NSObject <FlutterTexture, FlutterStreamHandler> | |
| @property(nonatomic, readonly) bool isPlaying; | ||
| @property(nonatomic) bool isLooping; | ||
| @property(nonatomic, readonly) bool isInitialized; | ||
| @property(nonatomic, assign) id notificationObserverId; | ||
| - (instancetype)initWithURL:(NSURL*)url frameUpdater:(FLTFrameUpdater*)frameUpdater; | ||
| - (void)play; | ||
| - (void)pause; | ||
|
|
@@ -82,14 +83,13 @@ - (void)addObservers:(AVPlayerItem*)item { | |
| options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew | ||
| context:playbackBufferFullContext]; | ||
|
|
||
| [[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemDidPlayToEndTimeNotification | ||
| _notificationObserverId = [[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]; | ||
| [p seekToTime:kCMTimeZero]; | ||
|
||
| } else { | ||
| if (self->_eventSink) { | ||
| self->_eventSink(@{@"event" : @"completed"}); | ||
|
|
@@ -395,7 +395,7 @@ - (void)dispose { | |
| forKeyPath:@"playbackBufferFull" | ||
| context:playbackBufferFullContext]; | ||
| [_player replaceCurrentItemWithPlayerItem:nil]; | ||
| [[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
| [[NSNotificationCenter defaultCenter] removeObserver:_notificationObserverId]; | ||
|
||
| [_eventChannel setStreamHandler:nil]; | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 might be cleaner to just use the
addObserver:selfhere since we are just using mainQueue. This way we can separate the observing implementation out of theaddObserversmethod.