gpt4 book ai didi

java - 无法加载 libvlc

转载 作者:行者123 更新时间:2023-12-01 13:10:49 34 4
gpt4 key购买 nike

嗨,我有这个代码来流式传输一些视频

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 也是 64 位,jna、jna-platform 和 vlcj 位于同一文件夹 lib 中。但我每次都会收到这个错误

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 路径,这正常吗?

最佳答案

步骤 1) 安装 VLC X64: https://get.videolan.org/vlc/2.2.6/win64/vlc-2.2.6-win64.exe

第2步)更改 native 库路径:

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

关于java - 无法加载 libvlc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22885679/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com