2014-01-12 58 views
2

我對vlcj努力試圖運行視頻流之後給錯誤和我是從本教程所使用的任何想法,如何解決這一問題,他得到了使用的JFileChooservlcliber路視頻碼 但我改變它來設置路徑直接vlcj運行此代碼

lectur video

第一類

/* 
* To change this license header, choose License Headers in Project Properties. 
* To change this template file, choose Tools | Templates 
* and open the template in the editor. 
*/ 

package video; 

import java.io.File; 
import javax.swing.JFileChooser; 


/** 
* 
* @author isslam 
*/ 
public class start { 
    private static final JFileChooser ourFileSelector = new JFileChooser(); 

    public static void main(String[] args){ 
     String vlcPath="C:\\Program Files\\VideoLAN\\VLC"; 
     String mediaPath=""; 
     File ourFile; 


     ourFileSelector.setFileSelectionMode(JFileChooser.FILES_ONLY); 
     ourFileSelector.showSaveDialog(null); 
     ourFile = ourFileSelector.getSelectedFile(); 
     mediaPath = ourFile.getAbsolutePath(); 
     new Tutorial2A(vlcPath,mediaPath).run(); 
    } 
} 

的第二類

/* 
* To change this license header, choose License Headers in Project Properties. 
* To change this template file, choose Tools | Templates 
* and open the template in the editor. 
*/ 

package video; 

/** 
* 
* @author isslam 
*/ 
import com.sun.jna.NativeLibrary; 
import javax.swing.JFrame; 
import uk.co.caprica.vlcj.component.EmbeddedMediaListPlayerComponent; 
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent; 
import uk.co.caprica.vlcj.runtime.RuntimeUtil; 

    public class Tutorial2A { 
     private final JFrame ourFrame = new JFrame(); 
     private final EmbeddedMediaPlayerComponent ourMediaPlayer; 
     private String mediaPath=""; 



     Tutorial2A(String vlcPath,String mediaURL){ 
     this.mediaPath = mediaURL; 
     NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(),vlcPath); 
     ourMediaPlayer = new EmbeddedMediaListPlayerComponent(); 
     ourFrame.setContentPane(ourMediaPlayer); 
     ourFrame.setSize(500, 500); 
     ourFrame.setVisible(true); 
     ourFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

     } 
     public void run(){ 
     ourMediaPlayer.getMediaPlayer().playMedia(mediaPath); 
     } 
    } 

錯誤信息

Exception in thread "main" java.lang.RuntimeException: Failed to initialise libvlc. 

This is most often caused either by an invalid vlc option begin passed when creating a MediaPlayerFactory or by libvlc being unable to locate the required plugins. 

If libvlc is unable to locate the required plugins the instructions below may help: 

In the text below <libvlc-path> represents the name of the directory containing "libvlc.dll" and "libvlccore.dll" and <plugins-path> represents the name of the directory containing the vlc plugins... 

For libvlc to function correctly the vlc plugins must be available, there are a number of different ways to achieve this: 
1. Make sure the plugins are installed in the "<libvlc-path>/plugins" directory, this should be the case with a normal vlc installation. 
2. Set the VLC_PLUGIN_PATH operating system environment variable to point to "<plugins-path>". 

More information may be available in the log, specify -Dvlcj.log=DEBUG on the command-line when starting your application. 


    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:279) 
    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:236) 
    at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.onGetMediaPlayerFactory(EmbeddedMediaPlayerComponent.java:278) 
    at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.<init>(EmbeddedMediaPlayerComponent.java:168) 
    at uk.co.caprica.vlcj.component.EmbeddedMediaListPlayerComponent.<init>(EmbeddedMediaListPlayerComponent.java:50) 
    at video.Tutorial2A.<init>(Tutorial2A.java:29) 
    at video.start.main(start.java:30) 
Java Result: 1 
BUILD SUCCESSFUL (total time: 19 seconds) 

回答

7

如果使用vlcj 3.0.0,然後vlcj該版本取決於JNA的4.0.0版本。

不幸的是,在Windows上LibVLC和JNA 4.0.0的組合暴露了一個新的錯誤[1]。

提供給你現在在Windows上,唯一的解決辦法要麼是:

  1. 設置VLC_PLUGIN_PATH環境變量( Java系統屬性)爲指向包含VLC插件目錄,例如「c:\ program files \ videolan \ vlc \ plugins」

  2. 確保當您運行Java程序時,當前目錄是「c:\ program files \ videolan \ vlc」。

  3. 使用JNA和Platform Jars的版本3.5.2而不是4.0.0。

很明顯,您用自己的磁盤上適當的內容替換上面的目錄字符串。

這些解決方案都不是理想的。

[1] https://github.com/caprica/vlcj/issues/226

+0

謝謝你這麼多的信息的圖片。我對vlcj完全陌生,並試圖使用3.10.1版本。在將JNA版本更改爲3.5.2後,vlcj開始工作(vlcj版本不變)。 :) – AndrewMcCoist

0

謝謝你,但你讓事情看起來很複雜其實只是使用舊版本,它的工作原理,這是應用enter image description here

+0

是的你的回答正確我知道這就是爲什麼我喜歡你,但你真的嚇到我,當我閱讀你的答案,因爲這個項目將成爲我的大學項目,所以幫助我儘可能多地 –