2

我正在尝试使用 AppleScript设置用户播放列表的曲目。我不希望添加曲目,我希望它们替换当前曲目。在我这样做之前,我需要通过它们的持久 ID 查找轨道,这工作正常,但是设置轨道的语句不起作用。下面的代码片段:

            set fixed indexing to true
        set myPlaylist to the first item of (every user playlist whose persistent ID is "5C768EFF306E3366")

        set tracksPIDs to {"66EB935073027EDD", "B6807694FEDD76B4"}
        set resolvedTracks to {}

        --resolve the tracks
        repeat with trackPID in tracksPIDs
            set myTrack to the first item of (every track whose persistent ID is equal to trackPID)
            set end of resolvedTracks to myTrack
        end repeat

        set (the tracks of my myPlaylist) to duplicate of (resolvedTracks)

另外,如何从播放列表中删除所有曲目(即设置为空列表)?

4

1 回答 1

4

要执行您想要的操作,您需要执行两个步骤,首先从播放列表中删除现有曲目,然后添加您想要在播放列表中的曲目。第一步看起来像:

delete every track of myPlaylist

然后添加看起来像:

duplicate resolvedTracks to myPlaylist
于 2009-07-18T05:46:18.383 回答