Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. AForge VideoSourcePlayer

AForge VideoSourcePlayer

Scheduled Pinned Locked Moved WPF
csharpwpfhtmlwinformscom
2 Posts 2 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    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
    
    M 1 Reply Last reply
    0
    • K Kevin Marois

      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
      
      M Offline
      M Offline
      Member_15783521
      wrote on last edited by
      #2

      Adding background as Transparent for WindowsFormsHost worked for me.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups