0

My goal here is to be able to have a local webpage which I can embed in my GUI. That local page will be able to play a video using VLC. I'm pretty sure I need a plugin to play a video with VLC (other browsers do, right?) but I'm not sure if this is possible in Java.

Is there another way of embedding video into an HTML page and then displaying that using Swing? Is VLC the wrong way to go? I know this project might seem weird but I assure you this is the way I want to do it.

2 Answers2

3

If you're only trying to play video then there are other alternatives to video playback then trying to get a Browser to display properly in Java. Video and Browser's are the two hardest things to do in Swing still and there's no sense trying to tackle both if you only need one.

However, if you do need both then once you have the Browser working you can use Flash pretty easily at that point for a lot of video and audio playback.

I've used two separate solutions for embedding a web browser into a Swing application. The first is pretty simple, you can wrap a SWTBrowser into a java Swing Component. The only downside here is that you get whatever the native browser is on each platform. The second is there is a Swing XULRunner project out there. XULRunner is what Firefox is built upon. It's a bit hard to find the project but it lets you fully customize the browser and use the same one on each platform.

meverett
  • 921
  • 5
  • 6
  • I guess if this is a bad way of approaching things, how should I display video in Swing in a simple way? I've looked at JVLC and it seems overly complicated for what I need: just video. –  Jun 29 '11 at 14:08
  • 1
    I'm afraid there's not a great solution to video playback in Swing. What video extensions are you wanting to play and what OSs are you trying to target? – meverett Jun 29 '11 at 14:34
  • I basically only want a video to play. I don't need controls or fancy menus or anything like that. I have full control over which video gets played when. I'm specifically targeting a Linux environment but I would love for it to be cross platform. –  Jun 29 '11 at 14:39
  • If you're ok using flash, the SWT approach might be the simplest. I just tried accessing youtube on ubuntu with the SWT browser and flash ran fine. I used to have a code example of how to embed an SWT browser in Swing but the companies website is no longer up which it was posted on. – meverett Jun 29 '11 at 14:47
  • I'd forgetten about this project but this is probably the best bet for doing as little work as possible for video/browsers in Swing: http://djproject.sourceforge.net/ns/ It wraps SWT for you and handles cleanup of SWT when their disposed, etc.. – meverett Jun 29 '11 at 14:51
  • But Flash can't handle .avi's and files like that can it? –  Jun 29 '11 at 14:52
  • @meverett: That link looks awesome. Thanks for your help I think this is what I need. –  Jun 29 '11 at 14:54
1

Some older answers:

NOTE that the 2nd option here refers to JWebPane, a project that has pretty much died.

I guess what I'm saying is, the support for this, in Java, out of the box, has never really materialized. You can certainly try JWebPane since it sounds like you're rendering a very simple page, but it may or may not work very well.

Community
  • 1
  • 1
jefflunt
  • 33,527
  • 7
  • 88
  • 126