首页 > 解决方案 > 如何在树莓派上使用 VLC.DotNet.Core API

问题描述

我制作了一个使用 mono ( mcs) 编译的 C# 控制台应用程序,我可以在 Windows 和 Raspberry Pi (raspbian) 上运行它。该应用程序使用 NuGet 包Vlc.DotNet.Core与我的 Windows 机器上存在的 VLC 安装进行交互,这很有效。

我知道我的 Windows 机器上的路径libvlc.dll(api 需要它才能工作),问题是我无法在 Raspberry Pi 上找到它,即使在apt-get install vlc.

我在 Pi 中搜索了 vlc 的位置,并将该路径输入到构造函数中VlcMediaPlayer,如下所示;

new VlcMediaPlayer(new DirectoryInfo("/usr/lib/arm-linux-gnueabihf/vlc"));

我对我使用了正确的路径几乎没有信心......显然,VLC 的 Windows 安装和 Raspbian 的安装之间存在重大差异。

在 Pi 上产生的异常显示为:

Unhandled Exception:
System.IO.FileNotFoundException: Unable to find the specified file.
  at Vlc.DotNet.Core.Interops.VlcLibraryLoader..ctor (System.IO.DirectoryInfo dynamicLinkLibrariesPath) [0x0007a] in <baf298be89ec4e8f88b59dde806086ea>:0 
  at Vlc.DotNet.Core.Interops.VlcLibraryLoader.GetOrCreateLoader (System.IO.DirectoryInfo dynamicLinkLibrariesPath) [0x00051] in <baf298be89ec4e8f88b59dde806086ea>:0 
  at Vlc.DotNet.Core.Interops.VlcManager..ctor (System.IO.DirectoryInfo dynamicLinkLibrariesPath, System.String[] args) [0x00006] in <baf298be89ec4e8f88b59dde806086ea>:0 
  at Vlc.DotNet.Core.VlcMediaPlayer..ctor (System.IO.DirectoryInfo vlcLibDirectory) [0x00000] in <9af967e78de14038abf8c3386a2b8049>:0 
  at MonoApp.Classes.VLCFactory.Create () [0x0000b] in <0b03f50fed2542db8a444bf356ef64b6>:0 
  at MonoApp.Classes.VLCCommands.VLCCommand_Play.Execute (Vlc.DotNet.Core.VlcMediaPlayer& mediaPlayer, System.String[] args) [0x00007] in <0b03f50fed2542db8a444bf356ef64b6>:0 
  at MonoApp.Program.Main (System.String[] args) [0x00019] in <0b03f50fed2542db8a444bf356ef64b6>:0 

编辑:

我在这里找到了 VlcLibraryLoader 类的源文件(如异常所示)显然它正在寻找三个 dll,其中只有两个存在于 Windows 上,所以我猜测链接的源文件有点过时了。这里的重点是他们正在寻找.dll文件,而不是.soRaspberry Pi 上存在的文件,所以我对它失败并不感到惊讶。然而,问题仍然存在……

问题:

标签: c#raspberry-pi3raspbianvlc

解决方案


我不知道 Vlc.DotNet.Core 是否可以在带有单声道的 raspbian 上工作。如您所知,它最初的目标是在 Windows 上工作。

不过,LibVLCSharp 可能适用于 raspbian,因为它适用于 ubuntu。

LibVLC/GTK linux 安装指南:https ://code.videolan.org/videolan/LibVLCSharp/blob/master/docs/linux-setup.md

LibVLCSharp.GTK 示例:https ://code.videolan.org/videolan/LibVLCSharp/tree/master/Samples/LibVLCSharp.GTK.Sample

祝你好运。


推荐阅读