|  | @@ -22,10 +22,6 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @property (nonatomic, assign) BOOL hasFreeObserver;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -@property (nonatomic, assign) BOOL isSeekInProgress;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -@property (nonatomic, assign) CMTime chaseTime;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  @end
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @implementation kSNewPlayer
 | 
	
	
		
			
				|  | @@ -119,6 +115,8 @@
 | 
	
		
			
				|  |  |          [self addTimeObserve];
 | 
	
		
			
				|  |  |          //添加播放完成的通知
 | 
	
		
			
				|  |  |          [self addPlayToEndObserver];
 | 
	
		
			
				|  |  | +        // 添加异常通知
 | 
	
		
			
				|  |  | +        [self addExceptionObserver];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  - (void)configPlayerRate:(CGFloat)rate {
 | 
	
	
		
			
				|  | @@ -249,23 +247,25 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  -(void)addTimeObserve
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | -    __block typeof(self) bself = self;
 | 
	
		
			
				|  |  | +//    __block typeof(self) bself = self;
 | 
	
		
			
				|  |  | +    @weakObj(self);
 | 
	
		
			
				|  |  |      _timeObserver = [_player addPeriodicTimeObserverForInterval:CMTimeMake(1, 100) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
 | 
	
		
			
				|  |  | +        @strongObj(self);
 | 
	
		
			
				|  |  |          //设置player的声音
 | 
	
		
			
				|  |  | -        //        [bself setPlayerVolume];
 | 
	
		
			
				|  |  | +        //        [self setPlayerVolume];
 | 
	
		
			
				|  |  |          //当前时间
 | 
	
		
			
				|  |  |          float current = CMTimeGetSeconds(time);
 | 
	
		
			
				|  |  |          //总共时间
 | 
	
		
			
				|  |  | -        float total = CMTimeGetSeconds(bself.player.currentItem.asset.duration);
 | 
	
		
			
				|  |  | +        float total = CMTimeGetSeconds(self.player.currentItem.asset.duration);
 | 
	
		
			
				|  |  |          //进度
 | 
	
		
			
				|  |  |          float progress = current/total;
 | 
	
		
			
				|  |  |          //将值传入知道delegate方法中
 | 
	
		
			
				|  |  |          //        NSLog(@"--current %f -- total %f -----%f", current, total, progress);
 | 
	
		
			
				|  |  | -        if (bself.delegate && [bself.delegate respondsToSelector:@selector(getSongCurrentTime:andTotalTime:andProgress:currentInterval:playTime:inPlayer:)]) {
 | 
	
		
			
				|  |  | +        if (self.delegate && [self.delegate respondsToSelector:@selector(getSongCurrentTime:andTotalTime:andProgress:currentInterval:playTime:inPlayer:)]) {
 | 
	
		
			
				|  |  |              NSDate *date = [NSDate date];
 | 
	
		
			
				|  |  |              NSTimeInterval inteveral = [date timeIntervalSince1970];
 | 
	
		
			
				|  |  |              //            NSLog(@"----- start play %f", inteveral * 1000);
 | 
	
		
			
				|  |  | -            [bself.delegate getSongCurrentTime:current*1000  andTotalTime:total*1000 andProgress:progress currentInterval:inteveral playTime:current*1000 inPlayer:bself];
 | 
	
		
			
				|  |  | +            [self.delegate getSongCurrentTime:current*1000  andTotalTime:total*1000 andProgress:progress currentInterval:inteveral playTime:current*1000 inPlayer:self];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }];
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -376,6 +376,23 @@
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:_songItem];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +#pragma mark ---- 异常通知
 | 
	
		
			
				|  |  | +- (void)addExceptionObserver {
 | 
	
		
			
				|  |  | +    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerError:) name:AVPlayerItemFailedToPlayToEndTimeNotification object:_songItem];
 | 
	
		
			
				|  |  | +    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerError:) name:AVPlayerItemPlaybackStalledNotification object:_songItem];
 | 
	
		
			
				|  |  | +    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerError:) name:AVPlayerItemPlaybackStalledNotification object:_songItem];
 | 
	
		
			
				|  |  | +    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerError:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
 | 
	
		
			
				|  |  | +    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerError:) name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +-(void)playerError:(NSNotification *)notice {
 | 
	
		
			
				|  |  | +    //移除所有监听
 | 
	
		
			
				|  |  | +    dispatch_main_sync_safe(^{
 | 
	
		
			
				|  |  | +        if ([self.delegate respondsToSelector:@selector(playerDidError:)]) {
 | 
	
		
			
				|  |  | +            [self.delegate playerDidError:self];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #pragma mark---通知的方法
 | 
	
		
			
				|  |  |  -(void)playFinished:(NSNotification *)notice
 |