Permalink
Browse files

Merge branch 'master' of github.com:blommegard/HSPlayer

  • Loading branch information...
2 parents 567e305 + e81ffa4 commit 6f4bb5215dd1f30a71d3fcdba46e3a7bcf3a84d1 @blommegard committed Jan 31, 2012
Showing with 20 additions and 1 deletion.
  1. +0 −1 HSPlayer/HSPlayer-Prefix.pch
  2. +2 −0 HSPlayer/HSPlayerView.h
  3. +18 −0 HSPlayer/HSPlayerView.m
@@ -11,5 +11,4 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
- #import <AVFoundation/AVFoundation.h>
#endif
@@ -11,6 +11,8 @@
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
+@class AVPlayer, AVPlayerLayer;
+
@interface HSPlayerView : UIView
@property (nonatomic, strong, readonly) AVPlayer *player;
/*
@@ -10,6 +10,7 @@
#import "HSSlider.h"
#import <QuartzCore/QuartzCore.h>
#import <MediaPlayer/MediaPlayer.h>
+#import <AVFoundation/AVFoundation.h>
// Constants
CGFloat const HSPlayerViewControlsAnimationDelay = .4; // ~ statusbar fade duration
@@ -235,6 +236,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
@@ -523,6 +535,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) {

0 comments on commit 6f4bb52

Please sign in to comment.