FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Sample Airfoil 2.0 Scripts

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac
View previous topic :: View next topic  
Author Message
crashtkd
Newbie


Joined: 12 Mar 2006
Posts: 5

PostPosted: Sun Mar 12, 2006 9:19 pm    Post subject: Sample Airfoil 2.0 Scripts Reply with quote

Here are some sample scripts to control Airfoil 2.0. They are not dynamic, I've hardcoded values for my own setup but have commented clearly so you can edit these yourself for your environment. There are 4 scripts, I'll put each in a separate post. The scripts allow you to display the current audio source, connect and disconnect from speakers, and change audio sources. They aren't elegant, but get the job done.
Back to top
View user's profile Send private message
crashtkd
Newbie


Joined: 12 Mar 2006
Posts: 5

PostPosted: Sun Mar 12, 2006 9:20 pm    Post subject: Display Source Script Reply with quote

Cut and paste into your script:

(* Salling Clicker script to display audio sources in Airfoil, by Rich Mogull. Path to strip /Applications/ is hard coded, so if you use an application in a different path you may need to modify the text parsing*)
on curapp2()
tell application "Airfoil"
set curapp to current audio source
if name of curapp is not "System Audio" then
set curapp to application file of curapp
if "/Applications/" is in curapp then
set curapp to get text 15 thru end of curapp
set curapp to get text 1 thru ((offset of "." in curapp) - 1) of curapp
end if
else
set curapp to "System"
end if
end tell
end curapp2

set displaytext to curapp2()
tell application "SEC Helper"

enter messagebox mode title "Audio Source" text displaytext
end tell
Back to top
View user's profile Send private message
crashtkd
Newbie


Joined: 12 Mar 2006
Posts: 5

PostPosted: Sun Mar 12, 2006 9:21 pm    Post subject: Change Sources Script Reply with quote

(* Salling Clicker script to change audio sources in Airfoil, by Rich Mogull. This is just a basic script with values hardcoded, although it would be easy to generate a dynamic list *)
using terms from application "SEC Helper"

