I'm trying to make a script to get the duration of the current song, but when I do this the duration comes back as "missing value". Any suggestions?

tell application "iTunes"
    if player state is playing or player state is paused then
        set theDuration to (get duration of the current track)
        display dialog theDuration
    end if
end tell
有帮助吗?

解决方案

Your code works perfectly here. For example, I play "How Many Times" from Bob Marley and when I run your script the dialog shows 145.1920013427734. But (of course) when I play Internet Radio, duration will return nothing. Try a local track and run your script again ? Just guessing. (iTunes 11.0.5 / OS X 10.8.2)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top