【发布时间】:2015-11-11 14:18:44
【问题描述】:
我是 AppleScript 的新手,我正在尝试编写一个脚本来更改任何正在播放音频的应用 [iTunes、Spotify 等] 的音量。
AppleScript 有没有办法检查当前正在播放音频的应用程序?我已经搜索过这个问题的答案,但结果是空的......
更正: 我找到了这个链接http://hypertext.net/2011/11/applescript-powermate-media-apps/
有这个脚本:
--Define the lastPaused property and give it a default value
property lastPaused : ""
--Get current states of iTunes and Spotify
tell application "iTunes" to set itunesState to (player state as text)
tell application "Spotify" to set spotifyState to (player state as text)
--Pause the active app; play the last-paused app
if itunesState is equal to "playing" then
tell application "iTunes" to playpause
set lastPaused to "iTunes"
else if spotifyState is equal to "playing" then
tell application "Spotify" to playpause
set lastPaused to "Spotify"
else if ((itunesState is equal to "paused") and (lastPaused is equal to "iTunes")) then
tell application "iTunes" to playpause
else if ((spotifyState is equal to "paused") and (lastPaused is equal to "Spotify")) then
tell application "Spotify" to playpause
end if
所以,这适用于 iTunes/Spotify,但不适用于其他播放音频的设备。
applescript 不能只检查正在播放音频的应用并停止它[无需硬编码应用名称?]
【问题讨论】:
标签: applescript