How to play mp4 video in JAVA (swing) jframe using vlcj?Is there any other way to play mp4 in JAVA?

paru picture paru · Jul 9, 2013 · Viewed 37.4k times · Source

I want to play video file in JAVA(java swing).

I have used JMF(java media framework). But it support .mpg format only.

I want to play .mp4 format video file.

How to do this?

I could play mpg video using this code

 mediaPlayer1.setMediaLocation("file:///C:/mpgvdo/Best_Song2.mpg");
 mediaPlayer1.start();

I want to know how i could use vlcj to play mp4 files.I need complete steps.starting from vlcj installation.

I have included vlcj jar file in netbeans library also added to palette but I did not find vlc player.

Please help me.

Answer

Freak picture Freak · Jul 9, 2013

If you just want to play a mp4 file , then it is so easy

Desktop.getDesktop().open(new File("test.mp4"));

But If you want to play it specifically in JFrame
Then keep in mind that JMF is not supporting mp4.Here you can see the support formats.So for this I suggest you to use Xuggler which is an awesome API AFAIK.A very good example with code is present here
As far as vlcj concerns, here you can find a very good quick start guide and some simple code examples are present here