我试图找出通过Spotify的Applescript库检测轨道变化的最佳方法.到目前为止,我已经尝试检查玩家位置 - 如果它等于0则它是一个新轨道并且再次出现Growl通知.(如果有人开了一首歌等,这大部分都不起作用)
我想知道更合理的方法是运行空闲的iTunes脚本,并且每隔几秒检查当前的轨道名称是否有变化.我担心这可能是记忆力的一点点.我也无法使用此代码.
tell application "System Events"
-- checks for instance of Growl and Spotify, does not run if both programs are not active
set isRunning to ¬
(count of (every process whose name is "Growl")) > 0
(count of (every process whose name is "Spotify")) > 0
end tell
--establish empty variable to be filled by song title later
global latest_song
set latest_song to ""
on idle
tell application "Spotify"
if player state is playing then
copy name …Run Code Online (Sandbox Code Playgroud)