Sunday, May 1, 2011

Airplay through Media Center

So I felt like doing some media center programming this morning. I thought about how cool it would be to get AirPlay working with media center. Unfortunately, my solution is not native to MCE but it seems to work ok. I read this TUAW article about AirMediaPlayer, which opened to the door. AirMediaPlayer was discontinued by the author without releasing the source code, which SUCKS. So I wrote an AutoIt script to bridge the gaps between MCE and AirMediaPlayer. Here's a video of it in action:



How it works:

The first time you run the Airplay app from media center, it launches AirMediaPlayer and also launches a daemon to wait for the airplay connection, then returns you to media center. Now all you have to do is start playing a video on your iDevice, and click the airplay icon to select the computer name of your MCE machine. Once AirMediaPlayer receives the connection, MCE's "Now Playing" title is stopped, then MCE is minimized, and AirMediaPlayer is maximized to full screen mode. When you stop the video from the iDevice, AirMediaPlayer is minimized and you are returned to MCE. It's pretty seamless, although not native.

Setup: AirPlay.zip

1. So first download the zip file an extract the contents to "C:\Airplay\"

2. Run AirMediaPlayer. If you get an error, it's probably because you need to install Bonjour and Quicktime. If you can't get AirMediaPlayer to get airplay videos from your iphone, there is no point in going to Step 3 until you get that working. Once you can airplay videos, move on to step 3.

3. Run the install.cmd This will put the airplay app into media center. I only tested on windows 7 x64, so others will have to find a workaround. you can find the icon in the "Extras menu" or get Advent Media center studio to put it wherever you want it.

4. Launch the addin from media center, and you should see the screen flicker as AirMediaPlayer starts and MCE restores back.

5. Now launch a vid from your iphone, hit the airplay icon and send to MCE. MCE should notice and start the stream.

Other stuff:

There's a config.ini that you can edit that will enable logging or set the timeout of the daemon. The default timeout is 900 seconds (5 minutes). So if you dont send an airplay stream to MCE within that time period, AirMediaPlayer will close and you will have to click the MCE airplay icon again to start it.

Launcher.exe does all the real work. The source code is at launcher.au3 ( an autoit script ) feel free to recompile it if needed. If someone get this going on 32bit let me know and I'll add your changes.

So, that was my sunday... I would love to see Airplay audio, and a native Airplay video solution in the future. I just won't be the dev to do it, I dont have that kind of time anymore.

7 comments:

Da1ek said...

Hi,

The launcher seems to upset Ad-aware's background process monitor.

It declares as a generic trojan...

Doesnt seem to annoy MS essentials tho.

Apart from that , works like a charm.

Treas0n said...

Thanks Dave, anytime one executable launches another it looks like a virus to the scanners. Anyways, glad it worked for you.

Da1ek said...

Theres a newer version of the airplayer out there 1.07 I think , any benefit trying to squeeze it in ?

I've spotted a quirk too , when you run from within WMC it does what it is says it will do. But there is a periodic pause for a fraction of a second.

I thought it might be bandwidth related , did some tests all seemed find but the periodic ( roughly every 30 seconds ? _) was there.

Running the player on its own ( sans launcher ) no pause.

It seemed to be doing it on all three of my media center machines, something the watcher might be doing ?

Cheers

treas0n said...

Yea Da1ek,

I don't know what 1.07 provides but it's worth a shot. The way this is programed sucks, because airplayer is built with .net 3.0, Autoit can't identify when the streaming starts or ends, so it polls the airplayer every X seconds then tries to maximize the airplayer window, hence the lag.

I only wish I had the source code for airplayer, then it could be native in MCE... Maybe one day I'll revisit this, it's great with Apple and microsoft play together.

Da1ek said...

Hi ,

Maybe this will help keep your fiddling with it ?

http://code.google.com/p/airstream-media-player/

Cheers for what you have done so far tho!

Unknown said...

I have a bug. I can start the program without any errors,but when i try to stream via QuickTime (I imstalled it) it doesn't work. But if i change to wmp rendering in the program it works well. Since i cant default the program to wmp, do you know what's wrong with QuickTime.

funky said...

You can also try Aerodrom: http://funky-factory.blogspot.com/
Aerodrom is a AirPlay / AirTunes host wich allows you to stream audio, videos and photos to your Windows PC and/or MCE just like AppleTV.