AForge VideoSourcePlayer
-
I'm trying to get the [AForge VideoSourcePlayer](http://www.aforgenet.com/framework/docs/html/bd272e5f-344c-56a5-f74f-1ac3062a9554.htm) to work in a WPF app. It's a WinForms control hosted in a WindowsFormsHost. I can't get this to work ina WinForms app either, but I'm targeting WPF in the end. XAML
Code Behind
public partial class MainWindow : Window
{
#region CTOR
public MainWindow()
{
InitializeComponent();this.DataContext = this; videoSourcePlayer.NewFrame += VideoSourcePlayer\_NewFrame; videoSourcePlayer.Height = 320; videoSourcePlayer.Width = 320; } #endregion #region Private Methods private void Connect() { FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDevices.Count == 0) { throw new ApplicationException(); } var selectdDevice = videoDevices\[0\].MonikerString; VideoCaptureDevice videoSource = new VideoCaptureDevice(selectdDevice); OpenVideoSource(videoSource); } private void Disconnect() { if (videoSourcePlayer.VideoSource != null) { videoSourcePlayer.SignalToStop(); videoSourcePlayer.WaitForStop(); } } private void HandleNewFrame(ref Bitmap image) { //TODO: handle this later
-
I'm trying to get the [AForge VideoSourcePlayer](http://www.aforgenet.com/framework/docs/html/bd272e5f-344c-56a5-f74f-1ac3062a9554.htm) to work in a WPF app. It's a WinForms control hosted in a WindowsFormsHost. I can't get this to work ina WinForms app either, but I'm targeting WPF in the end. XAML
Code Behind
public partial class MainWindow : Window
{
#region CTOR
public MainWindow()
{
InitializeComponent();this.DataContext = this; videoSourcePlayer.NewFrame += VideoSourcePlayer\_NewFrame; videoSourcePlayer.Height = 320; videoSourcePlayer.Width = 320; } #endregion #region Private Methods private void Connect() { FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDevices.Count == 0) { throw new ApplicationException(); } var selectdDevice = videoDevices\[0\].MonikerString; VideoCaptureDevice videoSource = new VideoCaptureDevice(selectdDevice); OpenVideoSource(videoSource); } private void Disconnect() { if (videoSourcePlayer.VideoSource != null) { videoSourcePlayer.SignalToStop(); videoSourcePlayer.WaitForStop(); } } private void HandleNewFrame(ref Bitmap image) { //TODO: handle this later
Adding background as Transparent for WindowsFormsHost worked for me.