Up arrow
Down arrow
Pink smile thing
Loading image
Pointer image
Home

flickrss

BVNameTags-002 BVNameTags-001 BVTS-GameDay-079 BVTS-GameDay-078 BVTS-GameDay-077

favs

Macro-001 RoadTrip6-small-016 Strobes At Home-5.jpg Town Lake HDR Angel The Ring OliverBobblehead

me

Oliver Wong
edu: comp sci @ UT
live: austin
work: bazaarvoice

toys

macbook pro
nike+
canon 50d
canon 5d mkii
canon 85 f/1.2L
canon 85 f/1.8
canon 50 f/1.4
canon 16-35 f/2.8L
canon 100 macro
pink nintendo ds lite
iphone 3g

social

Flickr YouTube Twitter Facebook
 
Filed under nerdy weekend

I ran across this nifty little blog post that lets you control a remote Mac’s iTunes via iChat. I decided to customize the script a bit and added a way to search for songs. Here’s my addition to the stock AppleScript:

else if (theMessage begins with "song " and theMessage is not "song ")
     or (theMessage begins with "s " and theMessage is not "s ") then

    set cLength to (count (first word of theMessage)) + 1
    set query to texts cLength thru -1 of theMessage

    tell application "iTunes"
        set theSongs to (search playlist "Library" for query)
        try
            set songID to persistent ID of (item 1 in theSongs)
            play (first track of (get some playlist whose special kind is Music)
                 whose persistent ID = songID)
            set theResponse to "Playing song request. "
        on error
            set theResponse to "Did not find any songs. "
        end try

    end tell

    set theResponse to theResponse & getCurrentiTunesTrack()

I also added “aliases” to the previous and next commands (“p” and “n” respectively), but that was pretty trivial, so I won’t include it here. This is the first AppleScript I’ve written, so I’m probably making some noobish mistakes, but it was pretty cool. Now I can chat with my Mac Mini and tell it what to play!

AppleScript/iTunes/iChat

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment