Easy way to embed videos in my Swing GUI

I was looking for a while for a dead easy way to embed videos in my Java Swing GUI. Am I chasing the wind? Ideally, I would like to have something like:

VideoPlayer video = new VideoPlayer("filename");
frame.getContentPane().add(video);
video.play();

Am I looking for something that does not exist? I develop mainly for Linux, but taking into account windows, since I can try and make my application cross-platform in the future.

Additional Information:

  • I used to watch JMF and was unhappy with the amount of code needed before the video could be displayed and played. I can visit him again.
  • I thought of a built-in browser that will play videos using VLC, but again, not the easiest of all.
  • I have full control over the video format for playback. They are fixed in quantity and can be re-encoded if necessary.
+5
source share
2 answers

I don't know why you think you need a lot of code to use JMF.


    public class mediaPlayer extends JFrame
    {
        public mediaPlayer()
        {
            setLayout(new BorderLayout());

            //file you want to play
            URL mediaURL = //Whatever
            //create the media player with the media url
            Player mediaPlayer = Manager.createRealizedPlayer(mediaURL);
            //get components for video and playback controls
            Component video = mediaPlayer.getVisualComponent();
            Component controls = mediaPlayer.getControlPanelComponent();
            add(video,BorderLayout.CENTER);
            add(controls,BorderLayout.SOUTH);
        }
    }

A full media player, like 6 lines, could make it smaller. If all you need is something basic then id go to JMF.

As Zemzela said, Xuggle is also a good solution, but will require more work.

There are also Java VLC bindings. Press here

+6
source

xuggle. http://www.xuggle.com/. avi (divx) "". JMF xuggle. java , , Thread.sleep(30) 30 , Windows 16 , 30 . linux , , 1 .

+2

All Articles