Applescript播放轨道spotify

Var*_*ali 3 macos applescript spotify

我想通过运行AppleScript来播放曲目.我无法搞清楚播放曲目的方法.

我这样做

tell application "Spotify"
    play track "One Thing" in context spotify:track:5Up9Lj7QWudEfMc0ve5qWW
end tell
Run Code Online (Sandbox Code Playgroud)

这显然不起作用.我不知道如何处理上下文部分.什么是背景?

iKe*_*dac 8

请查看AppleScript编辑器中的文档.Track并且context都是URI.Spotify上下文是一个容器,客户端默认使用该轨道的相册.

所以,例如,这两个都将在其专辑的背景下播放曲目(它们在功能上是相同的):

tell application "Spotify"
     play track "spotify:track:5Up9Lj7QWudEfMc0ve5qWW"
end tell

tell application "Spotify"
     play track "spotify:track:5Up9Lj7QWudEfMc0ve5qWW" in context "spotify:album:33yaWg4n9max6UWPlD59zs"
end tell
Run Code Online (Sandbox Code Playgroud)

但是,您也可以在艺术家的背景下播放曲目:

tell application "Spotify"
     play track "spotify:track:5Up9Lj7QWudEfMc0ve5qWW" in context "spotify:artist:2AsusXITU8P25dlRNhcAbG"
end tell
Run Code Online (Sandbox Code Playgroud)

甚至是一个播放列表!

tell application "Spotify"
    play track "spotify:track:3NN3bw0UMt3DbFUVGh78kV" in context "spotify:user:sweetlelle:playlist:6C7spm3ZSJSWL9EZAhiMFb"
end tell
Run Code Online (Sandbox Code Playgroud)