AVAudioRecorder 및 AVAudioPlayer를 사용하여 오디오를 녹음하고 재생하는 응용 프로그램에서 전화가 걸려 올 경우 시나리오를 보았습니다. 녹음이 진행 중이고 전화가 오면 오디오 전화 통화 후에 녹음 된 녹음은 전화 통화 이전에 녹음 된 오디오의 계속됨을 원합니다.AVAudioRecorder는 중단 후 오디오 만 녹음합니다.
난 인터럽트가 AVAudioRecorderDelegate 방법
를 이용하여 오디오 레코더에 발생하는 추적- (공극) audioRecorderBeginInterruption (AVAudioRecorder *) avRecorder 및
- (공극) audioRecorderEndInterruption (AVAudioRecorder *) avRecorder.
내 EndInterruption 메서드에서 나는 audioSession을 활성화합니다. 여기
내가 같은 문제가 말하고 다른 링크 how to resume recording after interruption occured in iphone? 및 http://www.iphonedevsdk.com/forum/iphone-sdk-development/31268-avaudiorecorderdelegate-interruption.html 건너 온이 문제에 대한 해결책을 찾고있는 동안 내가- (void)startRecordingProcess
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
if(err)
{
DEBUG_LOG(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
return;
}
[audioSession setActive:YES error:&err];
err = nil;
if(err)
{
DEBUG_LOG(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
return;
}
// Record settings for recording the audio
recordSetting = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatMPEG4AAC],AVFormatIDKey,
[NSNumber numberWithInt:44100],AVSampleRateKey,
[NSNumber numberWithInt: 2],AVNumberOfChannelsKey,
[NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
nil];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:recorderFilePath];
if (fileExists)
{
BOOL appendingFileExists =
[[NSFileManager defaultManager] fileExistsAtPath:appendingFilePath];
if (appendingFileExists)
{
[[NSFileManager defaultManager]removeItemAtPath:appendingFilePath error:nil];
}
if (appendingFilePath)
{
[appendingFilePath release];
appendingFilePath = nil;
}
appendingFilePath = [[NSString alloc]initWithFormat:@"%@/AppendedAudio.m4a", DOCUMENTS_FOLDER];
fileUrl = [NSURL fileURLWithPath:appendingFilePath];
}
else
{
isFirstTime = YES;
if (recorderFilePath)
{
DEBUG_LOG(@"Testing 2");
[recorderFilePath release];
recorderFilePath = nil;
}
DEBUG_LOG(@"Testing 3");
recorderFilePath = [[NSString alloc]initWithFormat:@"%@/RecordedAudio.m4a", DOCUMENTS_FOLDER];
fileUrl = [NSURL fileURLWithPath:recorderFilePath];
}
err = nil;
recorder = [[recorder initWithURL:fileUrl settings:recordSetting error:&err]retain];
if(!recorder)
{
DEBUG_LOG(@"recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
[[AlertFunctions sharedInstance] showMessageWithTitle:kAppName
message:[err localizedDescription]
delegate:nil
cancelButtonTitle:@"Ok"];
return;
}
//prepare to record
[recorder setDelegate:self];
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
[recorder record];
}
를 사용하는 레코딩 코드입니다. 해당 링크에서 제공되었지만 성공적이지 못한 제안을 시도했습니다. AVAudioRecorder 자체에서 작동하도록하고 싶습니다. 이 문제에 대한 해결책을 찾을 수있는 방법이 있습니까? 모든 유용한 제안에 감사드립니다.
게시 하시겠습니까? 두 파일을 어떻게 합치시겠습니까? –
두 파일을 적절히 사용하여 AV 구성을 만들 수 있습니다. 다음 링크에는 http://stackoverflow.com/questions/7775040/play-avmutablecomposition-with-avplayer를 수행하는 방법에 대한 샘플 코드가 있습니다. 그런 다음 AVAssetExportSession을 사용하여 컴포지션을 단일 오디오 파일로 내보낼 수 있습니다. 이 링크를 통해 이동하십시오 http://stackoverflow.com/questions/8019033/avassetexportsession-not-working-in-ios5/9767681#9767681. 희망이 당신의 문제를 해결합니다. – Siddharth