首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVAudioRecorder总是空的。

AVAudioRecorder总是空的。
EN

Stack Overflow用户
提问于 2015-08-01 18:22:21
回答 1查看 380关注 0票数 2

我一直在尝试用xamarin格式录制音频,没有直接的方法来实现它,所以我试图通过自定义呈现来实现它,并且我遵循了这里的例子。

// AVAudioRecorder创建

代码语言:javascript
复制
        //set up the NSObject Array of values that will be combined with the keys to make the NSDictionary
        NSObject[] values = new NSObject[]
        {
            NSNumber.FromFloat (16000.0f), //Sample Rate
            NSNumber.FromInt32 ((int)AudioToolbox.AudioFormatType.MPEG4AAC), //AVFormat
            NSNumber.FromInt32 (1), //Channels
            NSNumber.FromInt32 (16), //PCMBitDepth  
            NSNumber.FromBoolean (false), //IsBigEndianKey
            NSNumber.FromBoolean (false) //IsFloatKey
        };

        //Set up the NSObject Array of keys that will be combined with the values to make the NSDictionary
        NSObject[] keys = new NSObject[]
        {
            AVAudioSettings.AVSampleRateKey,
            AVAudioSettings.AVFormatIDKey,
            AVAudioSettings.AVNumberOfChannelsKey,
            AVAudioSettings.AVLinearPCMBitDepthKey,
            AVAudioSettings.AVLinearPCMIsBigEndianKey,
            AVAudioSettings.AVLinearPCMIsFloatKey
        };

        //Set Settings with the Values and Keys to create the NSDictionary
        settings = NSDictionary.FromObjectsAndKeys (values, keys);

        //Set recorder parameters
        recorder = AVAudioRecorder.Create(url, new AudioSettings(settings), out error);

但是,在代码中,“记录器=AVAudioRecorder.Create”(url,新AudioSettings(设置),out错误);始终为空

任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-02 08:50:44

我自己修复了它,通过更改音频设置使其工作如下

代码语言:javascript
复制
    `var settings = new AudioSettings
        {
            SampleRate = 44100.0f,
            Format = AudioFormatType.LinearPCM,
            NumberChannels = 1,
            LinearPcmBitDepth = 16,
            AudioQuality = AVAudioQuality.High,
        };`
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31764817

复制
相关文章

相似问题

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