[英]Directory Not Found Exception or FileNotFoundException on VLC.DotNet
Using the VLC library provided by Vlc.DotNet, I have tried to implement it in a simple WPF. 使用Vlc.DotNet提供的VLC库,我试图在一个简单的WPF中实现它。
I copied exactly the code from the repository, and got the NuGet online, but can't seem to make it work. 我从存储库中复制了完整的代码,并在线获取了NuGet,但似乎无法使其正常工作。 I get a Directory Not Found exception straight from the load of the file on the disk. 我直接从磁盘上的文件加载获得Directory Not Found异常。
Here is my code: 这是我的代码:
public MainWindow()
{
InitializeComponent();
VLCControl.MediaPlayer.VlcLibDirectoryNeeded += OnVlcControlNeedsLibDirectory;
}
private void OnVlcControlNeedsLibDirectory(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
{
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
if (currentDirectory == null)
return;
if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"..\..\..\lib\x86\"));
else
e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"..\..\..\lib\x64\"));
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var d = new Microsoft.Win32.OpenFileDialog();
d.Multiselect = false;
if (d.ShowDialog() == true)
{
Uri src = new Uri(d.FileName);
VLCControl.MediaPlayer.Play(src); //Exception here
}
}
VLCControl being the VLC control in the xaml. VLCControl是xaml中的VLC控件。
By changing the VlcLibDirectory
with another path where I put the libraries (for example the root of application), I get this StackTrace : 通过将VlcLibDirectory
更改为我放置库的另一个路径(例如应用程序的根目录),我得到了这个StackTrace:
at Vlc.DotNet.Core.Interops.VlcInteropsManager..ctor(DirectoryInfo dynamicLinkLibrariesPath) at Vlc.DotNet.Core.Interops.VlcManager..ctor(DirectoryInfo dynamicLinkLibrariesPath) at Vlc.DotNet.Core.Interops.VlcManager.GetInstance(DirectoryInfo dynamicLinkLibrariesPath) at Vlc.DotNet.Core.VlcMediaPlayer..ctor(DirectoryInfo vlcLibDirectory) at Vlc.DotNet.Forms.VlcControl.EndInit() at Vlc.DotNet.Forms.VlcControl.Play(Uri uri, String[] options) at VLCTest.MainWindow.Button_Click(Object sender, RoutedEventArgs e) in c:\\Users\\ME\\Documents\\Visual Studio 2013\\Projects\\VLCTest\\VLCTest\\MainWindow.xaml.cs:ligne 56 位于Vlc.DotNet.Core.Interops.VlcManager.ctor(DirectoryInfo dynamicLinkLibrariesPath)的Vlc.DotNet.Core.Interops.VlcInteropsManager..ctor(DirectoryInfo dynamicLinkLibrariesPath),位于Vlc.DotNet.Core.Interops.VlcManager.GetInstance(DirectoryInfo dynamicLinkLibrariesPath)在Vlc.DotNet.Core.VlcMediaPlayer..ctor(DirectoryInfo vlcLibDirectory)Vlc.DotNet.Forms.VlcControl.EndInit()at Vlc.DotNet.Forms.VlcControl.Play(Uri uri,String [] options)at VLCTest.MainWindow .Button_Click(Object sender,RoutedEventArgs e)位于c:\\ Users \\ ME \\ Documents \\ Visual Studio 2013 \\ Projects \\ VLCTest \\ VLCTest \\ MainWindow.xaml.cs:ligne 56
The code becomes : 代码变成:
if(AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
e.VlcLibDirectory = new DirectoryInfo(currentDirectory);
else
e.VlcLibDirectory = new DirectoryInfo(currentDirectory);
Thank you for your help. 谢谢您的帮助。
The problem is definitely with your library path, though you have to debug the problem yourself in order to find the exact discrepancy between provided path and actual path. 问题肯定在于您的库路径,但您必须自己调试问题才能找到提供的路径与实际路径之间的确切差异。
The misunderstanding may be, which libraries are missing. 误解可能是,图书馆遗失了。 You do have the Vlc.DotNet.Core.Interops.dll
but your are missing the nativ libraries behind. 你有Vlc.DotNet.Core.Interops.dll
但你缺少后面的nativ库。 This is the reason, why the exception occurs inside Vlc.DotNet.Core.Interops.dll
when it tries to load the actual libraries. 这是什么原因,为什么发生异常里面 Vlc.DotNet.Core.Interops.dll
当它试图加载实际库。
The OnVlcControlNeedsLibDirectory
function is called inside VLCControl.MediaPlayer.Play(src);
OnVlcControlNeedsLibDirectory
函数在VLCControl.MediaPlayer.Play(src);
调用VLCControl.MediaPlayer.Play(src);
, so the Path from OpenFileDialog has nothing to do with the problem. ,所以OpenFileDialog的路径与问题无关。
Steps I taken to reproduce / fix: 我重现/修复的步骤:
My folder layout: 我的文件夹布局:
Solution path: 解决途径:
D:\\Programmierung\\VLCTest-VAlphaTesting\\VLCTest-VAlphaTesting\\ d:\\ Programmierung \\ VLCTest-VAlphaTesting \\ VLCTest,VAlphaTesting \\
Actual Assembly location on execute 执行时的实际装配位置
D:\\Programmierung\\VLCTest-VAlphaTesting\\VLCTest-VAlphaTesting\\VLCTest\\bin\\Debug d:\\ Programmierung \\ VLCTest-VAlphaTesting \\ VLCTest-VAlphaTesting \\ VLCTest \\ BIN \\调试
ProcessorArchitecture: x86 ProcessorArchitecture:x86
Library Path: 图书馆路径:
D:\\Programmierung\\Vlc.DotNet-master\\Vlc.DotNet-master\\lib\\x86 d:\\ Programmierung \\ Vlc.DotNet主\\ Vlc.DotNet主\\ lib中\\ X86
Contents of library path: 图书馆路径的内容:
plugins (folder) 插件(文件夹)
.keep (file) .keep(文件)
libvlc.dll (file) libvlc.dll(文件)
libvlccore.dll (file) libvlccore.dll(文件)
For testing purposes I hardcoded the library path - you may want to do that as well 出于测试目的,我对库路径进行了硬编码 - 您可能也希望这样做
if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
e.VlcLibDirectory = new DirectoryInfo(@"D:\Programmierung\Vlc.DotNet-master\Vlc.DotNet-master\lib\x86");
else
e.VlcLibDirectory = new DirectoryInfo(@"D:\Programmierung\Vlc.DotNet-master\Vlc.DotNet-master\lib\x64");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.