JVLC on Linux with JInternalFrame: X11 errors
Posted: 14 Mar 2009 01:24
Hello,
I'm trying to use JVLC as part of a larger Java application. Things seem to work OK on Windows. On Linux, however, I'm getting an error from X11 video output:
What's interesting is that this happens even after I disabled the shared memory for VLC.... Switching between --vout=xvideo and x11 doesn't change anything. I'm currently using vlc that I built from Git a couple of days ago. This issue, however, is nothing new: I've been having it with all stable vlc versions (latest was 0.9.8a).
Anyway, I'm attaching a slightly modified version of VlcClient from samples directory; the chief difference is that it puts VLC's canvas in a JInternalFrame. Steps to reproduce the problem:
1) Start VlcClient. You'll need JVLC and JNA on the classpath.
2) Type or paste a valid file path for a movie into the edit box
3) Click Set Item. The movie should start playing.
4) Start resizing the main window, making it smaller. As soon as the window boundary touches the JInternalFrame boundary, boom.
(In fact, even if you don't do the resizing, it crashes after a while; this just makes it quick.)
I attach my code:
I'm trying to use JVLC as part of a larger Java application. Things seem to work OK on Windows. On Linux, however, I'm getting an error from X11 video output:
Code: Select all
[????????] x11 video output error: X11 request 147.4 failed with error code 8:
BadMatch (invalid parameter attributes)
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 147 (MIT-SHM)
Minor opcode of failed request: 4 (X_ShmGetImage)
Serial number of failed request: 1813
Current serial number in output stream: 1813
Anyway, I'm attaching a slightly modified version of VlcClient from samples directory; the chief difference is that it puts VLC's canvas in a JInternalFrame. Steps to reproduce the problem:
1) Start VlcClient. You'll need JVLC and JNA on the classpath.
2) Type or paste a valid file path for a movie into the edit box
3) Click Set Item. The movie should start playing.
4) Start resizing the main window, making it smaller. As soon as the window boundary touches the JInternalFrame boundary, boom.
(In fact, even if you don't do the resizing, it crashes after a while; this just makes it quick.)
I attach my code:
Code: Select all
/*****************************************************************************
* VlcClient.java: Sample Swing player
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
*
* Created on 28-feb-2006
*
* $Id: AudioIntf.java 8 2006-02-28 12:03:47Z little $
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*/
import java.awt.Canvas;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
import java.awt.BorderLayout;
//import javax.swing.JFrame;
import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.Playlist;
import org.videolan.jvlc.VLCException;
class VLCPlayerFrame extends JInternalFrame
{
private Playlist playlist;
public Canvas jvcanvas;
public VLCPlayerFrame()
{
initComponents();
}
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
fullScreenButton = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
setButton = new javax.swing.JButton();
pauseButton = new javax.swing.JButton();
stopButton = new javax.swing.JButton();
jvcc = new JPanel();
jvcanvas = new java.awt.Canvas();
jvcanvas.setSize(200, 200);
jvcc.add(jvcanvas);
jvlc = new JVLC(new String[] {"-vvv", "--no-x11-shm", "--no-xvideo-shm"});
playlist = new Playlist(jvlc);
setLayout(new java.awt.GridBagLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
getContentPane().add(jvcc, gridBagConstraints);
fullScreenButton.setText("FullScreen");
fullScreenButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
fullScreenButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(fullScreenButton, gridBagConstraints);
jTextField1.setText("file:///home/frank/test.mp4");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
getContentPane().add(jTextField1, gridBagConstraints);
setButton.setText("Set item");
setButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
setButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(setButton, gridBagConstraints);
pauseButton.setText("Play/Pause");
pauseButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
pauseButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(pauseButton, gridBagConstraints);
stopButton.setText("Stop");
stopButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
stopButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(stopButton, gridBagConstraints);
pack();
}
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
playlist.stop();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
playlist.togglePause();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void setButtonActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
jvlc.setVideoOutput(jvcanvas);
playlist.add(jTextField1.getText(), "a.avi");
playlist.play();
}
catch (VLCException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void fullScreenButtonActionPerformed(java.awt.event.ActionEvent evt)
{
// jvlc.fullScreen();
}
private javax.swing.JButton setButton;
private javax.swing.JButton pauseButton;
private javax.swing.JButton stopButton;
private javax.swing.JButton fullScreenButton;
private javax.swing.JTextField jTextField1;
private JPanel jvcc;
public JVLC jvlc;
// MediaControlInstance mci;
}
public class VlcClient
{
public static void main(String[] args)
{
JFrame pfr = new JFrame("Parent");
JDesktopPane dtp = new JDesktopPane();
dtp.setPreferredSize(new java.awt.Dimension(1000, 1000));
pfr.add(dtp);
pfr.pack();
pfr.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent ev)
{
System.exit(0);
}
});
pfr.setVisible(true);
JInternalFrame f = new VLCPlayerFrame();
dtp.add(f);
f.setVisible(true);
}
}