Skip to content

Commit

Permalink
Remove observers.
Browse files Browse the repository at this point in the history
  • Loading branch information
blommegard committed Dec 14, 2011
1 parent 7cee27a commit e81ffa4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions HSPlayer/HSPlayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N

- (void)dealloc {
[self removePlayerTimeObserver];

[self.player removeObserver:self forKeyPath:@"rate"];
[self.player removeObserver:self forKeyPath:@"currentItem"];
[self.playerItem removeObserver:self forKeyPath:@"status"];
[self.playerItem removeObserver:self forKeyPath:@"duration"];
[self.playerLayer removeObserver:self forKeyPath:@"readyForDisplay"];

if ([self.playerItem respondsToSelector:@selector(allowsAirPlayVideo)])
[self.playerItem removeObserver:self forKeyPath:@"airPlayVideoActive"];

[self.player pause];
}

#pragma mark - Properties
Expand Down Expand Up @@ -517,6 +528,12 @@ - (void)doneLoadingAsset:(AVAsset *)asset withKeys:(NSArray *)keys {
options:(NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew)
context:HSPlayerViewPlayerItemStatusObservationContext];

// Durationchange
[self.playerItem addObserver:self
forKeyPath:@"duration"
options:(NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew)
context:HSPlayerViewPlaterItemDurationObservationContext];

[[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemDidPlayToEndTimeNotification
object:self.playerItem
queue:nil usingBlock:^(NSNotification *note) {
Expand Down

0 comments on commit e81ffa4

Please sign in to comment.