C# 未找到VlcLibDirectory
我正在使用VS2017,并用C#编写代码。我安装了4个Vlc库,以便在Windows窗体应用程序中播放视频。我在表单中放置了一个Vlc控件。然后,在代码中,我写道:C# 未找到VlcLibDirectory,c#,visual-studio,vlc,libvlc,C#,Visual Studio,Vlc,Libvlc,我正在使用VS2017,并用C#编写代码。我安装了4个Vlc库,以便在Windows窗体应用程序中播放视频。我在表单中放置了一个Vlc控件。然后,在代码中,我写道: vlcControl1.SetMedia(curFolder + @"\media\1.mp4"); vlcControl1.Play(); 当我运行它时,会得到一个“未找到VlcLibDirectory”。我需要做什么?我看到我可以通过视觉控件在VlcControl1属性中设置该目录,但那个文件夹是什么?需要加载的库是安装VLC
vlcControl1.SetMedia(curFolder + @"\media\1.mp4");
vlcControl1.Play();
当我运行它时,会得到一个“未找到VlcLibDirectory”。我需要做什么?我看到我可以通过视觉控件在VlcControl1属性中设置该目录,但那个文件夹是什么?需要加载的库是安装VLC软件的文件夹中的libvlc.dll。需要加载的库是安装VLC软件的文件夹中的libvlc.dll。很抱歉,这太晚了 第一部分是在VisualStudio中获取包,现在需要库 下载此文件: 将lib目录放在应用程序可以找到的地方,并将VlcLibDirectory设置为一个新的DirectoryInfo(指向dir的路径) 我是这样做的:
var libDirectory = new DirectoryInfo(Path.Combine(".", "libvlc", IntPtr.Size == 4 ? "x86" : "x64"));
vlcControl1 = new Vlc.DotNet.Forms.VlcControl();
vlcControl1.VlcLibDirectory = libDirectory;
很抱歉这么晚了 第一部分是在VisualStudio中获取包,现在需要库 下载此文件: 将lib目录放在应用程序可以找到的地方,并将VlcLibDirectory设置为一个新的DirectoryInfo(指向dir的路径) 我是这样做的:
var libDirectory = new DirectoryInfo(Path.Combine(".", "libvlc", IntPtr.Size == 4 ? "x86" : "x64"));
vlcControl1 = new Vlc.DotNet.Forms.VlcControl();
vlcControl1.VlcLibDirectory = libDirectory;
为此,我几乎访问了每个谷歌结果页面,几乎失去了希望,但这最终对我起了作用: 1) 在我的FormsApp文件中创建了一个对象:
VlcControl vlcControl1 = new VlcControl();
2) 在构造函数中实例化它:
VlcControl vlcControl1 = new VlcControl();
3) 在我的表单中,sapp_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()
希望这对某人有所帮助。我几乎访问了每个谷歌搜索结果页面,几乎失去了希望,但这最终对我起到了作用: 1) 在我的FormsApp文件中创建了一个对象:
VlcControl vlcControl1 = new VlcControl();
2) 在构造函数中实例化它:
VlcControl vlcControl1 = new VlcControl();
3) 在我的表单中,sapp_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”所在的目录来更改Media Player类别下的VlcLibDirectory项
(在我的应用程序中
C:\Users\MCOT\source\repos\WindowsApp3\packages\VideoLAN.LibVLC.Windows.3.0.6\build\x86
)我也遇到了这个问题
我只是查看表单上VlcControl的属性,并通过浏览“libvlc.dll”所在的目录来更改Media Player类别下的VlcLibDirectory项
(在我的应用程序中C:\Users\MCOT\source\repos\WindowsApp3\packages\VideoLAN.LibVLC.Windows.3.0.6\build\x86
)是我所需要的。。。下面是一段代码片段,该库应该安装在哪里
//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[] { });
}
是我所需要的。。。下面是一段代码片段,该库应该安装在哪里
//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[] { });
}