我想开发app以.mp3格式录制音频。它必须录制语音电话,会议等。
我搜索并找到了几个用于android的示例代码,仅用于录制单曲(麦克风)。如何录制来自麦克风和扬声器的声音(如果是语音通话)。我怎样才能在ios和windows中实现这一目标?
以下是我在Android中尝试过的内容。这可以工作并创建.mp3文件,但有任何记录语音通话的帮助吗?
string path = "/sdcard/test.mp3";
MediaRecorder _recorder = new MediaRecorder();
_recorder.SetOutputFormat(OutputFormat.Mpeg4);
_recorder.SetAudioEncoder(AudioEncoder.Aac);
_recorder.SetAudioSamplingRate(44100);
_recorder.SetAudioEncodingBitRate(8000);
_recorder.SetOutputFile(path);
_recorder.Prepare();
_recorder.Start();
iOS代码(创建文件但不播放或无法正确创建文件):
// Declare string for application temp path and tack on the file extension
string fileName = string.Format("Myfile{0}.aac", DateTime.Now.ToString("yyyyMMddHHmmss"));
string tempRecording = Path.Combine(Path.GetTempPath(), fileName);
Console.WriteLine(tempRecording);
this.audioFilePath = NSUrl.FromFilename(tempRecording);
//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),
NSNumber.FromInt32((int)AudioToolbox.AudioFormatType.MPEG4AAC),
NSNumber.FromInt32(1),
NSNumber.FromInt32((int)AVAudioQuality.High)
};
//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.AVEncoderAudioQualityKey
};
//Set Settings with the Values and Keys to create the NSDictionary
settings = NSDictionary.FromObjectsAndKeys(values, keys);
//Set recorder parameters
NSError error;
recorder = AVAudioRecorder.Create(this.audioFilePath, new AudioSettings(settings), out error);
在ios和android上以.mp3格式录制语音电话的任何帮助。或者在iOS中录制简单的.mp3文件以启动。
我还想知道我是否在android和iOS中获得了SamplingRate,BitRate,AudioEncoder的列表?