2017-08-25 145 views
0

我试图为使用vlcj的客户端创建媒体播放器,无需在VLC中从他们的PC安装VLC。不能在Java应用程序中包含vlc库

我从VLC的官方网站验证码它做工精细,直到我加入EmbeddedMediaPlayerComponent()得到它错误

当我使用

新NativeDiscovery()发现()。

它的工作很好,因为我在我的电脑

安装VLC但是当我使用

私有静态最后弦乐NATIVE_LIBRARY_SEARCH_PATH =“C:\\程序 文件\\ \\ VideoLAN的VLC “;

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(),NATIVE_LIBRARY_SEARCH_PATH);

Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(),LibVlc.class);

这是错误日志

14:49:08.471 [main]     INFO             uk.co.caprica.vlcj.Info - vlcj: 3.10.1 
14:49:08.482 [main]     INFO             uk.co.caprica.vlcj.Info - java: 1.8.0_131 Oracle Corporation 
14:49:08.482 [main]     INFO             uk.co.caprica.vlcj.Info - java home: C:\Program Files\Java\jre1.8.0_131 
14:49:08.483 [main]     INFO             uk.co.caprica.vlcj.Info - os: Windows 10 10.0 amd64 


V: 2.2.6 Umbrella 
14:49:08.831 [AWT-EventQueue-0]  DEBUG    uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent - args=[--video-title=vlcj video output, --no-snapshot-preview, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy] 
14:49:08.841 [AWT-EventQueue-0]  DEBUG        uk.co.caprica.vlcj.player.MediaPlayerFactory - initX=null 
14:49:08.853 [AWT-EventQueue-0]  INFO         uk.co.caprica.vlcj.binding.LibVlcFactory - vlc: 2.2.6 Umbrella, changeset 2.2.6-0-g1aae789 
14:49:08.854 [AWT-EventQueue-0]  INFO         uk.co.caprica.vlcj.binding.LibVlcFactory - libvlc: C:\Program Files\VideoLAN\VLC\libvlc.dll 
14:49:08.854 [AWT-EventQueue-0]  DEBUG        uk.co.caprica.vlcj.player.MediaPlayerFactory - MediaPlayerFactory(libvlc=Proxy interface to Native Library <C:\Program Files\VideoLAN\VLC\[email protected]>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy]) 
14:49:08.855 [AWT-EventQueue-0]  DEBUG        uk.co.caprica.vlcj.player.MediaPlayerFactory - jna.library.path=null 
14:49:08.856 [AWT-EventQueue-0]  DEBUG        uk.co.caprica.vlcj.player.MediaPlayerFactory - VLC_PLUGIN_PATH=null 
[00000000007ecfc0] core libvlc error: No plugins found! Check your VLC installation. 
14:49:08.887 [AWT-EventQueue-0]  DEBUG        uk.co.caprica.vlcj.player.MediaPlayerFactory - instance=null 
14:49:08.888 [AWT-EventQueue-0]  ERROR        uk.co.caprica.vlcj.player.MediaPlayerFactory - Failed to initialise libvlc 
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Failed to initialise libvlc. 

This is most often caused either by an invalid vlc option being passed when creating a MediaPlayerFactory or by libvlc being unable to locate the required plugins. 

If libvlc is unable to locate the required plugins the instructions below may help: 

In the text below <libvlc-path> represents the name of the directory containing "libvlc.dll" and "libvlccore.dll" and <plugins-path> represents the name of the directory containing the vlc plugins... 

For libvlc to function correctly the vlc plugins must be available, there are a number of different ways to achieve this: 
1. Make sure the plugins are installed in the "<libvlc-path>/plugins" directory, this should be the case with a normal vlc installation. 
2. Set the VLC_PLUGIN_PATH operating system environment variable to point to "<plugins-path>". 

More information may be available in the log. 

at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:300) 
    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:259) 
    at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.onGetMediaPlayerFactory(EmbeddedMediaPlayerComponent.java:349) 
    at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.<init>(EmbeddedMediaPlayerComponent.java:217) 
    at tutorial.Tutorial.<init>(Tutorial.java:68) 
    at tutorial.Tutorial$1.run(Tutorial.java:49) 
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
    at java.awt.EventQueue.access$500(Unknown Source) 
    at java.awt.EventQueue$3.run(Unknown Source) 
    at java.awt.EventQueue$3.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 

,你能不能帮我VLC捆绑到了我的项目

回答

0

因为我没有评论权限... 是否有可能你有更多的那么安装1个VLC安装? 问的原因是64位jdk/jre无法使用32位VLC安装,反之亦然。只是猜测,如果它可能是VLCJ发现一个不正确的版本的VLC,然后抛出一个错误..只是在这里猜测。

+0

我用VLC 64位和64位JDK – Ahmed

+0

@Ahmed 当你的错误日志看我看到这几行: 'INITX = NULL VLC:2.2.6伞,变更集2.2.6-0-g1aae789 libvlc:C:\ Program Files文件\ VideoLAN的\ VLC \ libvlc.dll jna.library.path = NULL VLC_PLUGIN_PATH = null' 对我来说好像libVLC 2.2.6是发现但图书馆的路径是不是?也似乎VLC_PLUGIN_PATH环境变量可能没有设置? – Payerl

1

对我来说,最好的解决方案是编写我自己的发现策略并将VLC库与应用程序捆绑在一起。这样,不需要安装VLC。一切都伴随着应用程序。

这里有一个发现策略的一个例子:

https://github.com/johndeverall/BehaviourCoder/blob/master/src/main/java/de/bochumuniruhr/psy/bio/behaviourcoder/BundledVLCLibsDiscoveryStrategy.java

你或许可以使用上面未编辑链接的类。

下面是一个使用示例:

final boolean found = new NativeDiscovery(new BundledVLCLibsDiscoveryStrategy()).discover(); 
     SwingUtilities.invokeLater(new Runnable() { 
      public void run() { 
       new Main(found); 
      } 
     }); 

除了这个,你就需要在相同的方式,他们包括在链接的资源文件夹的类路径中的相关VLC库项目。

https://github.com/johndeverall/BehaviourCoder/tree/embedded_video_libraries/src/main/resources/lib

目前我只带了这方面的工作在Windows,但如果你能得到它的Mac和/或Linux的工作,我会很感激公关!

+0

不知道为什么这是downvoted ..它是完美的功能代码,目前在生产中使用,并且似乎是对我有效的方法。 –

1

我用VLCJ - 3.10.1,JNA 4.1组合观察了这个问题。 我通过在我的pom.xml文件中添加JNA 4.2来解决这个问题。

<dependency> 
    <groupId>uk.co.caprica</groupId> 
    <artifactId>vlcj</artifactId> 
    <version>3.10.1</version> 
</dependency> 
<dependency> 
    <groupId>net.java.dev.jna</groupId> 
    <artifactId>jna</artifactId> 
    <version>4.2.0</version> 
</dependency> 

然后添加VLC 2.2.6库使用下面的代码。

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), System.getProperty("user.dir")+"/lib"); 
System.setProperty("VLC_PLUGIN_PATH", System.getProperty("user.dir")+"/lib/plugins"); 

你可以找到代码example here

相关问题