Java 无法使用ubuntu 13.04中的vlcj在JPanel中播放视频
我尝试在ubuntu中使用vlcj在JPanel中播放视频,没有错误。我的项目成功构建,但未播放视频。当我运行代码时,JFrame会出现一段时间。 当我在windows中使用相同的代码时,它可以播放视频并成功地工作,但在Ubuntu中却不行 下面是输出窗口 代码的输出窗口 以下是我的代码:(我正在使用vlcj-3.0.1) 请告诉我ubuntu中vlc播放器的路径。名称为vlc的文件夹超过5个。一个在Java 无法使用ubuntu 13.04中的vlcj在JPanel中播放视频,java,swing,vlcj,Java,Swing,Vlcj,我尝试在ubuntu中使用vlcj在JPanel中播放视频,没有错误。我的项目成功构建,但未播放视频。当我运行代码时,JFrame会出现一段时间。 当我在windows中使用相同的代码时,它可以播放视频并成功地工作,但在Ubuntu中却不行 下面是输出窗口 代码的输出窗口 以下是我的代码:(我正在使用vlcj-3.0.1) 请告诉我ubuntu中vlc播放器的路径。名称为vlc的文件夹超过5个。一个在/usr/share/中,另一个在/etc/中,依此类推。编辑: 运行时,您会找到路径“vlc播
/usr/share/
中,另一个在/etc/
中,依此类推。编辑:
java-jar vlcj-3.0.1-tests.jar
作为符号链接,您可以使用:“/usr/lib/libvlc.so.5”
filename.luac
在ubuntu 14.04中,您可以在这里找到它:
/usr/lib/vlc/lua/meta/reader/filename.luac
它不能解决问题,但如果重命名/usr/lib/vlc/lua/meta/reader/filename,它会给出视频无法播放的原因。luac
视频可以播放,但youtube不支持。
import com.sun.jna.NativeLibrary;
import java.awt.BorderLayout;
import java.io.File;
import javax.swing.JFrame;
import javax.swing.JPanel;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
class PlayerPanel
extends JPanel {
private File vlcInstallPath = new File("---------------Path of vlc player (installed) --------------");
private EmbeddedMediaPlayer player;
public PlayerPanel() {
NativeLibrary.addSearchPath("libvlc", vlcInstallPath.getAbsolutePath());
EmbeddedMediaPlayerComponent videoCanvas = new EmbeddedMediaPlayerComponent();
this.setLayout(new BorderLayout());
this.add(videoCanvas, BorderLayout.CENTER);
this.player = videoCanvas.getMediaPlayer();
}
public void play (String media) {
player.prepareMedia(media);
player.parseMedia();
player.play();
}
}
class VideoPlayer
extends JFrame {
public VideoPlayer() {
PlayerPanel player = new PlayerPanel();
this.setTitle("Swing Video Player");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(new BorderLayout());
this.setSize(640, 480);
this.setLocationRelativeTo(null);
this.add(player, BorderLayout.CENTER);
this.validate();
this.setVisible(true);
player.play("---------------Path of video we want to play ----------------------");
}
public static void main (String[] args) {
new VideoPlayer();
}
}