2014-09-12 102 views
0

我想在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/等。

回答

0

編輯:

  1. 您找到路徑 「VLC播放器的路徑(安裝)」 當您運行:java -jar vlcj-3.0.1-tests.jar 作爲符號鏈接,你可以使用:"/usr/lib/libvlc.so.5"

  2. 因爲這些代碼粘貼在其他論壇也是如此。 32位java7和vlc有一個Ubuntu的問題。這個問題很好這裏explaind:https://github.com/caprica/vlcj/issues/62

作爲一種變通方法命名filename.luac 在Ubuntu的14.04你在這裏找到: /usr/lib/vlc/lua/meta/reader/filename.luac

+0

目前尚不清楚如何解決quesion。 – h7r 2015-02-07 22:16:09

+0

它不能解決問題,但它給了我視頻不播放 – 2015-02-11 08:38:24

+0

的原因,如果你重新命名'/ usr/lib/vlc/lua/meta/reader/filename.luac'視頻播放,但是你失去了對YouTube的支持。 – schasoli 2015-02-19 08:25:16