Search Result for airplay

December 30 2015 - 7:48 am

EPPC and AirPlay Bug?

A Correspondent alerted me to an issue he is seeing, and that I can verify, using the EPPC protocol to access the AirPlay device property via iTunes on a remote machine. For example, with Remote Apple Events enabled on a remote machine, a script like this—that up until recently worked—will fail:

tell application “iTunes” of machine “eppc://user:password@Remote-Machine.local”

set apDevices to (get name of every AirPlay device)

end tell

In this example, you would expect to get a list of the names of the AirPlay devices available on the remote machine. But instead, the script trips up on the word “AirPlay” with the error “Expected class name but found identifier”. “AirPlay device” is a class name. Other conventional iTunes/Remote Apple Events routines work as expected.

Our Correspondent reports that this sort of script worked happily in the past; sounds like he uses it to control iTunes like a server on the remote machine. There have been EPPC-related bugs in the past that were introduced with Security Updates so I’m hoping this is one of those sorts of things and not a deliberate “security feature”. File a bug if you can.

October 30 2013 - 4:35 pm

AirPlay Scripting Bug Fixed in 11.1.2

The bug affecting AirPlay scripting has been fixed in iTunes 11.1.2.

October 17 2013 - 7:07 pm

AirPlay Scripting Workaround

As previously noted, you can’t do this without getting -1728 errors:

tell application "iTunes"

set apDevices to (get AirPlay devices)

end tell

But you can do this:

tell application "iTunes"

set apDevices to (get a reference to AirPlay devices)

— see?

log (get name of apDevices)

— or

repeat with aDevice in apDevices

log (get aDevice‘s name)

end repeat

— or

repeat with aDevice in AirPlay devices

log (get aDevice‘s name)

end repeat

end tell

That’s if you need to do that.

September 23 2013 - 12:12 pm

iTunes 11.1 Breaks Some Airplay scripting

[UPDATE: iTunes 11.1.2 addresses and fixes this issue.]

The latest version of iTunes breaks some scripts I posted when Airplay scripting was introduced back in the Spring.

Specifically, an error will be generated doing something as simple as this:

tell application “iTunes”

set apDevices to (get AirPlay devices)

end tell

Come on. It’s gotta be a bug, right? You can still get properties of AirPlay devices and set the current AirPlay devices property by device name:

tell application “iTunes”

set apDevices to (get name of AirPlay devices)

–> {“Computer”, “Doug’s AirPort Express”}

set current AirPlay devices to AirPlay device “Computer”

end tell

Waiting to see how this evolves.

May 30 2013 - 2:14 pm

Project: Change AirPlay Speakers, Change EQ

I don’t fiddle much with iTunes EQ settings. I most frequently send audio to a receiver and, if necessary, tweak the tone settings there. But I realised that if you’re using AirPlay, you may want a different EQ setting for a selected AirPlay device. If you don’t mind firing a script whenever you want to change AirPlay speakers—and you don’t mind doing some of the script-writing yourself—here’s a simple way to acomplish that.

And I do mean simple. This script is pretty basic and could be finessed much more thoroughly. It will only allow you to select a single AirPlay device (I don’t believe there can be a different EQ for each active AirPlay device simultaneously) but it’ll get the job done.

Here’s the script. Open it in AppleScript Editor:

tell application "iTunes"

set listOfAirPlayNames to (get name of every AirPlay device)

set chosenAirPlayName to (choose from list listOfAirPlayNames with prompt "Change AirPlay Speakers to:")

if chosenAirPlayName is false then return — user pressed Cancel

set chosenAirPlayName to (chosenAirPlayName as text) — coerce to text from list

# This is the part you have to code:

if chosenAirPlayName is "Computer" then set chosenEQName to "Rock"

if chosenAirPlayName is "Apple TV" then set chosenEQName to "My Customized EQ"

if chosenAirPlayName is "Bedroom Airport Express" then set chosenEQName to "Classical"

# and so on…

# apply the changes

set current AirPlay devices to AirPlay device chosenAirPlayName

set current EQ preset to EQ preset chosenEQName

end tell

