Home > Enterprise >  Embedding VLC player in WInform Application in .Net Core. Core.Intialize() Giving Exception
Embedding VLC player in WInform Application in .Net Core. Core.Intialize() Giving Exception

Time:10-17

I am trying to Embed VLc in Winform Application on .net core 3.1 framework. Packages installed are ** LibVLCSharp 3.6.1 LibVLCSharp.WinForms 3.6.1 **

private void PlayerForm_Load(object sender, EventArgs e)
        {
            var url = typeof(LibVLC).Assembly.Location;
            Core.Initialize();
            using(var libvlc = new LibVLC())
                using (var mediaPlayer = new MediaPlayer(libvlc))
            {
                var uri = new Uri("C:\\Active Projects\\ScreenPlayerWeb\\ScreenPlayerWeb\\wwwroot\\Videos\\VID_20190621_112556.3gp");
                using var media = new Media(libvlc, uri);
                mediaPlayer.Fullscreen = true;
                mediaPlayer.Play();
            }
        }

Core.Initialize() Giving Exception

** LibVLCSharp.Shared.VLCException: 'Failed to load required native libraries. Have you installed the latest LibVLC package from nuget for your target platform? Search paths include C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlc.dll,C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlccore.dll; C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlc.dll,C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc\win-x64\libvlccore.dll; C:\Active Projects\ScreenPlayerClient\ScreenPlayerClient\ScreenPlayerClient\bin\Debug\netcoreapp3.1\libvlc.dll,'

**

Its searching for wrong file in my devug/netcore3.1 folder there is no file as libvlc.dll ... files avaialble are libvlcsharp.dll, libvlcsharp.winforms.dll and vlc.dotnet.core.dll.

There are answers on stack overflow but most of these are more than 5 years old so cant be referenced to updated versions of LIbVlc and .Net

Help will be highly appriciated.

CodePudding user response:

The package doesn't include the actual 'libvlc' as you might expect, its only initialization code in the LibVLCSharp. Ensure you installed the VideoLAN.LibVLC.[YourPlatform] package in your target project. Or download it manually and point towards the folder:

Core.Initialize(@"C:\yourpath\libvlc\win-x64");
var libvlc = new LibVLC();
// Make VideoView control
VideoView vv = new VideoView();
vv.MediaPlayer = new MediaPlayer(libvlc);
vv.Dock = DockStyle.Fill; 
// Add it to the form
Controls.Add(vv);

var uri = new Uri(@"C:\Video.mp4");
// Use command line options as Options for media playback (https://wiki.videolan.org/VLC_command-line_help/)
var media = new Media(libvlc, uri, ":input-repeat=65535");
vv.MediaPlayer.Play(media);

//Set fullscreen
this.FormBorderStyle = FormBorderStyle.None;
this.Size = Screen.PrimaryScreen.Bounds.Size;
this.Location = Screen.PrimaryScreen.Bounds.Location;
  • Related