November 16, 2007

Control Windows Media Player from an Adobe Flex application

I know it's been out there for some time already, but I have just discovered how beautiful Adobe's Flex-Ajax-Bridge is. The FABridge allows you to access Flex applications from javascript. It even allows you to listen for events that occur inside the Flex application and hook javascript callback functions to those events.

This makes it possible to make embed both a Windows Media Player object and a Flex application into a website and make them work together seamlessly. Of course, you probably don't want to actually do this, but that's besides the point. You can replace WMP with any other embeddable third party object that you can control through javascript.

Here's what I am so manically enthusiastic about:
I created a very crude webpage that embeds a WMP object and a very simple Flex application. The Flex app just shows a list of live channels (*.asx) that the user can choose from. When a channel is clicked, the WMP loads that channel and starts playing it. All it takes to make this happen is about 8 lines of javascipt that hooks a tiny event listener function to the click event on the channel list in the Flex app. At each occurance of that event, the listener function sets the URL property of the WMP object to the URL of the channel the user has clicked on. Wonderfully simple. Thank you Adobe!

Just wanted to share this with you. I will post a follow-up on this post with some code fragments and such later.

4 comments:

Gilda Maurice said...

Hi, can you let me know where the code for this is?
Thanks in advance
G

Anonymous said...
This comment has been removed by a blog administrator.
Vikthor said...

Hi i was looking for this could u share the code for this app or where could i find it. thanks

Unknown said...

Hi Vikthor, You can browse the sources here: http://www.xs4all.nl/~mnankman/Web20Stuff/FlexWMP/srcview