user470760
user470760

Reputation:

Controls to use for Video Stream?

I currently have LibVLC setup with a C# project and it uses a Panel to output the video stream. As WPF is better suited for some GUI options I want to implement, I have now switched my project over to it. However, I noticed that WPF Controls don't have handles like C# controls do.

I have found these... http://wpfmediakit.codeplex.com/ http://videorendererelement.codeplex.com

However I am new to WPF and have no idea how to actually integrate them. What would be the best approach to output the video streams from LibVlC in WPF?

Upvotes: 0

Views: 2178

Answers (2)

Fengari
Fengari

Reputation: 483

I'm afraid that's not possible...

Since WPF controls are not Win32 controls behind the scenes (the MS specific HWND or the more general HANDLE), like most WinForms controls are, providing a HANDLE to libvlc for rendering is not possible or not easy.

See here

All WPF elements on the screen are ultimately backed by a HWND. When you create a WPF Window, WPF creates a top-level HWND, and uses an HwndSource to put the Window and its WPF content inside the HWND. The rest of your WPF content in the application shares that singular HWND. An exception is menus, combo box drop downs, and other pop-ups. These elements create their own top-level window, which is why a WPF menu can potentially go past the edge of the window HWND that contains it.

You could try to use a Window and attempt to get its Handle like this:

IntPtr windowHandle = new WindowInteropHelper(windowInstance).Handle

Then pass this handle to libvlc. Remember to obtain this handle no sooner than inside the Loaded event of the window, see here

But this will limit you to using a top level Window control, which doesn't seem to be what you want.

Upvotes: 0

user470760
user470760

Reputation:

I managed to resolve this by using a WindowsFormsHost control and just use a Panel as I was doing previously in my Win Forms application. Still seems that using something else native to WPF would be preferable, but for now this is working fine.

Upvotes: 1

Related Questions