나는 이것에 대해 Cocos2D-iPhone.org 포럼에서 시끄러운 것을 발견했습니다. 나는 그것을 완전히 이해하지 못하고 있지만, 나는 그것에 대해 연구 중이다. 적어도 일시적으로 문제를 해결하는 것처럼 보였다. 링크 여기
[AVAudioSession sharedInstance];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interruption:) name:AVAudioSessionInterruptionNotification object:nil];
것 : http://www.cocos2d-iphone.org/forum/topic/49956
을
-(void) releaseBufferForFile:(NSString *) filePath {
int bufferId = [self bufferForFile:filePath create:NO];
if (bufferId != kCDNoBuffer) {
[soundEngine unloadBuffer:bufferId];
[loadedBuffers removeObjectForKey:filePath];
NSNumber *freedBufferId = [[NSNumber alloc] initWithInt:bufferId];
[freedBufferId autorelease];
[freedBuffers addObject:freedBufferId];
}
}
@end
- (void) interruption:(NSNotification*)notification
{
NSDictionary *interuptionDict = notification.userInfo;
NSNumber* interuptionTypeValue = [dict valueForKey:AVAudioSessionInterruptionTypeKey];
NSUInteger interuptionType = [interuptionTypeValue intValue];
if (interuptionType == AVAudioSessionInterruptionTypeBegan)
[self beginInterruption];
#if __CC_PLATFORM_IOS >= 40000
else if (interuptionType == AVAudioSessionInterruptionTypeEnded)
[self endInterruptionWithFlags:(NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionOptionKey]];
#else
else if (interuptionType == AVAudioSessionInterruptionTypeEnded)
[self endInterruption];
#endif
}
그런 다음 그는 대체 :이와
AVAudioSession *session = [AVAudioSession sharedInstance];
session.delegate = self;
그가했던 것은 CDAudioManger.m 파일에서이 방법을 쓰기이었다
이 코드의 기능을 더 잘 이해할 수있게되면 t를 편집해야합니다. 그의 게시물.
'이유는 무엇입니까?' – Jonny
Apple은 iOS 6에서 위임자와 AVAudioSessionDelegate 프로토콜을 설정하지 않으므로 대신 NSNotification 센터를 통해 알림을 청취해야합니다. – geekinit
이 답변은 불완전한 것으로 보입니다. –