110,538
社区成员
发帖
与我相关
我的任务
分享
public void InitVoice()
{//初始化声音相关设置:(1)捕捉缓冲区(2)播放缓冲区
//if (!CreateCaputerDevice())
//{
// throw new Exception();
//}//建立设备对象
try
{
if(!CreateCaputerDevice())
{
throw new Exception("找不到设备");
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
CreateCaptureBuffer();//建立缓冲区对象
CreateNotification();//设置通知及事件
//======(2)==============
if (!CreatePlayDevice())
{
throw new Exception();
}
CreateSecondaryBuffer();
}
private bool CreateCaputerDevice()
{
System.Windows.Forms.MessageBox.Show("当前没有可用于音频捕捉的设备", "系统提示");
//首先要玫举可用的捕捉设备
CaptureDevicesCollection capturedev = new CaptureDevicesCollection();
Guid devguid;
if (capturedev.Count > 0)
{
devguid = capturedev[0].DriverGuid;
}
else
{
//System.Windows.Forms.MessageBox.Show("当前没有可用于音频捕捉的设备", "系统提示");
return false;
}
//利用设备GUID来建立一个捕捉设备对象
capture = new Capture(devguid);
return true;
}
第一个if那里出问题了, CreateCaputerDevice没执行,不知道为什么