I am trying to play video in JPanel using vlcj in ubuntu, there is no error. My project builts successfully. but do not plays video. when i run code JFrame comes for a while. when i use same code in windows. it plays video and works successfully, but not in ubuntu.
In output window , it show following
A fatal error has occured in java runtime enviournment.
(and so many things.)
Following is my code : (i am using 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(); } }
And plz tell me which path to give for vlc player in ubuntu. there are more than 5 folders with name vlc. one is in /usr/share/ and other is in /etc/ and so on.