开发者

Capturing sound from TV Card with C#

开发者 https://www.devze.com 2023-04-01 15:51 出处:网络
I have written a WPF application which is capturing display and sound from TV Card from with through C# code. I can get the display from TV card, but I can\'t get any sound from TV Card. BTW, I\'m usi

I have written a WPF application which is capturing display and sound from TV Card from with through C# code. I can get the display from TV card, but I can't get any sound from TV Card. BTW, I'm using .NET framework 3.5 with Visual Studio 2010. My question is how can I get the sound from the TV card?

Lastly, I tried anything like below by using DirectSound library of DirectX. However, I got the following errors.

  1. The best overloaded method match for 'Microsoft.DirectX.DirectSound.Device.SetCooperativeLevel(System.Windows.Forms.Control, Microsoft.DirectX.DirectSound.CooperativeLevel)' has some invalid arguments.
  2. Argument 1: cannot convert from 'Wpfvideo.MainWindow' to 'System.Windows.Forms.Control'

Code:

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 = 开发者_如何学JAVAnew 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);
} 


Try this:

var windowInteropHelper = new WindowInteropHelper(this);
soundDevice = new DS.Device();
soundDevice.SetCooperativeLevel(windowInteropHelper.Handle, CooperativeLevel.Priority);


The call to soundDevice.SetCooperativeLevel(...) is expecting a winforms control as it's first parameter, and you're trying to give it a WPF window (which is not a winforms control).

0

精彩评论

暂无评论...
验证码 换一张
取 消