I can run a standalone MediaPlayer in eclipse whith this:
Code: Select all
...
...
JVLC jvlc = new JVLC(args);
MediaDescriptor mediaDescriptor = new MediaDescriptor(jvlc, "C:\\test.avi");
MediaPlayer mediaInstance = mediaDescriptor.getMediaPlayer();
mediaInstance.play();
...
...
Code: Select all
import java.awt.Canvas;
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.MediaPlayer;
import org.videolan.jvlc.Video;
public class JVLCPanel extends JPanel {
private static final String[] vlcArguments = new String[] {"--plugin-path=C:\\Documents and Settings\\scarciafratte\\Documenti\\Eclipse.Workspace\\VLC.Client\\addon\\plugins","--no-plugins-cache"};
private static final long serialVersionUID = -3316671696374369195L;
private Video video;
private Audio audio;
private MediaDescriptor mediaDescriptor;
private MediaPlayer player;
private JVLC jvlc;
private Canvas canvas;
/**
* 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);
super.invalidate();
System.out.println("super: " + super.isDisplayable());
this.invalidate();
this.setVisible(true);
System.out.println(this.isDisplayable());
canvas = new Canvas();
canvas.setSize(width, height);
this.add(canvas);
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);
// jvlc.setVideoOutput(canvas);
// this.play();
canvas.invalidate();
canvas.setVisible(true);
}
/**
* 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 Canvas getCanvas() {
return canvas;
}
public static void main (String[] args) throws InterruptedException {
JVLCPanel jp = new JVLCPanel("C:\\test.avi", 720, 576);
System.out.println("main jpanel " + jp.isDisplayable());
jp.invalidate();
jp.setVisible(true);
JFrame jf = new JFrame("test");
jf.add(jp);
jf.invalidate();
jf.setVisible(true);
//******************************************************************
//Here the error!
jp.getJVLCObject().setVideoOutput(jp.getCanvas());
//******************************************************************
jp.play();
System.out.println("main jpanel " + jp.isDisplayable());
System.out.println("main jframe ");
System.out.println("main");
}
}
Code: Select all
jp.getJVLCObject().setVideoOutput(jp.getCanvas());
Code: Select all
*** LibVLC Exception not handled: No active input
Set a breakpoint in 'libvlc_exception_not_handled' to debug.
[00000123] main access error: no access module matched "any"
main
[00000121] main input error: open of `C:\test.avi' failed: could not create access: no access module matched "any"