Я внедрил запись звука в своем приложении, но мне нужно знать, как сохранить файл аудиозаписи в каталоге документа и получить тот же файл в другом классе для воспроизведения звука.Как сохранить аудиофайл в iphone в каталоге документов
Адрес источника.
-(void)startPushed
{
NSMutableDictionary *rs = [[NSMutableDictionary alloc] init];
[rs setValue:[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
[rs setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[rs setValue:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
recordedTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%.0f.%@", [NSDate timeIntervalSinceReferenceDate] * 1000.0, @"caf"]]];
recorder = [[AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:rs error:&error];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];
NSArray *docPath = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString *docDir = [docPath objectAtIndex:0];
NSString *fullPath = [docDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", recordedTmpFile]];
NSLog(@"%@", fullPath);
}
-(void)playbackPushed
{
AVAudioPlayer *avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error];
NSLog(@"Play Path:%@", recordedTmpFile);
[avPlayer prepareToPlay];
[avPlayer play];
}
Пожалуйста, скажите мне, как читать и писать аудиофайл (.caf формат) в директории документа , а также предоставить информацию для воспроизведения звука в другом классе.
Заранее спасибо