这是非常特别的,所以我希望此前有人在Windows上使用过VLCJ。
使用Blue J,这是我的测试类:
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.test.VlcjTest;
/**
* An absolute minimum test player.
*/
public class MinimalTestPlayer extends VlcjTest {
public static void main(String[] args) throws Exception {
if(args.length != 1) {
System.out.println("Specify an MRL to play");
//System.exit(1);
}
System.setProperty("VLC_PLUGIN_PATH", "<plugins-path>");
Frame f = new Frame("Test Player");
f.setIconImage(new ImageIcon(MinimalTestPlayer.class.getResource("/icons/vlcj-logo.png")).getImage());
f.setSize(800, 600);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.setLayout(new BorderLayout());
Canvas vs = new Canvas();
f.add(vs, BorderLayout.CENTER);
f.setVisible(true);
MediaPlayerFactory factory = new MediaPlayerFactory();
EmbeddedMediaPlayer mediaPlayer = factory.newEmbeddedMediaPlayer();
mediaPlayer.setVideoSurface(factory.newVideoSurface(vs));
mediaPlayer.playMedia("test.mp4");//args[0]);
Thread.currentThread().join();
} }
当我将它打包到jar文件而没有需要
时,这是有效的-Djna.library.path="C:\Program Files\VideoLAN\VLC\plugins"
或
--plugin-path="C:\Program Files\VideoLAN\VLC\plugins"
如图所示here.
从cmd直接运行jar文件可以正常工作,那为什么不能在BlueJ中测试呢?
答案 0 :(得分:1)
在文件&gt;下的BlueJ中首选项单击“库”选项卡。你可以在那里为VLCJ添加jar文件。当您在BlueJ VM中运行程序时,它将包含该程序包。