无法加载libvlc [英] Unable to load libvlc

查看:345
本文介绍了无法加载libvlc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码可以流式传输一些视频

Hi i have this code to stream some videos

package video;
import javax.swing.*;

import java.awt.*;
import java.io.File;

import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;

import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.runtime.x.LibXUtil;

/**
 * Source: Etienne Vachon
 * */
public class PlayerPanel extends JPanel {

    private File vlcInstallPath = new File("C:\\Program Files (x86)\\VideoLAN\\VLC");
    private EmbeddedMediaPlayer player;

    public PlayerPanel() {
        System.out.println(vlcInstallPath.getAbsolutePath());
        //NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcInstallPath.getAbsolutePath());
        NativeLibrary.addSearchPath(
                RuntimeUtil.getLibVlcLibraryName(), vlcInstallPath.getAbsolutePath());
        Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
        LibXUtil.initialise();
        EmbeddedMediaPlayerComponent videoCanvas = new EmbeddedMediaPlayerComponent();
        this.setLayout(new BorderLayout());
        this.add(videoCanvas, BorderLayout.CENTER);
        this.player = videoCanvas.getMediaPlayer();
    }

    public void play(String media) {
        player.prepareMedia(media);
        player.parseMedia();
        player.play();
    }
}

我的vlc是64位,我的jvm也是如此,jna,jna平台和vlcj位于同一文件夹lib中.但是我每次都会收到此错误

My vlc is 64 bit and so is my jvm, the jna, jna-platform and vlcj are situated in the same folder lib. Yet i get this error every time

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libvlc': Native library (win32-x86-64/libvlc.dll) not found in resource path ([file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/bin/, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/xmlpull_1_1_3_4c.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/xpp3-1.1.3.4.C.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/ojdbc6.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/orai18n.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/JTattoo-1.6.10.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/JFeatureLib-1.6.0-jar-with-dependencies.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/JFeatureLib-1.6.0.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/jmf.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/slf4j.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/JFeatureLib-1.6.0-sources.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/ojdbc5.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/JFeatureLib-1.6.0-javadoc.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/slf4j-simple-1.7.6.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/xuggle-xuggler-5.4.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/slf4j-api-1.7.6.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/platform-3.5.2.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/vlcj-3.0.1.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/jna-4.0.0.jar, file:/C:/Users/Shonguiz/workspace/GTI660_LAB02/lib/jna-platform-4.0.0.jar])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.<init>(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:412)
    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at video.PlayerPanel.<init>(PlayerPanel.java:29)
    at video.VideoPlayer.<init>(VideoPlayer.java:11)
    at controllerV2.MainController.<init>(MainController.java:47)
    at controllerV2.MainController.main(MainController.java:166)

在异常显示的资源路径中看不到VLC路径是否正常?

Is it normal that i don't see the VLC path in the ist of ressources path displayed by the the exception ?

推荐答案

步骤1)安装VLC X64:

Step 1) Install VLC X64: https://get.videolan.org/vlc/2.2.6/win64/vlc-2.2.6-win64.exe

第2步)更改本机库路径:

Step 2) Change native library path:

File vlcInstallPath = new File("D:\\Program Files\\VideoLAN\\VLC");

这篇关于无法加载libvlc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