我已經寫了一個WPF應用程序,它通過C#代碼從電視卡捕獲顯示和聲音。我可以從電視卡上獲得顯示,但是我無法從電視卡獲得任何聲音。順便說一句,我在Visual Studio 2010中使用.NET framework 3.5。我的問題是如何從電視卡中獲取聲音?從C#的電視卡捕捉聲音#
最後,我使用DirectX的DirectSound庫嘗試了類似下面的任何內容。但是,我得到了以下錯誤。
- 最佳重載的方法匹配
'Microsoft.DirectX.DirectSound.Device.SetCooperativeLevel(System.Windows.Forms.Control, Microsoft.DirectX.DirectSound.CooperativeLevel)'
有一些無效 參數。 - 參數1:不能轉換從
'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);
}
因爲SetCooperativeLevel方法需要一個Windows窗體控件你所得到的錯誤,你是傳遞一個WPF窗口。 –
感謝您的回覆。我該怎麼辦? – Selo
沒有「修復」,你不能把一個wpf窗口變成一個winforms控件。 –