我有一个与Alfred一起使用的 Applescript,它可以播放或暂停 iTunes 或Rdio中的当前曲目,具体取决于我打开的曲目。在我的脚本中,Rdio 具有优先权,因为我总是打开 iTunes,并且仅在出于特定目的需要它时才打开 Rdio。
通常,当在 iTunes 中播放曲目并且我点击全局快捷方式来运行此脚本时,最多需要 15 秒才能停止曲目。我想在这里分享脚本,看看是否存在明显的问题,或者是否有更简单、更有效的方法来处理它。
我很感激我能得到的任何帮助!
tell application "System Events"
if (name of processes) contains "iTunes" then
set iTunesRunning to true
else
set iTunesRunning to false
end if
if (name of processes) contains "Rdio" then
set RdioRunning to true
else
set RdioRunning to false
end if
end tell
if RdioRunning then
tell application "Rdio"
if player state is paused or player state is stopped then
play
else if player state is playing then
pause
end if
end tell
else if iTunesRunning then
tell application "iTunes"
if player state is paused or player state is stopped then
play
else if player state is playing then
pause
end if
end tell
end if