VLCJ 简单应用程序可以打包为 jar,但不能在 BlueJ 中使用

发布于 2024-12-03 00:03:58 字数 1843 浏览 0 评论 0原文

这是非常特殊的,所以我希望这里有人以前在 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 文件就可以了,那么为什么这不能在测试中工作呢?蓝杰?

This is pretty particular, so I'm hoping someone on here has used VLCJ on windows before.

Using Blue J, here is my test class:

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();

}
}

This works when I package it to a jar file without the need for

-Djna.library.path="C:\Program Files\VideoLAN\VLC\plugins"

or

--plugin-path="C:\Program Files\VideoLAN\VLC\plugins"

as shown here.

just running the jar file from cmd straight up works, so why can't this work in testing in BlueJ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝不服输 2024-12-10 00:03:58

在 BlueJ 中的“文件”>“首选项单击“库”选项卡。您可以在那里添加 VLCJ 的 jar 文件。当您在 BlueJ VM 中运行该程序时,它将包含该包。

In BlueJ under File > Preferences click on the Libraries tab. You'll be able to add the jar file for VLCJ there. When you run the program in the BlueJ VM it will include the package.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文