(* I wasn't able to get the timing down to make this applescript
output a multiple line list and still look good. Maybe a future
revision of SubtleStatus will have a more versatile timing function
to display this applescript using multiple lines. As it is, I still think
the script is still good for outputting all the information on one line.
The script tries to give accurate remaining times, in case start and
finish times are set within a track info options tab.
If you "Select All" this text and copy and paste this text into the
applescript editor it should compile and work OK. Then save it as
perhaps "Itunes Track and Time" as a script into the user directory:
"~/Library/Subtle Status Scripts" Finally, choose it within the
SubtleStatus preferences.
Thanks, russs *)
on getInfo()
try
tell application "iTunes"
set theList to {}
set mylist to the name of current playlist
set tname to the name of current track
set cnt to (count of tracks of current playlist)
set num to (index of current track)
set mySum to 0
if (size of current track as text) contains "missing
value" then
set track_remain to "Elapsed Time For Stream: " &
my formatTime(player position)
set time_remain to ""
else
repeat with loopnum from num + 1 to cnt
set mySum to mySum + (finish of track
loopnum of current playlist) - (start of track loopnum of current
playlist)
end repeat
set track_remain to (finish of current track) -
player position
set mySum to mySum + track_remain
set time_remain to "and Total Time Remaining " &
my formatTime(mySum)
set track_remain to "Track " & my
formatTime(track_remain)
end if
end tell
set theList to {mylist & " " & num & " of " & cnt & " \"" &
tname & "\" " & track_remain & " " & time_remain}
return theList
on error
return ""
end try
end getInfo
on formatTime(t)
if t ? 3600 then
set hh to (t div 3600)
set t to (t - hh * 3600)
else
set hh to "0"
end if
set mm to (t div 60)
if mm < 10 then
set mm to "0" & mm
end if
set ss to (t - (mm * 60))
if ss < 10 then
set ss to "0" & ss
end if
return hh & ":" & mm & ":" & ss as text
end formatTime
tell application "System Events"
set isOpen to (name of every process) contains "itunes"
end tell
if isOpen then
getInfo()
end if
Useful iTunes Applescript?
Logged In: YES
user_id=1188155
Copy and paste doesn't work too well after all after submitting the page.
It split up the "set" lines and didn't recognize the greater than or equal to
symbol in the line:
if t ? 3600 then
it should be:
if t >= 3600 then
I have uploaded the applescript file also.