Search code examples
javapluginsvlcj

VLCJ cant find plugins in normal installation


My VLC.exe works fine with a bit of lag. But my simple VLCJ code does not work.

import javax.swing.JPanel;
import com.sun.jna.NativeLibrary;
import javax.swing.JFrame;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

public class VideoPanel extends JPanel {

private static final String NATIVE_LIBRARY_SEARCH_PATH = "C:/Program Files/VideoLAN/VLC";

private EmbeddedMediaPlayerComponent mediaPlayerComponent;

public VideoPanel() {
    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), NATIVE_LIBRARY_SEARCH_PATH);
    mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
    this.add(mediaPlayerComponent);
}
public static void main(String args[]){
    JFrame frame = new JFrame();
    frame.add(new VideoPanel());
    frame.setBounds(100, 100, 800, 450);
    frame.setVisible(true);
}
}

I am using 64bit java 1.8.0_60. And I am using vlc 2.2.4 64bit on Windows 10 64bit.

My error message was this.

[00000000018bbbb0] core libvlc error: No plugins found! Check your VLC installation. Exception in thread "main" java.lang.RuntimeException: Failed to initialise libvlc.

This is most often caused either by an invalid vlc option being passed when creating a MediaPlayerFactory or by libvlc being unable to locate the required plugins.

If libvlc is unable to locate the required plugins the instructions below may help:

In the text below represents the name of the directory containing "libvlc.dll" and "libvlccore.dll" and represents the name of the directory containing the vlc plugins...

For libvlc to function correctly the vlc plugins must be available, there are a number of different ways to achieve this: 1. Make sure the plugins are installed in the "/plugins" directory, this should be the case with a normal vlc installation. 2. Set the VLC_PLUGIN_PATH operating system environment variable to point to "".

More information may be available in the log.

at uk.co.caprica.vlcj.player.MediaPlayerFactory.(MediaPlayerFactory.java:300) at uk.co.caprica.vlcj.player.MediaPlayerFactory.(MediaPlayerFactory.java:259) at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.onGetMediaPlayerFactory(EmbeddedMediaPlayerComponent.java:349) at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.(EmbeddedMediaPlayerComponent.java:217) at VideoPanel.(VideoPanel.java:19) at VideoPanel.main(VideoPanel.java:31)

What should I do?


Solution

  • This is a not uncommon problem, especially it seems on Windows platforms.

    The vlcj introduction tutorial uses this code to find the native library and its plugins:

    package tutorial;
    
    import uk.co.caprica.vlcj.binding.LibVlc;
    import uk.co.caprica.vlcj.discovery.NativeDiscovery;
    
    public class Tutorial {
    
        public static void main(String[] args) {
            boolean found = new NativeDiscovery().discover();
            System.out.println(found);
            System.out.println(LibVlc.INSTANCE.libvlc_get_version());
        }
    }
    

    This NativeDiscovery class encapsulates everything needed, including setting the VLC_PLUGIN_PATH environment variable, for the most common cases.

    This is the recommended way to make sure LibVLC gets properly initialised with vlcj, so please try it.