Hi,
I wrote a small script that gets all song from the album playing, sorts them and puts them into one string.
When I tested the script it worked fine, but when I ran it from an iTunes Plug-in it messes up the whole iTunes Applescript:
First the same script won’t run again from the Script editor (suddenly the first line sent to iTunes creates an inunderstandable error) when inside any visualization (e.g. Apple’s).
Then not even Frontrow is able to communicate with iTunes any more, not even after I restarted iTunes.
Can someone please take a look at the script and tell me why it might mess up things.
Thank you!
(If the script is flawless then it might be a problem of running script from inside iTunes.)
Greeting from Germany
Christoph Vogelbusch
Here is my script:
tell application "iTunes"
set theAlbum to the album of current track
set allTracks to search library playlist 1 for theAlbum only albums
set trackNameList to {}
repeat (the number of items in allTracks) times
set noOfLowest to 1
set lowestTrackNo to track number of (item noOfLowest of allTracks)
repeat with i from 2 to (the number of items in allTracks)
if track number of (item i of allTracks) < lowestTrackNo then
set noOfLowest to i
set lowestTrackNo to track number of (item noOfLowest of allTracks)
end if
end repeat
set lowestTrack to item noOfLowest of allTracks
if noOfLowest is 1 then
if not (the number of items in allTracks is 1) then
set allTracks to (items 2 thru -1 of allTracks)
end if
else if noOfLowest is (the number of items in allTracks) then
set allTracks to (items 1 thru (noOfLowest - 1) of allTracks)
else
set allTracks to (items 1 thru (noOfLowest - 1) of allTracks) & (items (noOfLowest + 1) thru -1 of allTracks)
end if
if track number of lowestTrack is 0 then
set end of trackNameList to name of lowestTrack
else
set end of trackNameList to (track number of lowestTrack) & ". " & (name of lowestTrack) as string
end if
end repeat
set allTrackNames to 0
repeat with trackName in trackNameList
if allTrackNames is 0 then
set allTrackNames to trackName
else
set allTrackNames to allTrackNames & return & trackName
end if
end repeat
end tell
return allTrackNames