====== iTunes Integration (Indigo versions 2-4)====== There are many ways to integrate iTunes and Indigo Pro; this page will show you how to perform these integrations: * [[iTunes#Set up the iTunes sync script|Set up the iTunes sync script]] * [[iTunes#Setting up PalmPad (or other X10 controller) buttons to control iTunes|Set up a PalmPad or other X10 Controller to control iTunes]] * [[iTunes#Setting up Insteon ControLinc buttons to control iTunes|Set up an Insteon ControLinc to control iTunes]] * [[iTunes#Setting up KeypadLinc buttons to control iTunes|Set up an Insteon KeypadLinc to control iTunes]] NOTE: If you are using Indigo 5, please use the [[plugins:itunes|iTunes plugin]] which is quite a bit easier. ===== Set up the iTunes sync script ===== Indigo comes with an iTunes Sync script which inserts a bunch of different data into Indigo Variables about what iTunes is doing. These can be shown on Control Pages, etc. This functionality is enabled by default in the sample house - check it out! If it's not already in your database, here's how (it's very [[wiki:How-to level of difficulty#simple|simple]]) - Select **''TRIGGERS''** from the outline view on the left - Click the **''New...''** button - Name the trigger whatever you want - Select **''Indigo Server Startup''** from the **''Type:''** popup (this will cause the actions in this trigger to be executed each time the server starts up) - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Select the **''File:''** radio button - A standard Mac file dialog will appear: open **''Background Tasks''** and select ''**iTunes sync.scpt**'' - Click **''OK''** That's it. Next time you restart the server it will start up the iTunes sync script. However, there are much more useful things that you can do to enable iTunes control from all over the house using various hardware controllers and Indigo Pro. ===== Setting up PalmPad (or other X10 controller) buttons to control iTunes ===== Difficulty: [[wiki:How-to level of difficulty#simple|Simple]] These instructions assume you're setting up a PalmPad remote, but the process would be much the same for any other X10 controller (SlimFire, Maxi controller, etc). ==== Set up the Play/Pause button(s) ==== - Make a note of the X10 house code that your controller is using. The PalmPad has a dial on the lower end of the remote that points to the letter of the house code. Also note which unit codes the remote is going to send: it's either 1-8 or 9-16 on the PalmPad because it only has 8 sets of buttons. You can tell by the switch at the lower end of the remote under the buttons. - In Indigo Pro, select **''TRIGGERS''** from the outline view on the left - Click the **''New...''** button - Name the trigger "Palm Pad - Play iTunes" (or whatever you want) - Select **''X10/RF Command Received''** from the **''Type:''** popup - Select **''On''** from the popup labeled **''Received:''** - Click the **''Address''** radio button - Select the appropriate house code (as noted in step 1) and set the unit code (the number) to whichever button you want to use to start iTunes playing. (Make sure it isn't overlapping with a real X10 device, like a light, or the button will start iTunes playing AND turn on the light!) - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesPlay() - Click **''OK''** (You've just created the trigger that will start iTunes playing - now, let's create the trigger that will pause iTunes) - Click the **''New...''** button again - Name the trigger "Palm Pad - Pause iTunes" (or whatever you want) - Select **''X10/RF Command Received''** from the **''Type:''** popup - Select **''Off''** from the popup labeled **''Received:''** - Click the **''Address''** radio button - Set the house code (the letter) and unit code (the number) to the same values as step 8 above - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesPause() - Click **''OK''** That should do it for Play and Pause. When you press the right "On" button on the Palm Pad, iTunes should start playing and it should pause when you press the corresponding "Off" button. NOTE: iTunes should be in a playable state: in other words, a valid playlist should be selected OR the Music Library. At the moment, the iTunes Attachment script (which you use by calling iTunesPlay()) isn't smart enough to first check to see if there is a playable playlist selected. ==== Set up the Volume Up/Volume Down button(s) ==== - Make a note of the X10 house code that your controller is using. The PalmPad has a dial on the lower end of the remote that points to the letter of the house code. Also note which unit codes the remote is going to send: it's either 1-8 or 9-16 on the PalmPad because it only has 8 sets of buttons. You can tell by the switch at the lower end of the remote under the buttons. - In Indigo Pro, select **''TRIGGERS''** from the outline view on the left - Click the **''New...''** button - Name the trigger "Palm Pad - iTunes Volume Up" (or whatever you want) - Select **''X10/RF Command Received''** from the **''Type:''** popup - Select **''On''** from the popup labeled **''Received:''** - Click the **''Address''** radio button - Select the appropriate house code (as noted in step 1) and set the unit code (the number) to whichever button you want to use to start iTunes playing. Make sure it isn't the same you used for Play and Pause above - it's not gonna work as you might expect! - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesVolumeUp(5) - Click **''OK''** (You've just created the trigger that will increase iTunes volume by 5% each time that button is pressed) - Click the **''New...''** button again - Name the trigger "Palm Pad - Pause iTunes" (or whatever you want) - Select **''X10/RF Command Received''** from the **''Type:''** popup - Select **''Off''** from the popup labeled **''Received:''** - Click the **''Address''** radio button - Set the house code (the letter) and unit code (the number) to the same values as step 8 above - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesVolumeDown(5) - Click **''OK''** Now, when you press the right "On" button on the Palm Pad, iTunes will increase the volume by 5% and the corresponding "Off" button will decrease the volume by 5%. See, that wasn't hard at all! Next, we'll discuss getting it to work with an Insteon ControlLinc. It's really not much different. ===== Setting up Insteon ControLinc buttons to control iTunes ===== Difficulty: [[wiki:How-to level of difficulty#simple|Simple]] The process isn't very different from the PalmPad, but here's the whole thing. ==== Set up the Play/Pause button(s) ==== - Make a note of which buttons you plan on using on the ControLinc. There are 5 button groups (On and Off). - In Indigo Pro, select **''TRIGGERS''** from the outline view on the left - Click the **''New...''** button - Name the trigger "ControLinc - Play iTunes" (or whatever you want) - Select **''Insteon Command Received''** from the **''Type:''** popup - Select **''On''** from the popup labeled **''Received:''** - Click the **''Device''** radio button - Select the ControLinc in the popup list - Select the button/group you want to use (as identified in step 1) - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesPlay() - Click **''OK''** (You've just created the trigger that will start iTunes playing - now, let's create the trigger that will pause iTunes) - Click the **''New...''** button again - Name the trigger "ControLinc - Pause iTunes" (or whatever you want) - Select **''Insteon Command Received''** from the **''Type:''** popup - Select **''Off''** from the popup labeled **''Received:''** - Click the **''Device''** radio button - Select the ControLinc in the popup list - Select the button/group you want to use (as identified in step 1) - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesPause() - Click **''OK''** That should do it for Play and Pause. When you press the right "On" button on the ControLinc, iTunes should start playing and it should pause when you press the corresponding "Off" button. NOTE: iTunes should be in a playable state: in other words, a valid playlist should be selected OR the Music Library. At the moment, the iTunes Attachment script (which you use by calling iTunesPlay()) isn't smart enough to first check to see if there is a playable playlist selected. ==== Set up the Volume Up/Volume Down button(s) ==== - Make a note of which buttons you plan on using on the ControLinc. There are 5 button groups (On and Off). - In Indigo Pro, select **''TRIGGERS''** from the outline view on the left - Click the **''New...''** button - Name the trigger "Palm Pad - iTunes Volume Up" (or whatever you want) - Select **''Insteon Command Received''** from the **''Type:''** popup - Select **''On''** from the popup labeled **''Received:''** - Click the **''Device''** radio button - Select the ControLinc in the popup list - Select the button/group you want to use (as identified in step 1) - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesVolumeUp(5) - Click **''OK''** (You've just created the trigger that will increase iTunes volume by 5% each time that button is pressed) - Click the **''New...''** button again - Name the trigger "Palm Pad - Pause iTunes" (or whatever you want) - Select **''Insteon Command Received''** from the **''Type:''** popup - Select **''On''** from the popup labeled **''Received:''** - Click the **''Device''** radio button - Select the ControLinc in the popup list - Select the button/group you want to use (as identified in step 1) - Click the **''Actions''** tab - Select **''Execute AppleScript''** from the **''Type''** popup - Make sure the **''Embedded:''** radio button is checked - Type the following script into the text area below **''Embedded:''**: iTunesVolumeDown(5) - Click **''OK''** Now, when you press the right "On" button on the ControLinc, iTunes will increase the volume by 5% and the corresponding "Off" button will decrease the volume by 5%. See, that wasn't hard either! Next, we'll discuss getting it to work with an Insteon KeypadLinc. ===== Setting up KeypadLinc buttons to control iTunes ===== KeypadLinc buttons operate inherently differently from other controllers: the buttons, by default, are toggle buttons - which means that they are either on or off as indicated by whether it's lit up or not. We've created a separate [[inst_keypadlinc_buttons|How-To]] that explains how to control those buttons, and specifically how to keep one in sync with the iTunes play state. [[inst_keypadlinc_buttons|Read it]]!