Categories: Misc / DotNet / Java / Coder / Linux / PHP Ask - La ask - La Answer

Play Random Track from specific Playlist

ATI recently released the Macintosh drivers for their Remote Wonder RF remote control. It's very nice for controlling iTunes. You can program it's buttons to launch applications so I modified an AppleScript to launch iTunes, then play a random song from a specific playlist. I saved the applescript as an application, then mapped it to one of the keys on my Remote Wonder. the end result is that I can push a single button to start playing Classical music.

Perhaps others might find it useful. Change the value "xClassical" to whatever playlist you want.

Here's the script:

<--BEGIN SCRIPT---->

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 "xClassical"
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 "Internet Explorer"
GetURL this_URL
end tell
end ignoring
end access_website

<--END SCRIPT---->
[2073 byte] By [jkramlich] at [2007-11-9 13:26:41]
# 1 Re: Play Random Track from specific Playlist
cool... i image this could be used with Romeo or the SE-Clicker app for anyone who has a bluetooth phone.. wont work for me since mine is running symbian.. i am sooo bleeding egde that it hurts sometimes :D ;)

nice the way you have included to the option to upgrade itunes if required..
deeg at 2007-11-15 17:25:05 >
[an error occurred while processing this directive]
[an error occurred while processing this directive]