VLCJ不能播放视频
问题描述:
请看看下面的代码VLCJ不能播放视频
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媒体。但事实并非如此,它只是用一个空白的窗口打开框架,没有视频,没有声音。有什么问题?请帮助
答
按照@Yohan的要求:尝试使用带正确版本libVLC库的正确版本的VLCJ库。请参考http://code.google.com/p/vlcj/wiki/WhichVersion
+0
谢谢。标记此解决方案:) – 2012-07-13 14:52:44
有人请帮忙! – 2012-07-11 18:42:53
运行上述代码时,是否有任何报告的VLC异常,如'java.lang.UnsatisfiedLinkError'?如果是,请尝试将''c:/ program files/videolan/vlc“'更改为'”c:\\ program files \\ videolan \\ vlc“'和I:/ YouTube(1).mp4” ''to'“I:\\ YouTube(1).mp4”' – 2012-07-12 08:49:54
除此之外,请尝试使用正确版本的VLCJ库和正确版本的libVLC库。请参阅http://code.google.com/p/vlcj/wiki/WhichVersion – 2012-07-12 08:52:20