Search code examples
c#wpfvlclibvlcip-camera

C# Vlc wrapper in Wpf


I have been following this little 8min tutorial.

I am fairly new to C# but mostly understand what is going on. The only piece I don't understand is at 7:11. He appears to pull in a namespace (or variable) that is not in scope. I am assuming it is part of the vlc wrapper because of this line:

 video.MediaPlayer.VlcLibDirectoryneeded += MediaPlayer_VlcLibDirectoryNeeded;

Everything you said worked!

You wouldn't happen to know why these are giving me errors would you? I don't see these listed in the class anymore. I'm assuming the same method was just renamed something different? enter image description here


Solution

  • The video does not show all parts of the project. The MainWindow.xaml file that is not shown in the video contains a VlcControl from the Vlc.DotNet.Wpf NuGet package. This control is used to display the actual video content in the main window. It is declared in XAML like this:

    <Window ...
            xmlns:wpf="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf">
       <vlc:VlcControl x:Name="video"/>
    </Window>
    

    The vlc prefix is just the XAML namespace to access the control. The x:Name attribute defines the name of the instance. Consequently, the video in code-behind is just the VlcControl instance in the window.

    However you will still not be anle to access the MediaPlayer property of video, because in the version 3.0.0 the VlcControl for WPF was rewritten and the MediaPlayer property was moved. You now access it like this:

    video.SourceProvider.MediaPlayer
    

    The VlcLibDirectoryNeeded event shown in the video is only present in the WinForms VlcControl, it was removed from the WPF variant when it was rewritten.