I'm trying to write an AppleScript that gives me the time remaining and total time of the currently playing iTunes track. I'd like it to be formatted as minutes:seconds / minutes:seconds. If that is impossible, seconds / seconds would work as well.
Here's what I've got so far:
on run
set info to ""
set info2 to ""
tell application "System Events"
set num to count (every process whose name is "iTunes")
end tell
if num > 0 then
tell application "iTunes"
if player state is playing then
set when to player position
set long to time of current track
time of long as string
set info to when & " / " & long as string
end if
end tell
end if
return info
end run
Now the problem is it can't get long as a string because it is formatted as 3:31 (the total time of the track). If I try to divide long by 60 to get the seconds, it won't work because it can't make 3:31 into a real number. Converting when to a minutes:seconds format would work just as well for me.
Thanks for your help.
Here's what I've got so far:
on run
set info to ""
set info2 to ""
tell application "System Events"
set num to count (every process whose name is "iTunes")
end tell
if num > 0 then
tell application "iTunes"
if player state is playing then
set when to player position
set long to time of current track
time of long as string
set info to when & " / " & long as string
end if
end tell
end if
return info
end run
Now the problem is it can't get long as a string because it is formatted as 3:31 (the total time of the track). If I try to divide long by 60 to get the seconds, it won't work because it can't make 3:31 into a real number. Converting when to a minutes:seconds format would work just as well for me.
Thanks for your help.