|
Page 1 of 1
|
[ 4 posts ] |
|
My take for integrating internet radio stations
| Author |
Message |
|
ricks
Joined: Nov 11, 2006 Posts: 120 Location: Reno, NV
|
 My take for integrating internet radio stations
With the demise of the "Special X" XM channel that played that oh, so wacky holiday Xmas music, I decided that I had to come up with an alternative. Below is the applescript program that I came up with to integrate internet radio sources including from the AOL Radio.app, web based players, and iTunes capable streams. I should also note that I use Airfoil to direct the music from the server to one or more speakers.
I'm posting it in case it helps anyone else.
My basic Wacky Xmas iphone/ipod touch control screen that could use some more work:
You'll note the controls at the bottom in the dark blue relate to my Airfoil speaker setup and scripts and not to the current script at hand.
Theoretically, all one would need to add or modify the script would be to change the iRadioSources variable to the sources you'd want, and set up some buttons to call the functions.
Each of the buttons on the control page have an applescript such as: - Code: Select all
iRadio_StartStream("AOL Radio")
where you pass the Nickname you set in the iRadioSources list in the below script. And the Stop button: - Code: Select all
iRadio_StopStream()
It's working for me right now, but your mileage may vary!!! The Script: - Code: Select all
--This script provides the mechanism to listen to a variety of internet streams (e.g. AOL Radio, Web based, Itunes Radio Stations). --Add your radio source to the iRadioSources property below. For all options, you must set a nickname and a shortname. The shortname must be Indigo variable safe (e.g. no spaces) as it will be used to create an Indigo variable. --Option A: Application Based (e.g. using the AOL Radio.App). Set ApplicationName record. This script assumes that the app is in the applications folder and that the nickname is the app name. --Option B: iTunes radio station. Set itunestrackname and itunesplaylist records. --Option C: Open a web player using Safari. Set SafariURL record.
--This script will create several Indigo variables on the fly: --iRadio_Stream : Shortname of currently playing stream --iRadio_Playing : "true" if stream is currently playing, else "false" --iRadio_Status : Text variable stating current status --iRadio_Safari_WinName : Safari WindowID of webplayer
--In addition, several variables of the form "iRadio_Shortname_on" will be created for each stream. Will be "true" if that stream is playing or else "false"
--This script requires access to AF_Application_Source()
property iRadioSources : {{nickname:"AOL Radio", shortname:"AOLRadio", itunesplaylist:"", itunesTrackName:"", SafariURL:"", ApplicationName:"AOL Radio", ApplicationParameter:""}, {nickname:"SlackerXmas", shortname:"SlackerXmas", itunesplaylist:"", itunesTrackName:"", SafariURL:"http://www.slacker.com/?sid=stations/1519278/874", ApplicationName:"", ApplicationParameter:""}, {nickname:"181 FM Xmas", shortname:"181FMXmas", itunesplaylist:"", itunesTrackName:"", SafariURL:"http://www.181.fm/stream/asx.181-xfun", ApplicationName:"", ApplicationParameter:""}, {nickname:"Cutting Edge", shortname:"CuttinEdge", itunesplaylist:"radio stations", itunesTrackName:"The Cutting Edge of Christmas", SafariURL:"", ApplicationName:"", ApplicationParameter:""}, {nickname:"Xmas in Frisko", shortname:"FriskoXmas", itunesplaylist:"radio stations", itunesTrackName:"Xmas in Frisko", SafariURL:"", ApplicationName:"", ApplicationParameter:""}}
on iRadio_StartStream(aNickName) tell application "IndigoServer" --STEP 0. If already playing, stop that stream first if value of variable "iRadio_Playing" = "true" then iRadio_StopStream() --Check or Add variable names (self repairing) if not (variable "iRadio_Stream" exists) then make new variable with properties {name:"iRadio_Stream", value:""} if not (variable "iRadio_Playing" exists) then make new variable with properties {name:"iRadio_Playing", value:"false"} if not (variable "iRadio_Status" exists) then make new variable with properties {name:"iRadio_Status", value:""} if not (variable "iRadio_Safari_winName" exists) then make new variable with properties {name:"iRadio_Safari_winName", value:""} --Make sure station on/off variables are present (self repairing) repeat with aStream in iRadioSources set onVar to ("iRadio_" & shortname of aStream & "_on") if not (variable onVar exists) then make new variable with properties {name:onVar, value:"false"} end if end repeat end tell repeat with aStream in iRadioSources --STEP 1: FIND STREAM if aNickName = (nickname of aStream) then --STEP 2: Parse based on type of stream -- ----> ITUNES ---------- if (count of itunesplaylist of aStream) > 0 and (count of itunesTrackName of aStream) > 0 then tell application "iTunes" --play ((tracks of playlist "radio stations") whose name contains "Xmas in Frisko") play (tracks of playlist (itunesplaylist of aStream) whose name contains (itunesTrackName of aStream)) end tell AF_Application_Source("iTunes") tell application "IndigoServer" log (itunesTrackName of aStream) log (itunesplaylist of aStream) set value of variable "iRadio_Stream" to shortname of aStream set value of variable "iRadio_Playing" to "true" set value of variable "iRadio_Status" to "Playing: " & nickname of aStream set value of variable ("iRadio_" & shortname of aStream & "_on") to "true" end tell end if -- ----> Web ---------- if (count of SafariURL of aStream) > 0 then tell application "Safari" make new document at end of documents set URL of document 1 to SafariURL of aStream set winName to id of the front window end tell AF_Application_Source("Safari") tell application "IndigoServer" set value of variable "iRadio_Safari_winName" to winName set value of variable "iRadio_Stream" to shortname of aStream set value of variable "iRadio_Playing" to "true" set value of variable "iRadio_Status" to "Playing: " & nickname of aStream set value of variable ("iRadio_" & shortname of aStream & "_on") to "true" end tell end if -- ----> AOL Radio ---------- if (count of ApplicationName of aStream) > 0 then --Open Application --Time Out for opening application tell application "AOL Radio" play end tell AF_Application_Source("AOL Radio") tell application "IndigoServer" set value of variable "iRadio_Stream" to shortname of aStream set value of variable "iRadio_Playing" to "true" set value of variable "iRadio_Status" to "Playing: " & nickname of aStream set value of variable ("iRadio_" & shortname of aStream & "_on") to "true" end tell end if end if end repeat end iRadio_StartStream -------------------------------------------------- -------------------------------------------------- on iRadio_StopStream() set currentStream to "" tell application "IndigoServer" set currentStream to value of variable "iRadio_Stream" repeat with theStream in iRadioSources if currentStream = shortname of theStream then set aStream to theStream set value of variable "iRadio_Stream" to "" set value of variable "iRadio_Playing" to "false" set value of variable "iRadio_Status" to "" set onVar to ("iRadio_" & shortname of aStream & "_on") set value of variable onVar to "false" --Have to decide how to turn off -- Parse based on type of stream -- ----> ITUNES ---------- if (count of itunesplaylist of aStream) > 0 and (count of itunesTrackName of aStream) > 0 then --tell application "iTunes" iTunesStop() --from iTunes attachment --end tell end if -- ----> Web ---------- set SafariWin to value of variable "iRadio_Safari_winName" as integer if SafariWin > 0 then tell application "Safari" set allWindows to every window repeat with w in allWindows if (id of w) = SafariWin then close w saving no tell application "IndigoServer" set value of variable "iRadio_Safari_winName" to "" end tell end if end repeat end tell end if -- ----> AOL Radio ---------- if (count of ApplicationName of aStream) > 0 then tell application ApplicationName of aStream stop quit end tell end if end if end repeat end tell end iRadio_StopStream
Also, for completeness, the AF_Application_Source script the changes the audio source in Airfoil - Code: Select all
--additiional airfoil commands on AF_Application_Source(desiredSource) tell application "Airfoil" set sourceSet to false try if not (desiredSource = "System") and not (desiredSource = "System Audio") then --SET APPLICATION SOURCE THAT ALREADY EXISTS set sourceList to get every application source repeat with aSource in sourceList if name of aSource = desiredSource then set current audio source to aSource set sourceSet to true end if end repeat --SET APPLICATION SOUCE THAT DOES NOT CURRENTLY EXIST if sourceSet = false then --create new link. Assume desired Source is app name that is located in applications folder set aSource to make new application source set application file of aSource to "/Applications/" & desiredSource & ".app" set current audio source to aSource end if else --set system source set aSource to first system source set current audio source to aSource end if on error number errNum if errNum is -1719 then --catch error if sunflower is not installed. Sunflower is needed for Airfoil to capture system sounds. tell application "IndigoServer" log "Airfoil Attachemt Script ERROR!!! Do you have Sunflower installed? Please see 'Install Extras...' under the Airfoil application menu." end tell end if end try --end timeout end tell end AF_Application_Source
|
| Sat Nov 29, 2008 7:25 pm |
|
 |
