2 u012751110 u012751110 于 2014.12.21 14:00 提问

基于vlcj的视频播放器,为什么无法播放视频

package demo1;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;

import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

public class Tutorial2B {

private final EmbeddedMediaPlayerComponent mediaPlayerComponent;

public static void main(final String[] args) {
    if (RuntimeUtil.isMac()) {
        NativeLibrary.addSearchPath(
                RuntimeUtil.getLibVlcLibraryName(), "/Applications/VLC.app/Contents/MacOS/lib"
                );
    }else if (RuntimeUtil.isWindows()) {
        NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "D://Program Files//VideoLAN//VLC"); 
    }else if (RuntimeUtil.isNix()) {
        NativeLibrary.addSearchPath(
                RuntimeUtil.getLibVlcLibraryName(), "/home/linux/vlc/install/lib"
                );
    }
    Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            new Tutorial2B();

        }
    });
}

private Tutorial2B() {

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

    mediaPlayerComponent.getMediaPlayer().playMedia("F:\\test.mp4");
}

}

2个回答

ma726518972
ma726518972   2016.02.25 15:43

视频路径需要和项目路径在一个文件夹下 别问我怎么知道的

qq_35740955
qq_35740955 终于找到答案了==
6 个月之前 回复
sinat_29741049
sinat_29741049   2015.09.17 20:51

vlcj-3.0.1.jar 是32位的吧,jdk是64位的吧

Csdn user default icon
上传中...
上传图片
插入图片