Reputation: 41
I have this code:
public class MediaPanel {
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
chargerLibrairie();
new MediaPanel(args);
}
});
}
static void chargerLibrairie(){ String ruta="C:/VideoLAN/VLC";
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), ruta);
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
LibXUtil.initialise();
}
private MediaPanel(String[] args) {
JFrame frame = new JFrame("Tutoriel vlcj");
frame.setLocation(100, 100);
frame.setSize(1050, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
//Créer une instance de Canvas
Canvas c = new Canvas();
//L'arrière plan de la vidéo est noir par défaut
c.setBackground(Color.black);
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
//La vidéo prend toute la surface
p.add(c, BorderLayout.CENTER);
frame.add(p, BorderLayout.CENTER);
//Créer une instance factory
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
//Créer une instance lecteur média
EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer();
mediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(c));
//Plein écran
mediaPlayer.toggleFullScreen();
//Cacher le curseur de la souris à l'intérieur de JFrame
mediaPlayer.setEnableMouseInputHandling(false);
//Désactiver le clavier à l'intérieur de JFrame
mediaPlayer.setEnableKeyInputHandling(true);
//Préparer le fichier
mediaPlayer.prepareMedia("J.mp4");
//lire le fichier
mediaPlayer.play();
}
}
And I have this error:
run:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Unable to load library 'libvlc': Native library (win32-x86-64/libvlc.dll) not found in resource path ([file:/C:/Users/Jes%c3%bas/Desktop/videoProyecto/jna-4.0.0.jar, file:/C:/Users/Jes%c3%bas/Desktop/videoProyecto/jna-platform-4.0.0.jar, file:/C:/Users/Jes%c3%bas/Desktop/videoProyecto/vlcj-2.4.0.jar, file:/C:/Users/Jes%c3%bas/Documents/NetBeansProjects/edicionVideo/build/classes/])
It seems that the directory is correct, but I think it doesn't load the libraries from vlc. I have ensured that the libraries are the same architecture as my pc, 64 bits, and I don't really know what the problem is.
Upvotes: 2
Views: 2391
Reputation: 4609
cd src/main/resources/
cp -r /Applications/VLC.app/Contents/MacOS/lib darwin
rm darwin/*.*.*
cd darwin
install_name_tool -add_rpath @loader_path libvlc.dylib
mkdir vlc
cp -r /Applications/VLC.app/Contents/MacOS/plugins vlc/plugins
This is the macOS version. Worked for me. Maybe help you.
├── kotlin
│ └── App.kt
└── resources
└── darwin
├── libvlc.dylib
├── libvlccore.dylib
└── vlc
└── plugins
├── liba52_plugin.dylib
├── libaccess_concat_plugin.dylib
├── libaccess_imem_plugin.dylib
├── libaccess_mms_plugin.dylib
Upvotes: 1
Reputation: 11
Sometimes the problem is due to incompatibility of the architecture of VLC and JRE.
You can check JRE architecture using the code below:
public class JavaApplication12 {
public static void main(String[] args) {
System.out.println(System.getProperty("sun.arch.data.model"));
}
}
If VLC is 32bit then the JRE must be 32 bit too, and if VLC is 64 then JRE must be 64 too.
Upvotes: 1