سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top