找不到 VlcLibDirectory

VlcLibDirectory not found

我正在使用 VS 2017 并使用 C# 进行编码。我安装了 4 个 Vlc 库以在 Windows 表单应用程序中播放视频。我在窗体中放置了一个 Vlc 控件。然后,在代码中,我写道:

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

当我 运行 它时,我得到一个 "VlcLibDirectory not found"。我需要做什么?我看到我可以通过可视控件在 VlcControl1 属性中设置该目录,但是那个文件夹是什么?

需要加载的库是libvlc.dll,在安装VLC软件的文件夹中找到。

抱歉来晚了...

您已经完成了第一部分,在 Visual Studio 中获取了包,现在您需要它的库。

下载这个:https://github.com/ZeBobo5/Vlc.DotNet/tree/master

将 lib 目录放在应用程序可以找到的地方,并将 VlcLibDirectory 设置为新的 DirectoryInfo(目录路径)。

我是这样做的:

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

为此我几乎访问了每个 Google 结果页面,几乎失去了希望,但这最终对我有用:

1) 在我的 FormsApp 文件中创建了一个对象:

VlcControl vlcControl1 = new VlcControl();

2) 在构造函数中实例化它:

VlcControl vlcControl1 = new VlcControl();

3) 在我的 FormsApp_Load() 中添加了以下行:

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()

希望这对某人有所帮助。

我也遇到过这个问题

我只是查看了窗体上 VlcControl 的属性,并通过浏览到 "libvlc.dll" 所在的目录来更改媒体播放器类别下的 VlcLibDirectory 项。

(在我的申请中C:\Users\MCOT\source\repos\WindowsApp3\packages\VideoLAN.LibVLC.Windows.3.0.6\build\x86

@Thanin's 是我需要的,...这是应该安装库的代码片段。

//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[] { });
}