私のアプリケーションでは、AVAudioRecorderとAVAudioPlayerを使用して音声を録音し再生するアプリケーションでは、着信時にシナリオが発生しました。録音が進行中で、通話後に録音された録音は、通話後に録音された録音が、通話前に録音された音声の継続であることが必要です。AVAudioRecorderは中断後の音声のみを記録します
私はAVAudioRecorderDelegate方法
- を使用してオーディオレコーダーにoccuring中断(無効)audioRecorderBeginInterruption追跡:(AVAudioRecorder *)avRecorder: と
- (無効)audioRecorderEndInterruption avRecorder(AVAudioRecorder *)を。
私の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自体で動作させることを望みます。 この問題の解決方法はありますか? 貴重なご意見をいただければ幸いです。
両方のファイルにどのように参加していますか投稿してください。 –
2つのファイルを適切に使用してAVCompositionを作成することができます。次のリンクには、行う方法のサンプルコードがあります。http://stackoverflow.com/questions/7775040/play-avmutablecomposition-with-avplayerその後、AVAssetExportSessionを使用してコンポジションを1つのオーディオファイルに書き出すことができます。このリンクhttp://stackoverflow.com/questions/8019033/avassetexportsession-not-working-in-ios5/9767681#9767681にアクセスしてください。これがあなたの問題を解決することを願っています。 – Siddharth