当前位置: 首页 > 知识库问答 >
问题:

vlcj无法在默认安装文件夹中找到插件库,NativeDiscovery工作

桑鸿志
2023-03-14
public class Test {

private final JFrame frame;

private final EmbeddedMediaPlayerComponent mediaPlayerComponent;

public static void main(final String[] args) {

    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\Program Files\\VideoLAN\\VLC");
    System.setProperty("VLC_PLUGIN_PATH",  "C:\\Program Files\\VideoLAN\\VLC\\plugins");
    System.out.println(LibVlc.INSTANCE.libvlc_get_version());

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            new Test(args);
        }
    });
   }

public Test(String[] args) {
    frame = new JFrame("My First Media Player");
    frame.setBounds(100, 100, 600, 400);
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            mediaPlayerComponent.release();
            System.exit(0);
        }
    });
    mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
}
   }
[main] INFO uk.co.caprica.vlcj.Info - vlcj: 3.10.1
[main] INFO uk.co.caprica.vlcj.Info - java: 10.0.1 Oracle Corporation
[main] INFO uk.co.caprica.vlcj.Info - java home: C:\Program Files\Java\jdk-10.0.1
[main] INFO uk.co.caprica.vlcj.Info - os: Windows 10 10.0 amd64
3.0.3 Vetinari
[AWT-EventQueue-0] INFO uk.co.caprica.vlcj.binding.LibVlcFactory - vlc:      3.0.3 Vetinari, changeset 3.0.3-1-0-gc2bb759264
[AWT-EventQueue-0] INFO uk.co.caprica.vlcj.binding.LibVlcFactory - libvlc: C:\Program Files\VideoLAN\VLC\libvlc.dll
[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 vlctest.Test.<init>(Test.java:46)
at vlctest.Test$1.run(Test.java:30)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue.access$600(EventQueue.java:97)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

你知道原因是什么吗?

共有1个答案

傅自明
2023-03-14

所以多亏了cubrr我才能够解决这个问题。只需创建一个设置环境变量的批处理文件,然后运行jar就可以工作了。

set VLC_PLUGIN_PATH=C:\Program Files\VideoLAN\VLC\plugins
start cmd.exe /c start "" javaw -jar test.jar

请注意,使用javaw运行jar会关闭控制台窗口,因此它不会停留在应用程序窗口下面,而使用java则会停留在控制台。

这里只保留以下内容:可以使用ClassLoader加载libvlc.dll和libvlccore.dll

File jarDir = new File(ClassLoader.getSystemClassLoader().getResource(".").getPath());
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), jarDir.getAbsolutePath());`
 类似资料:
  • 我尝试在工件名称中包含git提交哈希,以区分CI场景中的快照版本。git散列成功地包含在我的项目的目标/文件夹中,但是在最后一个maven步骤中,它将工件复制到我的HOME/. m2/repository文件夹中,并将名称更改为ARTIFACTID-VERSION-mta.jar. 我怎么能保持文件名从目标/文件夹,包括提交哈希? 我查看了maven安装插件,但找不到“finalName”属性或类

  • 我正在尝试在我的Spring Tool Suite 3.6.1版本中安装Hibernate Tools插件,安装完成时没有任何错误,但我既看不到Hibernate透视图,也没有获得逆向工程hibernate类的选项。我尝试了以下操作但没有成功: < li >使用安装新软件选项...,使用网站链接更新- 是否有人在 STS 3.6.1 发行版中成功配置了Hibernate工具。

  • 我的原始文件使用默认的谷歌协议缓冲区类型,如结构和时间戳。 使用默认的gradle协议集成,gradle输出错误,因为它无法解决导入: google/protobuf/struct。proto:找不到文件。 google/protobuf/timestamp。proto:找不到文件。 替换默认的gradle协议块 其中一个指定protoc的位置 修复了该问题,但它不可移植。 是否有任何jar依赖项

  • 问题内容: 我正在使用Maven版本3.6.1 我想在Maven存储库(elasticsearch-rest-high-level-client 7.5.1)中下载工件。我可以在 maven-central-repository search 但是在搜索elasticsearch elasticsearch-rest-high-level-client/7.5.1给出的回购协议时,它们是Centr

  • 更新我的问题: 我在安装用于Windows Phone 8的cordova时遵循了此步骤(不使用终端)。我无法确定插件文件在模板中的位置:https://cordova.apache.org/docs/en/3.0.0/guide_platforms_wp8_index.md.html 唯一的解决方案(不是我想要的)是我必须使用phoneGap而不是cordova。我试图调用API来显示设备版本,

  • 我的Windows 7上有Eclipse 4.4。我在尝试安装Google插件时出现以下错误: 正在安装的软件:Google Plugin for Eclipse 4.3 3.5.1. v201312301723-rel-r43(com.google.gdt.eclipse.suite.e43.feature.feature.group3.5.1. v201312301723-rel-r43) 缺