iTunes曲目播放日期

时间:2017-07-05 19:11:11

标签: applescript

以下AppleScript按预期工作,为指定last played中的第一首曲目提供user playlist值。

tell application "iTunes"
    set theTrack to (item 1 of tracks of user playlist "Named")
    set playedDate to played date of theTrack
    display dialog (playedDate as string)
end tell

然而,这个AppleScript不会编译,而是给我一个错误Expected end of line, etc. but found class name.

tell application "iTunes"
    my testMethod(item 1 of tracks of user playlist "Named")
end tell

on testMethod(theTrack)
    set trackName to (name of theTrack)
    display dialog trackName
    -- set playedDate to played date of theTrack
    -- display dialog playedDate        
end testMethod

这两个脚本是如此不同以至于AppleScript的编译器变得不稳定吗?如何在第二个示例中将played date of theTrack传入playedDate

1 个答案:

答案 0 :(得分:1)

played dateiTunes应用术语的一部分,您需要一个应用tell

tell application "iTunes"
    set playedDate to played date of theTrack
end tell

using terms from application块,以帮助编译器解决术语

using terms from application "iTunes"
    set playedDate to played date of theTrack
end using terms from

您现在可能会问:为什么name有效?好吧,name在许多应用程序中都是众所周知的属性,甚至AppleScript运行者都知道它。