![]() ![]() Set sound volume of AirPlay device "Hallway" to 20 Set sound volume of AirPlay device "Kitchen" to 10 How can something so trivial, so obvious in iTunes – by and large, the epitome of cruft in legacy software – be completely foreign to Shortcuts, the up-and-coming star of a new breed of automation? And yet here we are – while Shortcuts has no idea how to change the volume levels of connected AirPlay 2 devices, this AppleScript is all it takes iTunes to get it done in a second: tell application "iTunes" In their absence, the solution once again lies in starting playback from iTunes on the Mac and using AppleScript. Ideally, Shortcuts should offer native AirPlay 2 actions to activate speakers and set their volume levels programmatically. For me, tapping a widget is faster than saying “Hey Siri, set the volume to 45 in the kitchen and hallway”. 7 Similarly, when loud music is blasting through every room of the house during the day, I’d rather tweak the volume from the Shortcuts widget on my phone than have to a precise set of instructions to Siri. I don’t want to talk to Siri in the middle of the night and wake the dogs in the process. I mostly need to do this when my girlfriend and I listen to music at night before falling asleep. I love listening to music around the house with my three HomePods (one in the kitchen, one in the hallway, one in the bedroom), but I’ve often found myself wishing there was a quick way to change the global volume level without speaking to Siri. Get the album artwork of the song currently playing on iTunes on the Mac. Instead, my shortcut sends a Magic Variable to the AppleScript that runs on the Mac: a list of playlists is displayed by the ‘Choose from List’ action, and the chosen item is expanded as text upon running the AppleScript on macOS via the SSH action. But that wouldn’t be a great use of what Shortcuts has to offer with its visual automation on iOS. In theory, I could have built a shortcut that played a specific playlists and duplicated it multiple times, changing the name of the playlist in each version. With AppleScript and iTunes, four lines of code are all it takes to start playing a specific playlist on shuffle: tell application "iTunes" Over the years, I’ve been curating a selection of playlists I like to listen to either by myself, with my girlfriend, or when we have friends over at our place. Toggle the player state of the iTunes app on a Mac on the same local network as your iOS device. This is particularly nice when combined with the next shortcut. With this shortcut, I have a one-tap solution to resume iTunes’ playback on all the speakers it was previously connected to without having to manually select them each time. Unlike Control Center on iOS, iTunes on the Mac always remembers the last AirPlay speakers it was connected to (even across restarts) as well as their individual volume levels. Thanks to osascript, this shortcut checks the player state of iTunes and either pauses it (if it’s already playing) or starts playing (if it’s paused). This is an obvious one: I wanted a super-fast shortcut to instantly play or pause iTunes (which is usually sending audio to three HomePods at once) from either the Shortcuts widget on iOS or Siri. With iTunes, I can write AppleScripts that play Apple Music items from my library on specific HomePods/AirPlay 2 speakers therefore, all these scripts can be triggered from Shortcuts on iOS and chained together in a multitude of interesting ways. Yes, Apple’s music player/media manager gets a bad rap (and rightfully so the app is a mess), but it’s got one thing going for it still: iTunes has extensive integration with AppleScript, including actions that can connect to AirPlay speakers and set their volume to play a specific song, album, or playlist. It may sound anachronistic in 2019, but one of the advantages of having a Mac mini always running and multiple HomePods around the house is iTunes. ![]()
0 Comments
Leave a Reply. |