어떻게 해결 했나요?
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleAudioSessionInterruption:)
name:AVAudioSessionInterruptionNotification
object:[AVAudioSession sharedInstance]];
간섭을 처리하십시오.
-(void)handleAudioSessionInterruption:(NSNotification*)notification
{
//NSLog(@"%@",notification);
NSNumber *interruptionType = [[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey]; //1 Interuption Start, 0 Interuption Ends
NSNumber *interruptionOption = [[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey];
if ([interruptionType integerValue] == AVAudioSessionInterruptionTypeBegan)
{
NSLog(@"Player %d interupted",playerNumber);
// • Audio has stopped, already inactive
// • Change state of UI, etc., to reflect non-playing state
[self.playPauseButton setTitle:@">" forState:UIControlStateNormal];
self.playingAudio = NO;
return;
}
if ([interruptionType integerValue] == AVAudioSessionInterruptionTypeEnded)
{
if ([interruptionOption integerValue] == AVAudioSessionInterruptionOptionShouldResume)
{
NSLog(@"Player %d Resume",playerNumber);
[self.playPauseButton setTitle:@"||" forState:UIControlStateNormal];
self.playingAudio = YES;
NSError *error = nil;
AVAudioSession *aSession = [AVAudioSession sharedInstance];
[aSession setMode:AVAudioSessionModeDefault error:&error]; //& means value at address
[aSession setCategory:AVAudioSessionCategoryPlayback error:&error];
//[aSession setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&error];
//[aSession setMode:AVAudioSessionModeSpokenAudio error:&error];
[aSession setActive: YES error: &error];
[self.audioPlayer play];
}
// • Make session active
// • Update user interface
// • AVAudioSessionInterruptionOptionShouldResume option
}
카메라는 어떻게 열 립니 까? – rmaddy
슬라이드 업 제어판을 사용하면 어떻게 해오 고 있습니다. – Aaronium112
이로 인해 앱이 백그라운드로 이동합니다. 난 그냥 그것을 테스트하고 적절한 애플 리케이션 대리자 메서드가 호출됩니다. – rmaddy