Java Media Player - First GUI Demo
Java Media Player - First GUI Demo
Join the DZone community and get the full member experience.Join For Free
Learn how to build stream processing applications in Java-includes reference application. Brought to you in partnership with Hazelcast.
The Java Media Player is back on track, and I have a Web Start Demo to prove it! The reason I haven’t blogged in a while is because I haven’t made much progress compared to the time spent. I didn’t have that many problems with making things work on the Mac, except for some window ordering problems that seems to be Mac related. But creating a version without problems that worked on both the Mac and on Windows was an exercise in mind control, Vulcan style. The process was like the old game on circus where you hit frogs with a stick. Hit one and it goes away, but another one pops up…
The performance problem I reported in the last blog is all but gone. It’s not like the problem has been solved from Java’s side, I have just found a very narrow way around the problems. Let me explain.
The problem was that turning a window translucent would absolutely kill performance on Windows, for reasons mentioned in the last blog. I initially made one window for all graphics but that was way too slow since it needed it to be translucent. I now have four (4!) windows and it will be at least five before I’m done.
One window is the shadow for the main window. That window is also the main application window when you count the order and owner, strangely enough, but it had to be that way. Since the shadow should show the background though it is of course translucent. But since the graphics is almost never changed the performance isn’t that relevant.
Both sidebar windows are now normal JDialogs, but undecorated of course. They have set the shadow window as the “owner” window since it needs to be on top of it. They don’t change size when they slide, that was too slow and jerky on the Mac, it is just the graphics in the window that slides. These are also translucent and paints their own shadow. The performance here is good enough since they don’t change too much, the number of pixels are quite small and I can have full control of the painting process and optimize it like a mad pixel pushing junkie.
The main window is a normal window, but it is “shaped” on Windows and translucent on the Mac. This means that hardware acceleration will be in place for the main window, where it is most needed. You can see that it is a shaped window on Windows since the corners are pixelated. I do however have a sneaky way to solve this. I will paint the corners on the background shadow window instead, where we have translucency and thus anti aliased clipping/shapes.
If you run the Web Start demo you can see the GUI in action. Or at least parts of it. Please don’t be disappointed, it is far far from ready yet, but I have made the critical things work, things that required performance to be “enough”. There are still a lot of optimizations left to do. For instance I don’t use Romain Guy’s much faster blur algorithm for calculating the shadows, I use the naive approach with Gaussian blur, which is quite slow.
The app will need Java 1.6.0_10 on anything other than Mac. On OS X Java 1.5 is fine. I have not tested this on Linux, it will probably look like sh*t. Anyway, most things are just mockups, feel free to click around.
I will continue to update the app in place as I develop it and the same web start link will be used. Note that there are no media stuff in it at all, so don’t think it will play your mp3s, because it won’t. Yet… The app is signed with an old certificate so you will get a security warning. I will fix that when I get around to it.
The size of the whole app is 180k, most of it images, and it is pack200 compressed. If you are on update 10 that “.pack.gz” file will be used, otherwise you will have a 400k jar instead…
Well, enough babbling, just try it and let me know what you think. Is Java always ugly?
Opinions expressed by DZone contributors are their own.