Tyler Mullins
Tyler Mullins

Reputation: 77

Get duration of the current song in AppleScript

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

Upvotes: 0

Views: 1089

Answers (1)

user1804762
user1804762

Reputation:

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)

Upvotes: 1

Related Questions