Airfoil interacting with Airplay and Apple Remote

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Mon Nov 19, 2012 2:01 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Airfoil interacting with Airplay and Apple Remote

I set up an alarm clock "app" at the weekend with an old iPhone as the "bedside clock" that I use to set the alarm time and provide the Snooze and Off buttons.
I use Airfoil and the itunes plugins to play music to my wireless speakers connected by an Airport Express.
It all works great except if I've been using Apple Remote and Airplaying the iTunes music to a different set of speakers. It seems that Airfoil is not able to take control of the speaker routing if Airplay is enabled and pointing at different speakers.
If I deselect the speakers on iTunes, Airfoil is able to select the correct speaker routing.

Is there any way to override iTunes' Airplay assignment to allow Airfoil to do its thing?

Second issue seems to be a hit or a miss if the iTunes plugin Play function actually plays or not. It seems pretty random if it's going to work or not.

Posted on
Mon Nov 19, 2012 2:27 pm
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Airfoil interacting with Airplay and Apple Remote

alang_94526 wrote:
Is there any way to override iTunes' Airplay assignment to allow Airfoil to do its thing?


Apparently not - if something is connected via Airplay nothing else can connect until it disconnects (which can happen after a timeout period but that appears to be internal so I don't know the rules).

alang_94526 wrote:
Second issue seems to be a hit or a miss if the iTunes plugin Play function actually plays or not. It seems pretty random if it's going to work or not.


The only known issue is that controlling when listening to radio stations seems to work slightly differently than when controlling local media. Again, because there's no published API, I don't really know what the differences are. I never listen to radio stations and never have any issue with Play/Pause working correctly.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Nov 19, 2012 3:43 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Re: Airfoil interacting with Airplay and Apple Remote

I dug around some more and found this link
http://bendodsonapps.com/weblog/2011/01 ... plescript/
which I adapted and stripped down to this:

Code: Select all
tell application "System Events"
   tell application "iTunes"
      set visible of front browser window to true
   end tell
   delay 0.2
   
   tell window "iTunes" of application process "iTunes"
      click button 10
      keystroke "C"
      keystroke return
   end tell
end tell


The front browser setting is not technically needed but essentially click button 10 selects the Airplay icon.
Pressing button C selects the computer's internal speaker which is the same thing as turning off Airplay
Then press return to make the selection.

Posted on
Mon Nov 19, 2012 3:49 pm
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Airfoil interacting with Airplay and Apple Remote

Cool, thanks for sharing!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 21, 2012 2:43 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Re: Airfoil interacting with Airplay and Apple Remote

1 word of caution with the script above (as I found to my peril).
It doesn't work if you enable either screensaver or require a password to log in.
It is fine with Energy Saver setting the display to go off, but for some reason both screen saver and logging in seems to fail spectacularly.
What happens is the Airplay window does open, but then it halts and never completes the C or return and eventually times out.
To add to that, anything that Indigo thinks it's trying to do at the same time will stop working. I have security cameras that come up with epic failure logs during the time the script is trying to disable airplay.

I haven't found a way around this other than to disable the screensaver and remove the login password, neither of which are a big deal to me, but may not work for other people.

Posted on
Tue Dec 25, 2012 5:39 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Re: Airfoil interacting with Airplay and Apple Remote

The new iTunes 11 behaves a bit differently to iTunes 10.
Posting updated AS code which selects button 9 instead of 10 and for some reason, I had to extend the delay between C and return.
Code: Select all
ell application "System Events"
   tell application "iTunes"
      activate
      set visible of front browser window to true
   end tell
   delay 0.2
end tell

tell application "System Events"
   tell application "iTunes"
      activate
      set visible of front browser window to true
   end tell
   delay 0.2
   
   tell window "iTunes" of application process "iTunes"
      click button 9
      delay 0.2
      keystroke "C"
      delay 1
      keystroke return
   end tell
end tell


Now I have to figure out how to fix iTunes 11's broken Shuffle command

Posted on
Fri May 31, 2013 9:31 am
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Re: Airfoil interacting with Airplay and Apple Remote

With the installation of iTunes 11.0.3, this method stopped working or at least button 9 is no longer the Airplay button which means I have to go figure out the new button number allocation.
However, iTunes 11.0.3 has finally implemented Airplay support for Applescript so this clunky workaround is no longer required.
I found full details on Applescript support for Airplay at this very handy website:
http://dougscripts.com/itunes/category/itunes-11/

I'll spend some time next week dinking around with it but it looks like it will do the job and I won't even need Airfoil.

Posted on
Fri May 31, 2013 10:33 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Airfoil interacting with Airplay and Apple Remote

Just an FYI - I just upgraded my 10.6.8 production server to iTunes 11.0.3 and it's crashing at least once a day. It could be something to do with my server but I just wanted to get the word out there.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 31, 2013 10:54 am
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Re: Airfoil interacting with Airplay and Apple Remote

I've had iTunes 11.0.3 running on my OSX 10.8.3 for about a week now and it hasn't crashed yet (and I'd know about it too since I use it as an alarm clock ;-) )
Try updating your OSX and see if it magically corrects itself

Posted on
Fri May 31, 2013 11:23 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Airfoil interacting with Airplay and Apple Remote

Um, yeah, not gonna happen... :P

I know a lot of our users run Indigo on older hardware that doesn't necessarily support new OS releases...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 31, 2013 5:31 pm
AndrewGWalsh offline
Posts: 67
Joined: Feb 20, 2013

Re: Airfoil interacting with Airplay and Apple Remote

I've upgraded to 11.0.3 too and have considerable instability now after script access to iTunes each day. I haven't got to the bottom of what usage causes it but I suspect that it is the use of Radio via iTunes - Airfoil is stable though.

If I learn anything useful I'll post it.


Andrew

Posted on
Sat Jun 01, 2013 12:27 pm
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Airfoil interacting with Airplay and Apple Remote

I thought that might be it as well, so I rebooted and stopped using radio stations. Crash.

Sigh.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Jun 01, 2013 4:28 pm
AndrewGWalsh offline
Posts: 67
Joined: Feb 20, 2013

Re: Airfoil interacting with Airplay and Apple Remote

My new suspicion is that it is changing playlists - for the last couple of days I have just started and stopped the same playlist. Changing to radio or another playlist programmatically (its fine if I control iTunes manually from the console) means I end up having to restart things.

Andrew

Posted on
Sat Jun 01, 2013 7:27 pm
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Airfoil interacting with Airplay and Apple Remote

Well, I only change the playlist from the iTunes UI (never programmatically), so that's not the issue I'm seeing. FYI...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests