Search This Blog

Friday, 21 January 2011

And the solution...

Well, this one wasn't the toughest by any stretch. But it does highlight some weird syntax that's possible (though highly frowned upon.)

Rather than putting the square brackets that signal the return type is an array straight after the return type, these can also go after the method declaration. So it's exactly the same as:


public class Test{
public byte[][][] functionArray() {
return null;
}
}


So yes, it compiles and runs fine.

It's a bit of a weird design choice this one - these days it's just there for backwards compatibility, and even the JLS goes so far as to say it shouldn't be used in new code. So stay away from writing it, but if you see some weird old code like this then don't be too shocked :-)

Thursday, 20 January 2011

You know you love them really...

This is a quickie, answer will be posted in due course.

Does this compile, and why / why not?


public class Test{
public byte functionArray()[][][] {
return null;
}
}

Wednesday, 12 January 2011

Java and video

One of the possible future features I've always had in mind for Quelea is decent video support. The ability to import and display avi or mkv files, or to play a clip seamlessly from a DVD. This isn't really something I'd done previously, so I was interested to see the options available. All things considered, I thought that it's such a common thing to want to do there must be one or two good, well accepted libraries around at handling all of the media side of things.

I was wrong. Very wrong!

Considering that I want a cross platform way to do all the above, the amount of options available are considerably limited. The classic one is the JMF, which is probably the best option around. This doesn't mean it's good however - it's woefully outdated, the APIs aren't the best to work with in the world by a long shot and every other question about it asked online seems to end up with something along the lines of "wow, you're using JMF? Good luck..."!

So, I decided to search elsewhere. But really, there's not much of an elsewhere. VLCJ looked like a promising lead but relying on native code that has a habit of completely breaking the VM every so often isn't good for much more than tech demos. FMJ looks good in theory, but no-one can seem to get it to work properly, me included. And JVLC (an earlier project than VLCJ) is full of bugs and completely dead to any kind of activity.

Frantically, I turned to stack overflow for help to see if there was something obvious I'm missing. Seems not!

There is however a glimmer of hope on the horizon. When JavaFX 2.0 is released it looks like it's going to change things dramatically - I for one really hope so. Check out this video at 2:05 for a really impressive video UI demo:
http://www.youtube.com/watch?v=UXSmJYFrulY

That's due sometime later this year. Until then however, it looks like there's no real accepted, good way to deal with video in Java. If I can't wait for JavaFX I might give the JMF a crack... but based on other's experiences, I'm not expecting great things.