Re: iTunes programming
Re: iTunes programming
- Subject: Re: iTunes programming
- From: Gibbons Burke <email@hidden>
- Date: Wed, 7 Aug 2002 16:10:36 -0500
At 10:57 AM -0400 8/7/02, Isaac Sherman wrote:
>
Is it possible to send a message to iTunes through Cocoa/Applescript?
>
Specifically, I want it to play a random song. A few Google/ADC searches
>
returned no helpful info, other than a visual plugin SDK, which I'm not
>
interested in. A pointer to the appropriate documentation would be
>
appreciated.
Apple provides this script "Play Random Track" with iTunes. If you have your Script Menu installed, it will be in the iTunes sub-menu. The actual script will be found in your ~/Library/Scripts/iTunes/ folder:
property required_version : "2.0.3"
tell application "iTunes"
activate
-- VERSION CHECK
set this_version to the version as string
if this_version is not greater than or equal to the required_version then
beep
display dialog "This script requires iTunes version: " & required_version & ,
return & return & ,
"Current version of iTunes: " & this_version buttons {"Update", "Cancel"} default button 2 with icon 2
if the button returned of the result is "Update" then
my access_website("
http://www.apple.com/itunes/download/")
return "incorrect version"
end if
end if
tell source "Library"
tell playlist "Library"
set this_track to some track
set this_name to the name of this_track
set this_artist to the artist of this_track
set this_album to the album of this_track
play this_track
end tell
end tell
display dialog "Now playing
" & return & return & ,
"Name: " & this_name & return & ,
"Artist: " & this_artist & return & ,
"Album: " & this_album buttons {"*"} default button 1 giving up after 10
end tell
on access_website(this_URL)
ignoring application responses
tell application "Finder"
open location this_URL
end tell
end ignoring
end access_website
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.