|
@@ -388,6 +388,13 @@
|
|
|
-(void)playerError:(NSNotification *)notice {
|
|
|
//移除所有监听
|
|
|
dispatch_main_sync_safe(^{
|
|
|
+ if ([notice.name isEqualToString:AVAudioSessionRouteChangeNotification]) {
|
|
|
+ NSDictionary *info = notice.userInfo;
|
|
|
+ AVAudioSessionRouteChangeReason routeChangeReason = [[info valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
|
|
|
+ if (routeChangeReason == AVAudioSessionRouteChangeReasonCategoryChange) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
if ([self.delegate respondsToSelector:@selector(playerDidError:)]) {
|
|
|
[self.delegate playerDidError:self];
|
|
|
}
|
|
@@ -400,6 +407,13 @@
|
|
|
//移除所有监听
|
|
|
_isPlaying = NO;
|
|
|
dispatch_main_sync_safe(^{
|
|
|
+ if ([notice.name isEqualToString:AVAudioSessionRouteChangeNotification]) {
|
|
|
+ NSDictionary *info = notice.userInfo;
|
|
|
+ AVAudioSessionRouteChangeReason routeChangeReason = [[info valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
|
|
|
+ if (routeChangeReason == AVAudioSessionRouteChangeReasonCategoryChange) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
if ([self.delegate respondsToSelector:@selector(playFinished:)]) {
|
|
|
[self.delegate playFinished:self];
|
|
|
}
|