vlcj not displaying the video
- by Cássio Eudardo
I'm using vlcj to play video, but the video doesn't display on some computers(i tested in 4 and worked on 2, all windows), on 1 it displays the button but not the video and on the other it just display a gray background without the button. I tested .wmv and .avi files. I'm using the following code:
public class Video extends JFrame implements WindowListener{
private JPanel contentPane;
private JButton btnClose;
private Dimension size;
private float aspectRatio;
private EmbeddedMediaPlayer mediaPlayer;
public Video()
{
try
{
size = Toolkit.getDefaultToolkit().getScreenSize();
aspectRatio = (float)size.width/size.height;
String file = "...";
btnClose = new JButton("X");
btnClose.addActionListener(new ActionListener()
{...});
btnClose.setBounds(640 - 50, 10, 40, 40);
setBounds(size.width/2 - 320, (int)(size.height - 40*aspectRatio) - 250, 640, 200);
contentPane = new JPanel();
contentPane.setLayout(null);
setContentPane(contentPane);
WindowsCanvas surface = new WindowsCanvas();
contentPane.setBounds(0, 0, 640, 200);
surface.setBounds(0, 0, 640, 200);
MediaPlayerFactory factory = new MediaPlayerFactory(new String("--no-video-title-show"));
mediaPlayer = factory.newEmbeddedMediaPlayer();
surface.addMouseListener(new MouseListener()
{...});
contentPane.add(btnClose);
contentPane.add(surface);
setVisible(true);
mediaPlayer.setVideoSurface(factory.newVideoSurface(surface));
mediaPlayer.setRepeat(true);
mediaPlayer.playMedia(file);
}
catch(Exception e)
{
}
}}