0
AVRecorder와 AVPlayer를 많이 사용하고 있습니다. 나는 둘 다, 내 애플에 돌아 왔을 때, 그녀가 백그라운드에있을 때까지 기다렸다가, 예를 들어 내가 기록하려고한다면, 시작하기까지 4 초가 걸린다.배경 모드에서 돌아올 때 AVRecorder가 지연됩니까?
내 코드에서 녹음하기 전에 전에 을 녹음 할 준비가되어 있습니다.하지만 앱으로 돌아 가면 도움이되지 않습니다.
개선하기 위해 무엇을 할 수 있습니까?
이는 (배경에서하지 않을 경우 다시, 시작에!) 응용 프로그램이 열려있을 때 이루어집니다
-(void)prepareToRecord
{
NSArray *dirPaths;
NSString *docsDir;
NSString *sound=[NSString stringWithFormat:@"sound%d.caf",[memoryInstnace getNextFreePlace]];
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ;
docsDir = [dirPaths objectAtIndex:0];
currentSoundFilePath = [docsDir stringByAppendingPathComponent:sound];
NSURL *soundFileURL = [NSURL fileURLWithPath:currentSoundFilePath];
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
nil];
NSError *error;
recorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:settings error:&error];
//to not having a delay befor record
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil];
if (recorder)
{
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
}
else
NSLog(@"error in recordings" );
}
감사합니다!