【问题标题】:stream a .caf audio file from server从服务器流式传输 .caf 音频文件
【发布时间】:2013-07-22 11:02:41
【问题描述】:

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

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

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

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

我的问题是:.caf 文件可以支持流式传输吗?如果不是,那么我需要以哪种格式转换支持流式传输的录制文件?

【问题讨论】:

    标签: ios objective-c audio audio-recording avplayer


    【解决方案1】:

    AVAudioSession中使用此设置

    使用 .mp4 播放音频双方:

         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]; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-15
      • 1970-01-01
      • 2013-05-11
      • 1970-01-01
      • 2010-09-27
      • 2010-10-17
      • 1970-01-01
      • 2012-01-24
      相关资源
      最近更新 更多