这是非常特别的,所以我希望这里有人以前在 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"
如此处所示。
直接从 cmd 运行 jar 文件就可以了,那么为什么这不能在 BlueJ 中进行测试呢?