David TG
David TG

Reputation: 77

VlcLibDirectory not found

I'm using VS 2017 and coding in C#. I installed the 4 Vlc libraries to play videos in a Windows Form Application. I put a Vlc control in the form. And then, in the code, I wrote:

vlcControl1.SetMedia(curFolder + @"\media\1.mp4");
vlcControl1.Play();

When I run it, I get a "VlcLibDirectory not found". What I need to do? I see that I can set that directory through visual controls, in the VlcControl1 properties, but what is that folder?

Upvotes: 0

Views: 9930

Answers (5)

ergohack
ergohack

Reputation: 1358

@Thanin's answer is what I needed, ... here is a code snippet to where the library should be installed.

//InitializeComponent();
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(
    "SOFTWARE\\VideoLAN\\VLC",
     RegistryKeyPermissionCheck.ReadSubTree,
    RegistryRights.QueryValues))
{
    _Vlc.SourceProvider.CreatePlayer(
    new DirectoryInfo(rk.GetValue("InstallDir") as string),
    new string[] { });
}

Upvotes: 0

David TG
David TG

Reputation: 77

The library that it needs to be loaded is libvlc.dll that is found in the folder where is installed the VLC software.

Upvotes: 2

I've also experienced this problem.

I just look into the properties of the VlcControl on the Form and change the VlcLibDirectory item under the Media Player category by browsing to the directory which the "libvlc.dll" located.

(in my application C:\Users\MCOT\source\repos\WindowsApp3\packages\VideoLAN.LibVLC.Windows.3.0.6\build\x86)

Upvotes: 0

askepott
askepott

Reputation: 279

I visited practically every Google result page for this, almost lost hope, but this worked for me in the end:

1) Created an object in my FormsApp file:

VlcControl vlcControl1 = new VlcControl();

2) Instantiated it in the constructor:

VlcControl vlcControl1 = new VlcControl();

3) In my FormsApp_Load() added the following lines:

vlcControl1.BeginInit();
vlcControl1.VlcLibDirectory = new DirectoryInfo(_exeFolder + @"\libvlc\win-x86"); //Make sure your dir is correct
vlcControl1.VlcMediaplayerOptions = new[] { "-vv"}; //not sure what this does
vlcControl1.EndInit();
YourControlContainer.Controls.Add(vlcControl1); //Add the control to your container
vlcControl1.Dock = DockStyle.Fill; //Optional
this.vlcControl1.Click += new EventHandler(vlcControl1_Click); //Optional - added a click event .Play()

Hope this helps someone.

Upvotes: 1

CharlesW
CharlesW

Reputation: 625

I'm sorry this is late...

You got the first part, getting the packages in Visual Studio, now you need the libraries for it.

Download this: https://github.com/ZeBobo5/Vlc.DotNet/tree/master

Put the lib directory somewhere the application can find it, and set that VlcLibDirectory equal to a new DirectoryInfo(path to dir).

I did it like this:

var libDirectory = new DirectoryInfo(Path.Combine(".", "libvlc", IntPtr.Size == 4 ? "x86" : "x64"));
vlcControl1 = new Vlc.DotNet.Forms.VlcControl();
vlcControl1.VlcLibDirectory = libDirectory;

Upvotes: 3

Related Questions