[英]Unable to play video in JPanel using vlcj in ubuntu 13.04
我正在嘗試使用ubuntu中的vlcj在JPanel中播放視頻,沒有錯誤。 我的項目成功構建,但是沒有播放視頻。 當我運行代碼時,JFrame出現了一段時間。 當我在Windows中使用相同的代碼時,它可以播放視頻並成功運行,但是在Ubuntu中則不能。
以下是輸出窗口。
代碼的輸出窗口
以下是我的代碼:(我正在使用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播放器提供的路徑。 有5個以上名為vlc的文件夾。 一個在/usr/share/
,另一個在/etc/
,依此類推。
編輯:
運行時,找到路徑“ vlc Player的路徑(已安裝)”: java -jar vlcj-3.0.1-tests.jar
作為符號鏈接,可以使用: "/usr/lib/libvlc.so.5"
java -jar vlcj-3.0.1-tests.jar
"/usr/lib/libvlc.so.5"
由於此代碼也粘貼在其他論壇中。 32位java7和vlc存在ubuntu問題。 這個問題在這里得到了很好的解釋: https : //github.com/caprica/vlcj/issues/62
解決方法是重命名filename.luac
在ubuntu 14.04上,您可以在這里找到它: /usr/lib/vlc/lua/meta/reader/filename.luac
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.