我正在尝试初始化VLCJ以进行一些流媒体作为我正在处理的应用程序的一部分。在official tutorial之后,我使用以下代码尝试加载库:
NativeLibrary.addSearchPath(
RuntimeUtil.getLibVlcLibraryName(), "/Applications/VLC/Contents/MacOS/lib"
);
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
当我运行它时,我收到以下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'vlc': JNA native support (darwin/libvlc.dylib) not found in resource path (/Users/iamparker/Documents/workspace/VLCStreamer/target/classes:/usr/jar/vlc/vlcj-3.0.1-javadoc.jar:/usr/jar/vlc/vlcj-3.0.1-sources.jar:/usr/jar/vlc/vlcj-3.0.1-test-sources.jar:/usr/jar/vlc/vlcj-3.0.1-tests.jar:/usr/jar/vlc/vlcj-3.0.1.jar:/usr/jar/vlc/jna-4.1.0.jar:/usr/jar/vlc/jna-platform-4.1.0.jar)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:220)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:322)
at com.sun.jna.Library$Handler.<init>(Library.java:142)
at com.sun.jna.Native.loadLibrary(Native.java:387)
at com.sun.jna.Native.loadLibrary(Native.java:366)
at com.thundercats.vlcstreamer.Main.loadNative(Main.java:33)
at com.thundercats.vlcstreamer.Main.main(Main.java:16)
看起来它甚至没有搜索我给它的路径。该目录中有一个非常好的libvlc.dylib。
以下是运行VLCJ NativeDiscoveryTest的输出:
vlcj: (Info.java:70) | INFO | vlcj: <version not available>
vlcj: (Info.java:71) | INFO | java: 1.6.0_65 Apple Inc.
vlcj: (Info.java:72) | INFO | java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
vlcj: (Info.java:73) | INFO | os: Mac OS X 10.8.5 x86_64
vlcj: (NativeDiscovery.java:98) | DEBUG | discover()
vlcj: (NativeDiscovery.java:101) | DEBUG | jnaLibraryPath=null
vlcj: (NativeDiscovery.java:106) | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.linux.DefaultLinuxNativeDiscoveryStrategy@42b1b4c3
vlcj: (NativeDiscovery.java:109) | DEBUG | supported=false
vlcj: (NativeDiscovery.java:106) | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.windows.DefaultWindowsNativeDiscoveryStrategy@60072ffb
vlcj: (NativeDiscovery.java:109) | DEBUG | supported=false
vlcj: (NativeDiscovery.java:106) | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.mac.DefaultMacNativeDiscoveryStrategy@77df38fd
vlcj: (NativeDiscovery.java:109) | DEBUG | supported=true
vlcj: (AbstractNativeDiscoveryStrategy.java:49) | DEBUG | discover()
vlcj: (AbstractNativeDiscoveryStrategy.java:54) | DEBUG | directoryNames=[/Users/iamparker/Documents/workspace/NativeDiscoveryTest, /usr/bin, /bin, /usr/sbin, /sbin, /Applications/VLC.app/Contents/MacOS/lib]
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/Users/iamparker/Documents/workspace/NativeDiscoveryTest
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/usr/bin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/bin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/usr/sbin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/sbin
vlcj: (AbstractNativeDiscoveryStrategy.java:95) | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57) | DEBUG | directoryName=/Applications/VLC.app/Contents/MacOS/lib
vlcj: (AbstractNativeDiscoveryStrategy.java:85) | DEBUG | Matched 'libvlc.dylib' in '/Applications/VLC.app/Contents/MacOS/lib'
vlcj: (AbstractNativeDiscoveryStrategy.java:85) | DEBUG | Matched 'libvlccore.dylib' in '/Applications/VLC.app/Contents/MacOS/lib'
vlcj: (AbstractNativeDiscoveryStrategy.java:88) | DEBUG | Matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:63) | DEBUG | result=/Applications/VLC.app/Contents/MacOS/lib
vlcj: (NativeDiscovery.java:112) | DEBUG | path=/Applications/VLC.app/Contents/MacOS/lib
vlcj: (NativeDiscovery.java:114) | INFO | Discovery found libvlc at '/Applications/VLC.app/Contents/MacOS/lib'
vlcj: (Test.java:34) | DEBUG | found=true
vlcj: (LibVlcFactory.java:164) | INFO | vlc: 2.1.4 Rincewind, changeset 2.1.4-0-g2a072be
vlcj: (LibVlcFactory.java:165) | INFO | libvlc: /Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib
vlcj: (Test.java:36) | DEBUG | Version: {}2.1.4 Rincewind
答案 0 :(得分:1)
原来这只是我的一个愚蠢的错误。我提供的路径是"/Applications/VLC/Contents/MacOS/lib"
,它应该是"/Applications/VLC.app/Contents/MacOS/lib"
。我忘记了VLC有一个.app扩展名。我现在要把头埋在沙子里。
答案 1 :(得分:0)
cd src/main/resources/
cp -r /Applications/VLC.app/Contents/MacOS/lib darwin
rm darwin/*.*.*
cd darwin
install_name_tool -add_rpath @loader_path libvlc.dylib
mkdir vlc
cp -r /Applications/VLC.app/Contents/MacOS/plugins vlc/plugins
这是macOS版本。它为我工作。也许可以帮助您。
├── kotlin
│ └── App.kt
└── resources
└── darwin
├── libvlc.dylib
├── libvlccore.dylib
└── vlc
└── plugins
├── liba52_plugin.dylib
├── libaccess_concat_plugin.dylib
├── libaccess_imem_plugin.dylib
├── libaccess_mms_plugin.dylib
答案 2 :(得分:0)
我将vlcj maven依赖项更新为:
<dependency>
<groupId>uk.co.caprica</groupId>
<artifactId>vlcj</artifactId>
<version>3.12.1</version>
</dependency>
它有效