Play video in your dock with AIR

dockvideo screenshotA while back I was thinking if it would be possible to play video in the dock icon with AIR. Then I heard Lee Brimelow ask the same question during his FITC Amsterdam presentation. Last week I had a free moment during the Zurich AIR camp to give it a try and yes… it does work.

First of all let’s think about use-cases for this. Imagine having a video player and when you minimize the app, you can continue watching your video in the dock. Obviously, this will still use the resources needed to actually play the video but I think it’s really cool and wouldn’t actually mind seeing this in an application like the Adobe Media Player. You could even have the user set this option in a prefs panel etc…

Not many people know this but you can programatically set the icon of your AIR application. Christian Cantrell‘s TimeSlide application demo’s how this is done. The source code for that application is available on Google Code but I’ll give you the basics here. I’m sure you’ll be surprised of how easy this is.

To change the dockIcon, you just have to set the NativeApplication.nativeApplication.icon.bitmaps object.

AIR creates the NativeApplication.nativeApplication.icon object automatically. The object type is either DockIcon or SystemTrayIcon, depending on the operating system. You can determine which of these InteractiveIcon subclasses that AIR supports on the current operating system using the NativeApplication.supportsDockIcon and NativeApplication.supportsSystemTrayIcon properties. The InteractiveIcon base class provides the properties width, height, and bitmaps, which you can use to change the image used for the icon.

In this case, all I do is change that bitmap “onEnterFrame” by first drawing the video in a BitmapData object and then adding that BitmapData object to NativeApplication.nativeApplication.icon.bitmaps :

var iconData:BitmapData = new BitmapData(128, 128, true, 0x00000000);
iconData.draw(myVid);
NativeApplication.nativeApplication.icon.bitmaps = [iconData];

The Windows equivalent to the dock icon, is the system tray icon… and yes… it is possible to play video in there too. But it’s obvious that a 16x16px view of your video is somewhat harder to see compared to the 128x128px icon on the Mac.

I’m still polishing the app and I’m going to add some controls etc but I do plan on releasing both the app and source right here next week. One other thing I want to try also is to make the icon bounce to a beat of say a music video I played in the player… That sounds cool to me :D So stay tuned…

Tags: , , , , , , ,

4 Responses to “Play video in your dock with AIR”

  1. sandro 07. Mar, 2008 at 12:54 pm #

    still waiting for the webkit engine running in the dock ;)

  2. Sidney de Koning 24. Mar, 2008 at 8:14 pm #

    Hi Serge,

    Cool to see you also posted on this. I was the one who asked Lee at FITC :) My mind was buzzing with all the new features of AIR! I also created a post about this that you can find here: http://www.funky-monkey.nl/blog/2008/02/28/fresh-breath-of-air-2-animated-video-dock-icon/

    In my example i also dispose of the bitmap object so you can have alpha video running in your dock.

    Greetings,

    Sidney de Koning

Trackbacks/Pingbacks

  1. on AIR London / Review | Psyked - 11. Apr, 2008

    [...] Well, despite coming down with a killer headache 1/2 way through the event, I thoroughly enjoyed the London leg of the on AIR tour. All the guys from Adobe and [most of] the ‘guest speakers’ were really interesting. Toying around with AIR before the event helped understand things a little better, but looking up stuff on the ‘net just doesn’t compare to having it demonstrated on the tour. Like the worlds smallest video player. [...]

  2. Mr R, - 25. Mar, 2009

    @Karl_Freeman http://tinyurl.com/2tsnfm

Leave a Reply