Hi,
Is there any way to use automator actions & applescript so that I could say “Play … by …” and iTunes would search for the track and play it?
I know that I can make an applescript that tells itunes to play a certain song by putting the actual song name in quotes in the applescript, but I don’t want to have to make an applescript for every song in my library, so I wanted to find out if there was an applescript to search for the song I say or an automator action to copy the applescript and paste in every song in my library.
Is this possible??
Thanks
Frank
Model: MacBook 2.1 GHz
AppleScript: Applescript Utility 1.1, Script Editor 2.2
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)
This code will allow you to search for a song and play it . This is not my code this was written by hendo and works very well.
set songTitle to text returned of (display dialog "Enter the name of the song you want to play." default answer "")
set playTrack to ""
tell application "iTunes"
set fixedIndexing to fixed indexing
set fixed indexing to true
repeat while playTrack is ""
tell (tracks of (first playlist whose special kind is Music) whose name contains songTitle) to if (count) > 1 then --if you want to search for the artist replace "whose name" with "whose artist"
set playTrack to my chooseTracks(name, artist, album, it)
else if it is not {} then
set playTrack to item 1 of it
else
try
tell me to set songTitle to text returned of (display dialog "Your search turned up 0 results. Try again?." default answer "" buttons {"Cancel", "Go"} default button 2)
on error -- user canceled
set playTrack to false
end try
end if
end repeat
if playTrack is not false then
tell application "iTunes"
if (get version) as string < "7.1" then
set Master_Playlist to library playlist 1
else
set Master_Playlist to first playlist whose special kind is Music
end if
set view of browser window 1 to Master_Playlist
end tell
play playTrack
end if
set fixed indexing to fixedIndexing
end tell
tell application "Finder" to set the visible of every process whose name is "iTunes" to false
on chooseTracks(trackNames, trackArtists, trackAlbums, tracksFound)
set {tracksList, foundCount} to {{}, count tracksFound}
repeat with i from 1 to foundCount
if trackArtists's item i is "" then set trackArtists's item i to "Unknown"
if trackAlbums's item i is "" then set trackAlbums's item i to "Unknown"
set end of tracksList to trackNames's item i & " - " & trackArtists's item i & " (" & trackAlbums's item i & ")"
end repeat
set trackChosen to choose from list tracksList with prompt "Your search turned up " & foundCount & " results. Please specify which track you want to play."
if trackChosen is false then return false
set my text item delimiters to return
set tracksList to tracksList as Unicode text
set my text item delimiters to beginning of trackChosen
set trackNumber to count of paragraphs of first text item of tracksList
set my text item delimiters to ""
return item trackNumber of tracksFound
end chooseTracks