I got following error:
Code: Select all
[00000001] main libvlc debug: VLC media player - version 0.9.0-test3-20080727-0004 Grishenko - (c) 1996-2008 the VideoLAN team
[00000001] main libvlc debug: libvlc was configured with ./configure '--enable-debug' '--host=i586-mingw32msvc' '--build=i386-linux' '--enable-shared-libvlc' '--enable-sdl' '--with-sdl-config-path=/usr/win32/bin' '--disable-gtk' '--disable-hal' '--disable-libcdio' '--enable-nls' '--enable-skins2' '--enable-ffmpeg' '--with-ffmpeg-mp3lame' '--with-ffmpeg-faac' '--with-ffmpeg-zlib' '--with-ffmpeg-config-path=/usr/win32/bin' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-twolame' '--enable-dvdread' '--disable-vcdx' '--disable-cddax' '--enable-mozilla' '-
[00000001] main libvlc debug: translation test: code is "C"
Exception in thread "main" java.lang.IllegalStateException: Component must be displayable
at com.sun.jna.Native.getComponentID(Native.java:159)
at org.videolan.jvlc.JVLC.setVideoOutput(JVLC.java:90)
at at.uniklu.unikluni.client.gui.JVLCPanel.<init>(JVLCPanel.java:64)
at at.uniklu.unikluni.client.gui.JVLCPanel.main(JVLCPanel.java:128)
Code: Select all
package at.uniklu.unikluni.client.gui;
import java.awt.Canvas;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.videolan.jvlc.Audio;
import org.videolan.jvlc.JVLC;
import org.videolan.jvlc.MediaDescriptor;
import org.videolan.jvlc.MediaList;
import org.videolan.jvlc.MediaListPlayer;
import org.videolan.jvlc.MediaPlayer;
import org.videolan.jvlc.Video;
import at.uniklu.unikluni.client.listener.ClientMediaPlayerListener;
public class JVLCPanel extends JComponent {
private static final long serialVersionUID = -3316671696374369195L;
private static final String[] vlcArguments = new String[] {"--plugin-path=lib\\plugins"};
private Video video;
private Audio audio;
private MediaDescriptor mediaDescriptor;
private MediaPlayer player;
private JVLC jvlc;
private JVLCCanvas jvlcCanvas;
/**
* Constructor.
* @param source (e.g.: "C:/11-eclipseWorkspace/test-videos/t-en.mpg")
* @param number
* @param width
* @param height
*/
public JVLCPanel(String source, int width, int height) {
super();
super.setSize(width, height);
//jvcc = new JVLCCanvas(width, height);
//jvcc.setVisible(true);
//this.add(jvlcCanvas);
Canvas jvcc = new Canvas();
jvcc.setSize(width, height);
jvcc.setVisible(true);
this.add(jvcc);
//jvlc = jvlcCanvas.getJVLC();
jvlc = new JVLC(vlcArguments);
mediaDescriptor = new MediaDescriptor(jvlc, source);
player = mediaDescriptor.getMediaPlayer();
player.addListener(new ClientMediaPlayerListener());
video = new Video(jvlc);
audio = new Audio(jvlc);
// video.setSize(width, height);
//if (jvcc.isDisplayable()) {
jvlc.setVideoOutput(jvcc);
//}
this.play();
}
/**
* Set new source to play.
* @param source
*/
public void setSource(String source) {
mediaDescriptor = new MediaDescriptor(jvlc, source);
stop();
player = null;
player = mediaDescriptor.getMediaPlayer();
}
/**
* Start player.
*/
public void play() {
player.play();
}
/**
* Stop player.
*/
public void stop() {
player.stop();
}
/**
* Set mute.
* @param mute
*/
public void setMute(boolean mute) {
audio.setMute(mute);
}
/**
* Set volume.
* @param volume
*/
public void setVolume(int volume) {
audio.setVolume(volume);
}
/**
* Return JVLC.
* @return
*/
public JVLC getJVLCObject() {
return jvlc;
}
/**
* Set window size.
*/
public void setSize(int width, int height) {
super.setSize(width, height);
video.setSize(width, height);
}
public static void main (String[] args) {
JVLCPanel jp = new JVLCPanel("C:/11-eclipseWorkspace/test-videos/t-en.mpg", 640, 480);
jp.setVisible(true);
JVLCPanel jp2 = new JVLCPanel("C:/11-eclipseWorkspace/test-videos/t-en.mpg", 640, 480);
jp2.setVisible(true);
JFrame jf = new JFrame("test");
jf.add(jp);
jf.add(jp2);
jf.setVisible(true);
// Canvas canvas = new Canvas();
// canvas.setSize(200,200);
// JFrame jf = new JFrame("test");
// jf.add(canvas);
//
// JVLC jvlc = new JVLC(new String[]{"--plugin-path=lib\\plugins"});
// MediaList ml = new MediaList(jvlc);
//
// MediaListPlayer mlp = new MediaListPlayer(jvlc);
// mlp.setMediaList(ml);
//
// ml.addMedia(new MediaDescriptor(jvlc, "C:/11-eclipseWorkspace/test-videos/t-en.mpg"));
// //jvlc.setVideoOutput(canvas);
//
// mlp.playItem(new MediaDescriptor(jvlc, "C:/11-eclipseWorkspace/test-videos/t-en.mpg"));
//
}
}
cheers,
mkeuschn