Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay video in swing (VLCJ without VLC)
    text
    copied!<p>How can I play a video in swing with the library <code>vlcj</code> without having <code>vlc</code> installed?</p> <p>What I have done:</p> <p>1: Downloaded the <code>vlcj</code> library, <strong>vlcj 2.4.1 (zip)</strong> and add all to build path: (<a href="http://www.capricasoftware.co.uk/downloads/index.html" rel="nofollow">docs1</a>)</p> <p>2: Downloaded the <code>libvlc.dll</code> and <code>libvlccore.dll</code> and put them in project folder: (<a href="http://www.dll-files.com/dllindex/dll-files.shtml?libvlc" rel="nofollow">docs2</a>)</p> <p>(<a href="http://www.dll-files.com/dllindex/dll-files.shtml?libvlccore" rel="nofollow">docs3</a>)</p> <p>3: Downloaded a sample video from http:(<a href="http://support.apple.com/kb/ht1425" rel="nofollow">here video</a>) and put it in project folder: <strong>sample_mpeg4.mp43</strong>: (<a href="http://a1408.g.akamai.net/5/1408/1388/2005110405/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_mpeg4.mp4.zip" rel="nofollow">docs4</a>)</p> <p>I then created the following class to show the video in <code>swing</code>:</p> <pre><code>public class MediaPlayer extends JPanel { // Declares our media player component private EmbeddedMediaPlayerComponent mediaplayer; // This string holds the media URL path private static String mediapath; private JPanel panel; public MediaPlayer() { String projectPath = System.getProperty("user.dir"); String vlcpath = projectPath; mediapath = projectPath + "\\sample_mpeg42.mp4"; // Check if the .dll is correct File f = new File(vlcpath + "/libvlc.dll"); System.out.println("VLC PATH CORRECT: " + f.exists()); NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcpath); mediaplayer = new EmbeddedMediaPlayerComponent(); panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(mediaplayer, BorderLayout.CENTER); setLayout(new BorderLayout()); add(mediaplayer, BorderLayout.CENTER); } public void play() { mediaplayer.getMediaPlayer().playMedia(mediapath); } public static void main(String[] args) { MediaPlayer mediaplayer = new MediaPlayer(); JFrame ourframe = new JFrame(); ourframe.setContentPane(mediaplayer); ourframe.setSize(720, 560); ourframe.setVisible(true); mediaplayer.play(); ourframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } </code></pre> <p>}</p> <p>But getting the error:</p> <blockquote> <p>Exception in thread "main" java.lang.RuntimeException: Failed to load the native library. The error was "Unable to load library 'vlc':...</p> </blockquote> <p>Do I need to have something else/more then the <code>libvlc.dll</code> and <code>libvlccore.dll</code>?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload