Capturing sound from a TV card using C #

I wrote a WPF application that captures the display and sound from a TV card using C # code. I can get the display from the TV card, but I can not get the sound from the TV card. BTW, I am using the .NET framework 3.5 with Visual Studio 2010. My question is: how can I get sound from a TV card?

Finally, I tried something like below using the DirectX DirectSound library. However, I received the following errors.

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

the 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 = 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); } 
+6
source share
2 answers

Try the following:

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

The soundDevice.SetCooperativeLevel(...) call soundDevice.SetCooperativeLevel(...) control to be the first parameter, and you try to give it a WPF window (which is not a winforms control).

0
source

Source: https://habr.com/ru/post/896402/


All Articles