我想在ubuntu中使用vlcj在JPanel中播放視頻,沒有錯誤。我的項目成功建立,但不播放視頻。當我運行代碼JFrame來了一段時間。 當我在Windows中使用相同的代碼時,它播放視頻,併成功運行,但在Ubuntu中,不。無法在ubuntu中使用vlcj在JPanel中播放視頻13.04
以下是輸出窗口。
代碼的輸出窗口
以下是我的代碼:(我用vlcj-3.0.1)
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();
}
}
並請告訴我哪條路徑給出了在Ubuntu VLC播放。名稱vlc有超過5個文件夾。一個是/usr/share/
,另一個是/etc/
等。
目前尚不清楚如何解決quesion。 – h7r 2015-02-07 22:16:09
它不能解決問題,但它給了我視頻不播放 – 2015-02-11 08:38:24
的原因,如果你重新命名'/ usr/lib/vlc/lua/meta/reader/filename.luac'視頻播放,但是你失去了對YouTube的支持。 – schasoli 2015-02-19 08:25:16