I’m trying to create a cross-platform app in Java, using libvlc to play video. I’ve been searching the web a lot but I haven’t found any code to load libvlc independently on the platform used (Mac, Win, Linux – 32 or 64 bit). I use JNA library to load libvlc.
For example, this is the code which loads libvlc from the default installation path on Mac:
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "/Applications/VLC.app/Contents/MacOS/lib/");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
But what if the user changes the installation path of VLC.app?!
So I need to create a path independent, cross-platform loading code. Generally I just don’t know where to get the path to the folder containing the libvlc library.
Thanks for any ideas.
thanks for your help, but I found better solution. After few hours of reading of VLCJ’s javadoc I noticed NativeDiscovery class, which has all these common paths already saved.
The only con of this solution is, that if the user has installed the VLC into custom location, you are still forced to ask him, where the library is.