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

扶醉桌前 提交于 2019-12-06 07:18:27

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/17540794/how-to-play-mp4-video-in-java-swing-jframe-using-vlcjis-there-any-other-way-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!