xamarin.ios 录音并播放
来源:互联网 发布:蓝格眼镜软件 编辑:程序博客网 时间:2024/06/05 04:28
【广告】168vpn 翻墙神器。多多支持
AVAudioRecorder recorder;
NSError error = new NSError(new NSString("com.xamarin"), 1);NSUrl url;
NSDictionary settings;
var audioSession = AVAudioSession.SharedInstance ();
var err = audioSession.SetCategory (AVAudioSessionCategory.PlayAndRecord);
if(err != null) {
Console.WriteLine ("audioSession: {0}", err);
return ;
}
err = audioSession.SetActive (true);
if(err != null ){
Console.WriteLine ("audioSession: {0}", err);
return ;
}
//Declare string for application temp path and tack on the file extension
string audioFilePath = Path.Combine (Path.GetTempPath (), "bin.wav");
Console.WriteLine("Audio File Path: " + audioFilePath);
url = NSUrl.FromFilename(audioFilePath);
//set up the NSObject Array of values that will be combined with the keys to make the NSDictionary
NSObject[] values = new NSObject[]
{
NSNumber.FromFloat (44100.0f), //Sample Rate
NSNumber.FromInt32 ((int)AudioToolbox.AudioFormatType.LinearPCM), //AVFormat
NSNumber.FromInt32 (2), //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);
//Set Recorder to Prepare To Record
recorder.PrepareToRecord();
btn.TouchUpInside +=async (sender, e) => {
recorder.PrepareToRecord();
recorder.Record();
};
btn2.TouchUpInside +=async (sender, e) => {
recorder.Stop();
AVAudioPlayer pla=AVAudioPlayer.FromUrl(url);
pla.Play();
};
0 0
- xamarin.ios 录音并播放
- iOS 录音,播放并上传
- iOS 录音并播放,使用AFN发送文件
- ios 录音播放问题
- iOS录音和播放
- iOS录音和播放
- ios录音与播放
- IOS 录音与播放
- ios 录音,播放 tips
- iOS录音播放
- ios之录音+播放
- 用Java录音并播放
- android录音播放并上传
- iOS 实时录音和播放
- android进行录音功能并保存播放
- 使用AVFoundation来录音并播放
- ios 同时录音和播放问题
- ios中同时录音和播放
- OpenCV画HSV的3D直方图 cvQueryHistValue_3D
- list中按照指定属性的值序列化
- spring集成httpclient调用远端接口
- pip命令报错 Bad md5 hash for package xxx
- 计算hashCode的常见方法
- xamarin.ios 录音并播放
- html中的checkbox复选框不确定状态的设置
- The Contents.json describing the image set "BG_Email_Textfield.imageset" must start with a top level
- 面试题43:n个骰子的点数
- java练习
- linux常用命令----查看日志和系统资源占用
- SoundTouch音频处理库源码分析及算法提取(7)
- 程序员能力矩阵 — 敢测吗?看自己在哪个档次
- 小胖说事6------iOS setNeedsDisplay和setNeedsLayout的用法