从C#.net中的麦克风进行音频录制 [英] Audio Recording from microphone in C#.net
问题描述
我已经使用C#.Net从麦克风进行了录音.在我的本地系统中,它运行得非常好;记录,保存和播放所有内容.但是在Server中上载时,它正在创建一个文件,并显示44bytes.但是它没有播放,什么都没有,我假设它没有在Server中录制,我的录制代码如下,它将以"wav格式"保存.所以,我很困惑,因为它是录制问题还是扩展名...问题.我在后面的代码中重新编码的代码如下:
I have done audio recording from microphone.. using C#.Net. It was working absolutely fine in my local system; recording, saving and playing all. But when uploaded in Server it is creating a file, and showing 44bytes. But it is not playing, anything, I Suppose it is not recording in Server, my code for recording is as follows and it will be saved in "wav format". So, I am confused as it is recording problem or is it extension... problem. My code for Recoding in code behind is as follows:
protected void Recordbtn_Click(object sender, EventArgs e)
{
try
{
audioCmt.Style["display"] = "block";
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
//Stop.Visible = true;
Savebtn.Visible = true;
Recordbtn.Visible = false;
lblstatus.Visible = true;
}
catch
{
}
}
请帮忙.
在此先感谢您!
Please help.
Thanks in advance!
推荐答案
我不确定您的上述代码是如何从麦克风录制的.记录按钮事件中上面只有有意义的行是:
I am not sure on how your above code is recording from microphone. Only meaningful lines above in record button event are:
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
但是他们看起来并没有做太多!
请查看以下内容:
MSDN:用麦克风录制声音 [
But again they does not look doing much!
Please have a look at the following:
MSDN: Recording Sound with a Microphone[^]
Try!
protected void Button1_Click(object sender, EventArgs e)
{
//Start record
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
}
protected void Button2_Click(object sender, EventArgs e)
{
// stop and save
if (!System.IO.Directory.Exists("d:\\sound"))
System.IO.Directory.CreateDirectory("d:\\sound");
mciSendString("save recsound d:\\sound\\ a.wav", "", 0, 0);
mciSendString("close recsound", "", 0, 0);
Computer c = new Computer();
c.Audio.Stop();
//mciSendString( "pause recsound", "", 0, 0);
}
您正在使用哪个版本的Windows Server?
我记得那只适用于Server 2008(及更高版本),不适用于Server2003.
尝试安装Windows 2003资源工具包已经很久了,它已经解决了这个问题,但是我认为它现在有所帮助,但目前还不确定.
http://www.microsoft.com/download/en/details.aspx?id=17657 [ ^ ]
如果您使用的是Server 2003,我会研究/尝试在2003上运行.
您也可以使用DirectShow.net录制音频.
http://directshownet.sourceforge.net/
问候
Hi,
which version of windows server you''re using?
I''m remembering that''s only working with Server 2008 (and above), not with server 2003.
Try to install Windows 2003 resource toolkit, it''s a long time ago since solving this problem, but I think it helped but not sure at the moment.
http://www.microsoft.com/download/en/details.aspx?id=17657[^]
In case you''re using server 2003, I''ll research/try if it works on 2003.
You could also use DirectShow.net for recording audio.
http://directshownet.sourceforge.net/
Regards
这篇关于从C#.net中的麦克风进行音频录制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!