我编写了一个WPF应用程序,它通过C#代码从电视卡中捕获显示和声音.我可以从电视卡上看到显示器,但我无法从电视卡中获得任何声音.顺便说一句,我在Visual Studio 2010中使用.NET framework 3.5.我的问题是如何从电视卡中获取声音?
最后,我通过使用DirectX的DirectSound库尝试了类似下面的任何内容.但是,我收到了以下错误.
'Microsoft.DirectX.DirectSound.Device.SetCooperativeLevel(System.Windows.Forms.Control,
Microsoft.DirectX.DirectSound.CooperativeLevel)'有一些无效的参数.'Wpfvideo.MainWindow'为
'System.Windows.Forms.Control'码:
private DS.Device soundDevice;
private SecondaryBuffer buffer;
private ArrayList soundlist = new ArrayList();
private void InitializeSound()
{
soundDevice = new DS.Device();
soundDevice.SetCooperativeLevel(this, CooperativeLevel.Priority);
BufferDescription description = new BufferDescription();
description.ControlEffects = false;
buffer = new SecondaryBuffer(CaptureDeviceName, description, soundDevice);
buffer.Play(0, BufferPlayFlags.Default);
SecondaryBuffer newshotsound = buffer.Clone(soundDevice);
newshotsound.Play(0, BufferPlayFlags.Default);
}
Run Code Online (Sandbox Code Playgroud)
尝试这个:
var windowInteropHelper = new WindowInteropHelper(this);
soundDevice = new DS.Device();
soundDevice.SetCooperativeLevel(windowInteropHelper.Handle, CooperativeLevel.Priority);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1182 次 |
| 最近记录: |