我的iOS应用程序,处理audiosession与中断:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(AudioInterrupt:)
name:AVAudioSessionInterruptionNotification
object: NULL];
在AudioInterrupt:
- (void)AudioInterrupt:(NSNotification*)notification
{
NSDictionary *interuptionDict = notification.userInfo;
// get the AVAudioSessionInterruptionTypeKey enum from the dictionary
NSInteger interuptionType = [[interuptionDict valueForKey:AVAudioSessionInterruptionTypeKey] integerValue];
NSNumber* seccondReason = [[notification userInfo] objectForKey:@"AVAudioSessionInterruptionOptionKey"] ;
// decide what to do based on interruption type here...
switch (interuptionType) {
case AVAudioSessionInterruptionTypeBegan:
[[[self pureAudioHandler] audioController] setActive: NO];
NSLog(@"Interruption started");
break;
case AVAudioSessionInterruptionTypeEnded:
NSLog(@"Interruption ended");
break;
}
switch ([seccondReason integerValue]) {
case AVAudioSessionInterruptionOptionShouldResume:
NSLog(@"Resume Audio");
[[[self pureAudioHandler] audioController] configurePlaybackWithSampleRate:44100 numberChannels:2 inputEnabled:NO mixingEnabled:YES];
[[[self pureAudioHandler] audioController] setActive: YES];
break;
default:
break;
}
}
这正常工作与报警和Siri的。 但是,如果,我有没有互联网连接,我按Home键,我得到“Siri的不可用......”。 AVAudioSessionInterruptionTypeBegan被触发。 按两次为homeButton得到回到应用程序,也不AVAudioSessionInterruptionTypeEnded或AVAudioSessionInterruptionOptionShouldResume被激发。 任何变通办法?
与iPad 7.0.3迷你视网膜