You will have to supply the names of your AirPlay devices and the name of the EQ setting you want to use with each. The latter is easy, just use the name of an EQ preset as it’s displayed in the Equalizer Window. To get the accurate names of the Airplay devices, just run the script from AppleScript Editor and then right away click the “Cancel” button in the choose list dialog. In the AppleScript Editor Event Log window you’ll see the names listed. Use these names in each of the repeating lines of code in the script. You may have fewer or more than the three example lines in the original script. Edit accordingly.

When those edits have been made, “Save” the script as “Script” and named whatever you like and saved in your [home]/Library/iTunes/Scripts/ folder. And, like my Mom always says, add a keyboard shortcut to launch it.

Remember: if you manually change your AirPlay speakers in iTunes, without using the script, the EQ will not change. That only happens when you run the script.

So also: smarties can probably figure out how to set a discrete volume for each chosen device using the Airplay device sound volume property.

UPDATE: Just to be clear, it is the main iTunes EQ setting that is changed, not the EQ setting for individual tracks.

May 17 2013 - 12:33 pm

More Airplay stuff

Earlier, I posted a way to hardcode the Airplay devices in a script. But if you only have one computer, AirPort Express, or Apple TV kind of Airplay device you can forego using the name property and do something like this, which sets my lone Apple TV as the current Airplay device:

tell application "iTunes"

set current AirPlay devices to (get AirPlay devices whose kind is Apple TV)

end tell

Even though there is only a single item result from Airplay devices whose kind is Apple TV, it’s returned as a list which is what current AirPlay devices takes.

The other kind values, AirPlay device and unknown, are too generic to use this way—unless you know you only have one of them.

May 16 2013 - 5:22 pm

Hardcode Airplay Device Speakers

Correspondent Matt Stevens sent the following, which illustrates how to hard code your Airplay device names:

tell application "iTunes"

set computerSpeaker to (first AirPlay device whose name = "Computer")

set kitchenSpeaker to (first AirPlay device whose name = "Kitchen")

set current AirPlay devices to {computerSpeaker, kitchenSpeaker}

end tell

The current AirPlay devices application property accepts a list—even if the list is only one item.

May 16 2013 - 4:25 pm

Airplay device properties

These are the new Airplay device properties accessible via AppleScript:

active (boolean, r/o) : is the device currently being played to?
available (boolean, r/o) : is the device currently available?
kind (computer/AirPort Express/Apple TV/AirPlay device/unknown, r/o) : the kind of the device
network address (text, r/o) : the network (MAC) address of the device
protected (boolean, r/o) : is the device password- or passcode-protected?
selected (boolean) : is the device currently selected?
supports audio (boolean, r/o) : does the device support audio playback?
supports video (boolean, r/o) : does the device support video playback?
sound volume (integer) : the output volume for the device (0 = minimum, 100 = maximum)

Notice that all the properties are read-only (r/o) except for selected and sound volume, meaning only those two properties can be changed; the others can only be polled.

May 16 2013 - 3:54 pm

Basic Airplay script

This is a pretty basic use of the new Airplay stuff. Select and set your Airplay devices:

tell application "iTunes"

set apNames to (get name of AirPlay devices)

set apDevices to (get AirPlay devices)

set rez to choose from list apNames with prompt "Select Airplay:" with multiple selections allowed

if rez is false then return

set apPlays to {}

repeat with i from 1 to length of apNames

if item i of apNames is in rez then set end of apPlays to item i of apDevices

end repeat

set current AirPlay devices to apPlays

end tell

December 1 2018 - 7:44 pm

Shortcuts and SSHing to Snow Leopard

Like you-wouldn’t-believe-how-many other people, I still run an old Mac Mini with Snow Leopard on it. It’s been pretty reliable as an occasional music server and we still use it to play iTunes internet radio on AirPlay devices around the house. It also manages some backup tasks on my network. It runs headless and I access it through Screen Sharing when necessary.

It is more difficult then it used to be to remotely control Snow Leopard with AppleScript from newer operating systems. At one time, you could just address the machine and run commands with a username and password. Now you need to set up SSH. I haven’t done that and just use Screen Sharing.

But, believe it or not, the Run Script Over SSH action I described earlier works with Snow Leopard out-of-the-box. I will now set about creating a batch of Shortcuts to be able to quickly manage stuff on the Mac Mini with AppleScript, like playing a parrticular radio station in iTunes, shutting music down, changing AirPlay devices and so on, which I can call from my iPhone. Pretty cool.

Site contents © 2001 - 2019 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not interrupt the one doing it.