Geertjan's Blog

Swing YouTube Player

Geertjan Wielenga
Product Manager
NetBeans IDE 6 is out. Time to hurry to http://www.netbeans.tv/ and check for movies. Another place is YouTube, a few interesting things can be found there too. Here's one way of doing it, using a Swing YouTube Player:

YouTube is really well integrated here, for example, you can scroll through related movies within the browser component, i.e., note the "left" and "right" arrows on the two sides of the screenshot below. And, at the bottom of the currently playing movie, you can see small Ajaxy thumbnails, which move in and out as the mouse hovers over them and which you can click, at which point the selected movie starts instead of the current one:


  • YouTube Data API. Pulls the information from YouTube.
  • HTML Tidy. Parses the returned HTML page, looking for the OBJECT element and extracts the embedded URL from there.
  • WebRenderer. Provides the embedded browser component.

The latter of the three above was the hardest bit, and it still isn't perfect. First, I searched in vain for a Flash API. One that works on Linux, up to date with the latest Flash versions and, preferably, free and open source. Nothing out there meets these requirements. Secondly, I wrestled with JDIC and then gave up. Simply doesn't work with FireFox. Mozilla and Internet Explorer only, neither of which are an option. I also played with Rich Unger's JDIC Browser plugin from java.net, to no avail. I got quite far, but for the same FireFox reasons, couldn't succeed.

I then basically threw my hands in the air until I suddenly thought: "Who said that JDIC is the only available browser component?" Then I googled around and found WebRenderer. Not ideal, at all, because it is commercial. On the other hand, it doesn't involve native libraries, unlike JDIC, which is a big plus in my book. So, because I simply wanted to get something working, I got the evaluation download. Everything works as expected, basically, except that I'm having problems reloading new movies. (I write a temporary HTML file, as suggested by Sandip in the comments of the previous blog entry.) I don't want to invest too much time on this part, because WebRenderer can't be the real solution. I also get annoying messages about this being an evaluation version, as one might expect. So, my question is, does anyone know of other browser components? I would be so grateful if I could finish this application. And then port it to the NetBeans Platform, of course.

Join the discussion

Comments ( 12 )
  • Dominique De Vito Monday, December 3, 2007

    I have listed the browser components I have already encountered in my post <a href="http://www.jroller.com/dmdevito/entry/revisiting_xhtml_as_a_base">Revisiting XHTML as a base (?) for XUL-like programming</a>. I hope this will help you.

  • Patrick Tuesday, December 4, 2007


    is it possible to download the YouTube Player?

    Thanks in advance

  • Geertjan Wednesday, December 5, 2007

    Dominique, thanks for the tip! Good article. Do you know of embedded browser components that support Flash and that are cross-platform compatible? Dominique, I'm sorry I can't distribute the player because it uses a commercial embeddable browser component. I hope to write a tutorial sometime, which would explain how you can create the player yourself.

  • Natie Klopper Tuesday, December 11, 2007

    Not to change the subject too much, hehe. Just another HTML parser you may want to use, because I always had a bit of trouble with tidy, reason being it is still under dev.

    The following parser felt like I was parsing XML. :O


  • Natie Klopper Tuesday, December 11, 2007

    Dunno if this might help.


    It's a pure Java HTML renderer. I think. Haven't tried it yet.

  • Jose Friday, December 14, 2007

    Lobo/Cobra does not support Flash, but that is a fairly common request.

  • wernerino Thursday, January 24, 2008

    Hi, did you have a look into embedding JRex instead of WebRenderer?

    What is the pricing of WebRenderer?, they do not mention it explicitly on their page...

  • ben Saturday, April 17, 2010

    Hi i am kinda n0vice ... is there any source code for this?

  • ben Saturday, April 17, 2010

    Is it possible to have a source?

  • Flavio Friday, April 23, 2010

    I tried the 30-days trial package of WebRenderer (WebRenderer-5.0-Swing-Linux) on a 64bit system but it doesn't run properly. I.e. the demo application doesn't run due to the following problem:

    java.lang.UnsatisfiedLinkError: /home/user/.webrendererswing5/linux/corecomponents/libmozz.so: /home/user/.webrendererswing5/linux/corecomponents/libmozz.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)

    On Windows it works properly.

    What's the problem???

  • Mike Thursday, September 23, 2010

    I doesn't support 64 bit. Same issue with mozswing. Noone supports 64 bit. These component have stalled years ago. Noone can be bothered.

  • guest Monday, November 25, 2013

    hello sir, this is pretty good, will to please let me know about the tutorial or code so that i can implement this.

    please if u mail me with the detail.

    Thanks in advance

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.