on process invoke a_terminal
tell a_terminal
set the_list to make new list screen with properties {title:"Select Source", selected item:1}
(* list your audio sources in the next line using whatever name you want to appear on the menu. For example, I've listed XM, but in the next section will map it to the full application name I use to stream my XM audio *)
set item labels of the_list to {"XM", "iTunes", "All"}
push the_list
end tell
end process invoke

on process updated value the_widget
set cursource to (selected item of the_widget)
if cursource is 1 then --items are in order, change to match your apps
set cursource to "XM" --changing variable to display
tell application "Airfoil"
(* here is where I hardcoded application paths. You should replace the text in the quotes with the full path to your application. For example, I use "XM" as the display name, but the application that plays the XM audio is LineIn.app. *)
set newsource to make new application source
set application file of newsource to "/Applications/LineIn.app" --replace
set (current audio source) to newsource
end tell
else if cursource is 2 then
set cursource to "iTunes" --change display variable
tell application "Airfoil"
set newsource to make new application source
set application file of newsource to "/Applications/iTunes.app" --replace
set (current audio source) to newsource
end tell
else
set cursource to "All" --use system audio
tell application "Airfoil" to set (current audio source) to (first system source)
end if
show screen message "Audio Source " & (cursourcename) & " selected"

return false -- dismiss the list when an item is selected
end process updated value

on process screen exit the_screen
show screen message "exit"
end process screen exit

end using terms from
Back to top
View user's profile Send private message
crashtkd
Newbie


Joined: 12 Mar 2006
Posts: 5

PostPosted: Sun Mar 12, 2006 9:21 pm    Post subject: Connect Speakers Script Reply with quote

(* Salling Clicker script to change speaker connections in Airfoil, by Rich Mogull. This is just a basic script with values hardcoded, although it would be easy to generate a dynamic list *)
using terms from application "SEC Helper"

on process invoke a_terminal
tell a_terminal
(* I hardcode my speaker names here, change them for your own values *)
set the_list to make new list screen with properties {title:"Connect Speakers", selected item:3}
set item labels of the_list to {"Kitchen", "Stereo", "All"}
push the_list
end tell
end process invoke

on process updated value the_widget

set curspeaker to (selected item of the_widget)
if curspeaker is 1 then
(* my kitchen speakers are really named CrashBridge, thus the name change. You want to replace the values below with the name of your speakers as they are displayed in Airfoil *)
set curspeaker to "CrashBridge" --replace
else if curspeaker is 2 then
set curspeaker to "Stereo" - replace
else if curspeaker is 3 then
set curspeaker to "All" -- leave to send to all speakers

end if
show screen message "Streaming to " & (curspeaker)
if curspeaker is not "All" then -- connect to single speaker
tell application "Airfoil" to connect to (every speaker whose name is curspeaker)
else -- connect to all
tell application "Airfoil" to connect to every speaker
end if
return false -- dismiss the list when an item is selected
end process updated value

on process screen exit the_screen
show screen message "exit"
end process screen exit

end using terms from
Back to top
View user's profile Send private message
crashtkd
Newbie


Joined: 12 Mar 2006
Posts: 5

PostPosted: Sun Mar 12, 2006 9:22 pm    Post subject: Disconnect Speakers Script Reply with quote

(* Salling Clicker script to change speaker connections in Airfoil, by Rich Mogull. This is just a basic script with values hardcoded, although it would be easy to generate a dynamic list NOTE- see the ConnectSpeakers script for full documentation, since these two exactly mirror each other I only documented one of them*)
using terms from application "SEC Helper"

on process invoke a_terminal
tell a_terminal
set the_list to make new list screen with properties {title:"Connect Speakers", selected item:3}
set item labels of the_list to {"Kitchen", "Stereo", "All"}
push the_list
end tell
end process invoke

on process updated value the_widget

set curspeaker to (selected item of the_widget)
if curspeaker is 1 then
set curspeaker to "CrashBridge"
else if curspeaker is 2 then
set curspeaker to "Stereo"
else if curspeaker is 3 then
set curspeaker to "All"

end if
show screen message "Stopping Audio to " & (curspeaker)
if curspeaker is not "All" then
tell application "Airfoil" to disconnect from (every speaker whose name is curspeaker)
else
tell application "Airfoil" to disconnect from every speaker
end if
return false -- dismiss the list when an item is selected
end process updated value

on process screen exit the_screen
show screen message "exit"
end process screen exit

end using terms from
Back to top
View user's profile Send private message
Cliff.Braun
Newbie


Joined: 18 Feb 2006
Posts: 13

PostPosted: Sun Mar 19, 2006 11:57 am    Post subject: Airfoil scripts Reply with quote

Here's a somewhat dynamic set of airfoil scripts, I am still making improvements and am trying to find somewhere to host the thing. If you want me to let you know when I fix the little things, or if you want to let me know what could be better, email me at Cliff<dot>Braun<at>Gmail<dot>com.
Back to top
View user's profile Send private message AIM Address
alnyden
Newbie


Joined: 22 Mar 2006
Posts: 3

PostPosted: Wed Mar 22, 2006 4:09 am    Post subject: One question re: scripts Reply with quote

This is great! I've wanted something like this ever since I started using Salling Clicker, and it (almost) works perfectly!

I had only one problem, and I'm not sure if it's me or the code. When I use the "connect" script, I get my three options (living room, front room and all). "Front Room" works, and "all" works, but for some strange reason, clicking on "living room" doesn't do anything. I can select "all" to activate it, however, so I'm pretty sure i have the right name in there.

Thanks again for these scripts!

Al
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Jun 26, 2006 8:03 pm    Post subject: Reply with quote

I posted my take on the Airfoil thing here:

http://www.salling.com/forums/viewtopic.php?t=3996

Cliff: you're more than welcome to pick up my work and improve on it.

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group