Jump to content
OliverJAsh

[Request] AirPlay

Recommended Posts

iTunes was recently updated to allow control of AirPlay video AppleScript. I was wondering if someone could make a workflow for it?

 

Here's a small example script:

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

Share this post


Link to post

I've been wanting to throw something like this together for a while. How does this work for you? direct link.

 

Hotkey pops up a list of Airplay devices used by iTunes. Select one to toggle it on/off.

 

Main%20window.png

Share this post


Link to post

In case anyone else is using this workflow: I had to make a couple small changes to the script because the iTunes 11.1 update seems to have broken the original.

 

The previous link goes to the revised version, but here they are again:

Share this post


Link to post

I thought I'd post an update to let anyone following this thread know: I uploaded the most recent version of this workflow to the new Packal site, here. It sounds like there will be a great feature over there to keep track of updated workflows so you may want to keep an eye out.

 

There have not been any updates since September so you won't miss anything if you don't grab the version over there.  B) 

Share this post


Link to post

Just a minor update to this workflow: It seems like the Airplay device results were not being ordered properly (possibly due to tiny a change in Alfred after the 2.2 update).

 

I pushed a 1.01 update to Packal; you can grab the new version there.

Share this post


Link to post

Thanks for this.  I've added a couple Remote Triggers - you set up a trigger with the Argument type Text and the string as the name of the desired Airplay device, then pipe it out to the existing script in the workflow.  Works great.

Share this post


Link to post

Thanks for this.  I've added a couple Remote Triggers - you set up a trigger with the Argument type Text and the string as the name of the desired Airplay device, then pipe it out to the existing script in the workflow.  Works great.

That's a great idea. I was waiting patiently for the day when maybe the remote app is able to auto-populate triggers within itself, but if this is fairly easy I could add a few blank triggers to the workflow and provide examples for anyone that wants them.

 

I'll probably mess around today and add that as a minor update.

Share this post


Link to post

Smirky - awesome app and thank you for posting it.  One wish list item for you to consider if you get back to working on this app:

  • Would it be possible to edit your script to allow multiple devices to be selected as opposed to just one at a time?  I sometimes want to pipe music to several rooms in my house at once and this would be a great addition.

And then one tip for anyone else trying to automate some of this via remote.  The first way I did it was to add a remote page that triggers this workflow, and then a series of other "Dispatch Key Combo" buttons that send the CMD 1, CMD 2, CMD 3, etc. shortcuts that each select one of the AirPlay devices in my house.  This allows you to automated doing it remotely, though it's still only selecting one speaker at a time for now.

 

Thanks again, great script!

 

 

Share this post


Link to post
Posted (edited)

Does this workflow still work?

I entered a hotkey, but "iTunes Airplay  Toggle" flashes in the Alfred search bar and disappears.

Am I doing something wrong?

 

I just need a way to select various AirPlay speakers. Is there a better way?

Edited by mlondon

Share this post


Link to post
On 4/9/2020 at 9:26 AM, mlondon said:

Does this workflow still work?

 

Hi, yes! I still maintain this workflow as regularly as possible via the github page linked below. The current version works with Catalina but you can grab an older version if you haven't upgraded yet. Let me know if you're having any trouble with the current version and I'll help fix anything needed.

 

https://github.com/dotson/iTunes-Airplay-Toggle

Share this post


Link to post

ahhh i've removed that workflow a few months ago because it didn't work with Catalina. i'm seeing there's an update only now 😂

 

thanks a lot. very useful!

Share this post


Link to post
On 4/10/2020 at 9:39 PM, smirky said:

Hi, yes! I still maintain this workflow as regularly as possible via the github page linked below. The current version works with Catalina but you can grab an older version if you haven't upgraded yet. Let me know if you're having any trouble with the current version and I'll help fix anything needed.

 

Hi, Got it working on Mojave, thank you.

However I see that the workflow just toggles each Airplay target on/off.

I would like to be able to SWITCH from one to another.

For example, iTunes is set to play to Computer. Using your workflow, I have to toggle Computer OFF, and then toggle my speakers ON.

Is there a way to SWITCH instead of the current behaviour?

 

Thanks again...

Share this post


Link to post
6 hours ago, mlondon said:

 

Hi, Got it working on Mojave, thank you.

However I see that the workflow just toggles each Airplay target on/off.

I would like to be able to SWITCH from one to another.

For example, iTunes is set to play to Computer. Using your workflow, I have to toggle Computer OFF, and then toggle my speakers ON.

Is there a way to SWITCH instead of the current behaviour?

 

Thanks again...

 

Thanks for the update, glad to hear that it's working for you!

 

That feature should be fairly simple to implement and there are a couple ways to go about doing it. One is to allow a key option such that using it would toggle all choices rather than the one specifically chosen (i.e., action using shift-enter to make this one active and the others inactive). This would allow both the existing function and additional function to exist all at once. Another would be to let the user set which is the default type of action (i.e., set the variable in the preferences).

 

I think it'd be possible to do both at once, so you could tell Alfred which choice is your preferred default ('individual toggle' or 'switch to') and then have the other option be chosen with the special key combo. I'm going to play around a bit and see if I can make that work.

Share this post


Link to post
On 4/20/2020 at 10:47 AM, mlondon said:

 

Hi, Got it working on Mojave, thank you.

However I see that the workflow just toggles each Airplay target on/off.

I would like to be able to SWITCH from one to another.

For example, iTunes is set to play to Computer. Using your workflow, I have to toggle Computer OFF, and then toggle my speakers ON.

Is there a way to SWITCH instead of the current behaviour?

 

Thanks again...

Just pushed an update based on your request. Give it a shot and let me know if it works for you. You'll just need to change the default behavior from "toggle" to "select" in the variables section, per the About This Workflow page in Alfred. Please let me know if you have any issues or other ideas on improvements!

 

https://github.com/dotson/iTunes-Airplay-Toggle

Share this post


Link to post
3 hours ago, smirky said:

Just pushed an update based on your request. Give it a shot and let me know if it works for you. You'll just need to change the default behavior from "toggle" to "select" in the variables section, per the About This Workflow page in Alfred. Please let me know if you have any issues or other ideas on improvements!

 

https://github.com/dotson/iTunes-Airplay-Toggle

 

Really appreciate this!

However, now when I trigger the workflow, it tries to open Parallels app (for Windoze emulation).

I have zero idea why this is happening. Doesnt matter what I change your workflow hotkey to, still invokes Parallels

None of my AirPlay devices are connected to Windoze in any way. 

Very strange.... 

Share this post


Link to post
35 minutes ago, mlondon said:

 

Really appreciate this!

However, now when I trigger the workflow, it tries to open Parallels app (for Windoze emulation).

I have zero idea why this is happening. Doesnt matter what I change your workflow hotkey to, still invokes Parallels

None of my AirPlay devices are connected to Windoze in any way. 

Very strange.... 

 

Well that’s super weird, sorry about that! Does the workflow work as expected but also triggers Parallels or does it not work at all plus Parallels opens up unexpectedly?

 

Can you post the output from Alfred’s debug window after you run the workflow? What’s your Mac OS and Parallels version? I’ll see if I can mirror those and replicate this locally to sort it out.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...