|
emichaud
Joined: Mar 25, 2008 Posts: 35
|
 nice job
hey - this seems pretty slick. I'm curious - how you are delivering the audio in the separate rooms. are you using something like the airport express and using airfoil to control the streams?
Since I'm still saving up for my next project, I've had time to debate how best to deliver audio around the house.
|
| Sat Nov 29, 2008 9:06 pm |
|
 |
|
ricks
Joined: Nov 11, 2006 Posts: 120 Location: Reno, NV
|
With Apple's Black Friday sale, I picked up a couple more airport expresses on discount to replace a couple of computers that were acting as Airfoil Remotes. I never would have thought that I'd have this many expresses hanging around!
Yes, I use Airfoil to control what gets sent to each airtunes speaker and I couple that with Indigo to turn the speakers on/off using Appliance Lincs. For gf ease of use, I have a Remote Linc in the bedroom programmed to automatically turn the bedroom speakers on and start one of several playlists. Now I'm working more with the iphone/ipod touch interface for better control throughout the house.
I do have a somewhat large applescript I've been working on (slowly) that simplifies Airfoil control through Indigo. I'm hoping to "finish" it and get it into the user contributions in the next few weeks. See the second post here for a previous post that describes some of this functionality.
Right now it's kinda tough as you have two options if want iphone/ipod touch control. First is to use Apple's Remote or IOSPIRITS Remote Buddy AJAX Remote. These are slick, giving you album art and a nice, quick interface. You can control which speakers are sent the audio stream from these apps, but there is no way to automatically control power to the speakers. I've been wondering if there is a way to watch the TCP/IP stream to see if music is being streamed to a specific airport express and then have Indigo turn that speaker on. Of course if Apple ever decided to put proper Applescript commands into iTunes for controlling Airtunes, then things would be easier. Makes me wonder how Remote Buddy has implemented AirTunes control functionality.
The second approach, of course, is what I did above through Airfoil and Indigo.
Rick
|
| Sun Nov 30, 2008 9:31 am |
|
 |
|
hamw
Joined: Mar 31, 2008 Posts: 739
|
 Re: My take for integrating internet radio stations
Ricks,
With all the changes in AOL etc, does this script still work for you? Also, is there an easy way to integrate Pandora into this, or is that different?
|
| Tue Nov 02, 2010 7:40 pm |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 4 guests |
|
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 post attachments in this forum
|
|