mfkl / LibVLCSharp-readonly

.NET bindings for LibVLC
GNU Lesser General Public License v2.1
9 stars 2 forks source link

WPF sample #19

Open mfkl opened 6 years ago

mfkl commented 6 years ago

Will use this to set the drawable surface. https://github.com/mfkl/LibVLCSharp/blob/783e104b485931de978eee48d6d22a067d220cab/LibVlcSharp/MediaPlayer.cs#L773 May be of interest: https://github.com/prasannavl/WinApi https://msdn.microsoft.com/en-us/library/ms618134 https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/wpf-and-win32-interoperation

We probably should do something very similar to https://github.com/kakone/VLC.MediaElement/blob/master/VLCMediaElement/MediaElement.cs, but move all crossplatform-capable code in a MediaElementBase abstract class. Each platform would inherit from that and perform platform-specific initialization (set drawable surface etc).

/cc @jeremyVignelles

mfkl commented 6 years ago

(very) early API draft: Crossplatform https://github.com/mfkl/LibVLCSharp/blob/wpf/LibVLCSharp/MediaElementCore.cs WPF https://github.com/mfkl/LibVLCSharp/blob/wpf/LibVLCSharp.WPF.Sample/MediaElement.cs

Regarding potential HWND issues, this project seems to have done some interesting stuff we maybe could use: https://github.com/dzimchuk/power-video-player

mfkl commented 6 years ago

Maybe also do a crossplatform MediaTransportControls class? https://github.com/kakone/VLC.MediaElement/blob/ab45f9287e6cf927476a6c652f4fc5e573983122/VLCMediaElement/MediaTransportControls.cs

mfkl commented 6 years ago

For reference https://github.com/unosquare/ffmediaelement Also.

jeremyVignelles commented 6 years ago

Of the few options that are listed on this page, none seems to be "awesome":

I'm currently looking if this is possible with SharpDX

mfkl commented 6 years ago

how about this https://github.com/Microsoft/WPFDXInterop/blob/master/samples/D3D11Image/WpfD3D11Interop/MainWindow.xaml.cs ?

mfkl commented 6 years ago

ffmediaelement Writes to a bitmap (like Meta.Vlc)

Anything wrong with that?

jeremyVignelles commented 6 years ago

https://github.com/Microsoft/WPFDXInterop/blob/master/samples/D3D11Image/WpfD3D11Interop/MainWindow.xaml.cs seems interesting, but I still don't undestand how it is supposed to work, and it links to an inexistant documentation. Specifically, I don't see the difference with the built-in D3DImage.

Anything wrong with that?

Performance is the main reason I'd like to avoid that : That would require vlc to write the pictures in the memory, converting them in a C# buffer, writing them to the bitmap that would then be finally rendered on the screen. It feels like there are too many copies involved.

jeremyVignelles commented 6 years ago

Using directX in WPF "natively" seems to cause a lot of issues. See: https://github.com/sharpdx/SharpDX/issues/599#issuecomment-114016945

We need performance, and currently, I think the only reasonable way we have is to wrap the WinForms component at the cost of not being able to write above the video and some other event issues. Thus, I don't think this is necessary to have a Wpf component since it would add another layer and can be achieved with a few lines.