首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从服务器流.caf音频文件

从服务器流.caf音频文件
EN

Stack Overflow用户
提问于 2013-07-22 11:02:41
回答 1查看 488关注 0票数 0

我正在做一个项目,在这个项目中,我录制声音并上传到服务器上。上传的文件格式是.caf (核心音频格式)

现在,当我尝试使用从服务器使用AVPLayer播放这个文件时,它在下面给出了错误消息。

Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo=0x2f31e0 {NSLocalizedRecoverySuggestion=Try again later., NSLocalizedDescription=Cannot Complete Action}

我已经检查了服务器上的文件,它没有损坏。

我的问题是:.caf文件能够支持流吗?如果没有,那么我需要以哪种格式转换支持流的录制文件?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-22 11:11:07

AVAudioSession中使用此设置

使用.mp4播放音频双方:

代码语言:javascript
复制
     AVAudioSession * audioSession = [AVAudioSession sharedInstance];
                [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];
                [audioSession setActive:YES error: &error];

                NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
                [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
                [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
                [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];

                NSURL *recordedTmpFile = [NSURL fileURLWithPath:yourdirectorypath];
                //file=[NSString stringWithFormat:@"%@",recordedTmpFile];
                NSLog(@" filr url%@",recordedTmpFile);
               // NSLog(@" filr url%@",file);
                recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
                [recorder setDelegate:self];
                [recorder prepareToRecord];
                [recorder record];

 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; 
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17785925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档