2

请看下面的代码

import com.sun.jna.Native;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

import com.sun.jna.NativeLibrary;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class Tutorial2B {

  private final EmbeddedMediaPlayerComponent mediaPlayerComponent;

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        new Tutorial2B();
      }
    });
  }

  private Tutorial2B() {

      NativeLibrary.addSearchPath(
      RuntimeUtil.getLibVlcLibraryName(), "c:/program files/videolan/vlc"
    );
    Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);

    JFrame frame = new JFrame("vlcj Tutorial");

    mediaPlayerComponent = new EmbeddedMediaPlayerComponent();

    frame.setContentPane(mediaPlayerComponent);

    frame.setLocation(100, 100);
    frame.setSize(1050, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

    System.out.println("Running");

    mediaPlayerComponent.getMediaPlayer().playMedia("I:/YouTube (1).mp4");
  }
}

此代码应该使用 VLCJ 播放媒体。但事实并非如此,它只是用空白窗口打开框架,没有视频,没有声音。有什么问题?请帮忙

4

1 回答 1

2

根据@Yohan 的要求:尝试将正确版本的 VLCJ 库与正确版本的 libVLC 库一起使用。请参考http://code.google.com/p/vlcj/wiki/WhichVersion

于 2012-07-13T00:37:08.190 回答