Skip to Content

AppleScript: Control iTunes with an e-mail

Last week I talked about controlling your Mac with an e-mail; this week, as promised, I am going to show you how to apply this same idea to iTunes. So, without further ado, let's get started with writing some AppleScripts.

Continue reading to learn how to control iTunes.

Creating the AppleScripts
For this tutorial, I am going to show you how to control iTunes in the following ways: open, play, stop, skip and play a specific playlist. Just copy whichever script you want to use from the list below and paste them into the Script Editor (Script Editor.app can be found in ~/Applications/AppleScript/ Script Editor).

Open / Play iTunes
tell application "iTunes"
activate
play
end tell

Stop Playing
tell application "iTunes"
stop
end tell


Skip Track
tell application "iTunes"
next track
end tell

Start playing a specific playlist
tell application "iTunes"
set the_playlist to user playlist "typenameofplaylisthere"
set view of front window to the_playlist
play the_playlist
end tell

Additional Information
For the "Start playing a specific playlist" AppleScript, you need to define a playlist in the "typenameofplaylisthere" section -- remember to retain the quotation marks around the name as well as type the playlist name exactly as you see it in iTunes. For instance, if I wanted to use the Party Shuffle playlist, I would type "Party Shuffle" in this line.

Saving Your Scripts
You can now save your Apple Script in the format you want. You can also use this script to change tracks or load a new playlist by e-mail. Just follow the instructions in last weeks post to learn how to do this.

Mac Automation posts are published weekly here on TUAW, be sure to come back next week for more AppleScripty goodness.

Categories

Features How-tos

var digg_url = 'http://digg.com/apple/Control_iTunes_with_AppleScript_using_e_mail'; Last week I talked about controlling your Mac with...
 

Add a Comment

*0 / 3000 Character Maximum

5 Comments

Filter by:
Steve

I can see myself using this if I had a private Shoutcast stream that I wanted to control from another computer.

April 14 2008 at 9:24 AM Report abuse rate up rate down Reply
Dan

You can also control everything on your computer with twitter:

http://www.maciverse.com/control-your-mac-with-twitter.html

Create Automator Tasks, save them as an app, and then launch them with an apple script + mail rule.

April 13 2008 at 10:23 PM Report abuse rate up rate down Reply
Murphy Mac

Cory - Are you hanging out in my closet?

http://murphymac.com/select-a-playlist-by-email-and-more/

http://murphymac.com/sleep-your-mac-by-email/

April 13 2008 at 9:41 PM Report abuse rate up rate down Reply
Chris

Don't get me wrong, I love these AppleScript blogs, but in what instance would this particular script be used. I can't think of any unless you are trying to gaslight a roommate.

April 13 2008 at 9:21 PM Report abuse rate up rate down Reply
1 reply to Chris's comment
Cory Bohon

You can use this if you don't have an Apple remote or any way to control iTunes other than being directly in front of the computer. This would be great for someone who might have an Airtunes system set up with an Airport Express or AppleTV and want to change the track or playlist.

April 13 2008 at 9:25 PM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.