저는 AV 오디오 프레임 워크를 사용하여 iPhone에 오디오 파일을 녹음하고 있습니다.객관적인 C (iPhone)로 녹음 된 오디오를 저장하는 방법
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *soundFilePath = [docsDir
stringByAppendingPathComponent:@"sound.caf"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
가 지금은 다른 기능을 가지고 있고 내가 좋아하는 그 기능이 무엇인가에 sound.caf 파일을 보낼 : 여기에 현재 코드
NSData *soundData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:soundFilePath ofType:@"caf"]];
그러나 어떤 이유로 그 위 라인은 0kb 파일을 반환하는 것 같습니다.
을도 아니다 동일한 파일 이름에 개방 파일 포인트 :
이 질문은하지 개발 환경의 엑스 코드에 대해, iOS 및 자사의 API에 대한 것입니다 : 당신은 당신이 새로운 오디오 세션을 시작하는 모두의
먼저 주어진 코드를 사용해보십시오. 그에 따라 제목과 태그를 업데이트하십시오. – Codo
파일의 sound.caf가 프로젝트의 Resources 폴더에 있는지 확인하십시오. – visakh7
안녕하세요, 그렇습니다. 문제가 발견되었습니다. 누구든지 같은 문제가 발생하면 다음 줄을 사용하여 사운드 파일을 가져올 수 있습니다.
audioRecorder.url
– Nomad