0

I have been trying to play a video through Java. I am using DJ Native swing to play the video. The following code is getting compiled without any errors but it's not loading the video.

import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JVLCPlayer;

import javax.swing.*;
import java.awt.*;

public class VideoPlayer extends Thread{

    public static void start(final String title) {
        NativeInterface.open();
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame frame = new JFrame(title);
                frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                frame.getContentPane().add(getBrowserPanel(title), BorderLayout.CENTER);
                frame.setSize(800, 600);
                frame.setLocationByPlatform(true);
                frame.setVisible(true);
            }
        });
    }

    public void close(){
        NativeInterface.runEventPump();
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                NativeInterface.close();
            }
        }));
    }
    public static JPanel getBrowserPanel(String url) {
        JPanel webBrowserPanel = new JPanel(new BorderLayout());
        JVLCPlayer jvlcPlayer=new JVLCPlayer();
        webBrowserPanel.add(jvlcPlayer, BorderLayout.CENTER);
        jvlcPlayer.load("filename");
        jvlcPlayer.setControlBarVisible(true);

        return webBrowserPanel;
    }
}
Pang
  • 9,564
  • 146
  • 81
  • 122
  • [Example](http://djproject.cvs.sourceforge.net/*checkout*/djproject/DJNativeSwing-SWTDemo/src/chrriis/dj/nativeswing/swtimpl/demo/examples/vlcplayer/SimpleVLCPlayerExample.java?pathrev=R-1_0_1) here loads the file 1) in background 2) after the JFrame is visible. – PeterMmm Jan 08 '17 at 08:43
  • Did you put `jvlcPlayer.load("filename");` on purpose? What is this **"filename"** literal doing here? Which file should be load by the player and from where? – STaefi Jan 08 '17 at 08:51
  • i hard coded the filename with video i have in my PC. for eg; jvlcPlayer.load("C:/file.mp4"); – krishna kumar Jan 08 '17 at 09:11
  • PeterMmm, I tried running the same code what you have shared. I am getting the output window. If once am selecting the video file to be played, its not loading. am getting some rectangle like image on the top left corner of the window. video is not playing – krishna kumar Jan 08 '17 at 09:26

0 Answers0