Apple脚本:如何获取iTunes中下一首曲目的参考?

时间:2011-09-14 10:43:55

标签: applescript itunes

我想要实现的目标是:

tell application "iTunes"
    play next track with once
end tell

当然,'next track'是一个命令,而不是对下一首曲目的引用 - 所以这不起作用。我已经完成了文档,我真的被困在这个 - 我将如何编码以使其有效?

如果解决方案涉及制作播放列表或任何正常的内容 - 我需要的是一个播放下一首歌然后停止播放的脚本。

-

非常感谢任何帮助:)我已经浪费了很多时间试图让它发挥作用!

2 个答案:

答案 0 :(得分:1)

这个脚本是hacky但它​​有效...

tell application "iTunes"
    next track
    set this_track to the name of the current track
    previous track
end tell

答案 1 :(得分:0)

经过多次搞乱之后,我就是这样做的。如果你能看到更好的方式,那么我想知道!

tell application "iTunes"

    set is_playing to false

    if player state is playing then
        set is_playing to true
    end if

    tell playlist "Cinderella"

        set track_number to 1
        set should_repeat to true
        repeat while should_repeat is true

            if track track_number exists then
                tell track track_number
                    set play_count to (get played count)
                    if play_count is 0 then
                        set should_repeat to false
                    else
                        set track_number to track_number + 1
                    end if
                end tell
            else
                repeat with track_ref in tracks
                    tell track_ref
                        set played count to 0

                    end tell
                end repeat
                set track_number to 1
            end if
        end repeat

        if is_playing is true then
            set played count of track track_number to 1
            tell application "iTunes"
                stop
            end tell
        else
            play track track_number with once
        end if

    end tell

end tell