August 20, 2009

Video in Java, no more JMF please, use JavaFX!

I often get email from people asking me to help them with playing video in Java using JMF & FOBS, probably because of my post from last year: playing-flash-video-flv-with-java

The reason why I'm writing this is to make it clear to people that time has moved on since last year, and the long awaited Java Media Components framework which was annouced a few years ago has finally hit the shelves as the media playing capability built into JavaFX. So rest assured, you don't have to hack your way around JMF to integrate FFMPEG to play all your movies.

Just follow this link to the JavaFX samples website, there are plenty of better ways to play video in Java than a year ago. But you'd have to use JavaFX for that, don't worry JavaFX is simple and runs under Java so it integrates well with a regular Java app/applet.

Eclipse XML DetailFormatter

Having had to work with XML a lot for a current project I was tired of drilling down the DOM objects in Eclipse's debugger so I went looking on the net for an Eclipse debug detail formatter and found one here:

I do had to remove a few lines to get it to work so here is my version, enjoy formatted XML tags from a DOM tree:
if (this == null) return null;

javax.xml.transform.TransformerFactory tf = javax.xml.transform.TransformerFactory.newInstance(); 

javax.xml.transform.Transformer transformer = tf.newTransformer();

transformer.setOutputProperty( javax.xml.transform.OutputKeys.METHOD, "xml");
transformer.setOutputProperty("{}indent-amount", "3" );

javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(this);
if (source == null) return "Corrupted XML document: " + this.toString(); os = new; result = new;

return os.toString ();