Reputation: 307
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();
}
}
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)
Is it normal that i don't see the VLC path in the ist of ressources path displayed by the the exception ?
Upvotes: 0
Views: 3829
Reputation: 1927
Step 1) Install VLC X64: https://get.videolan.org/vlc/2.2.6/win64/vlc-2.2.6-win64.exe
Step 2) Change native library path:
File vlcInstallPath = new File("D:\\Program Files\\VideoLAN\\VLC");
Upvotes: 2