我是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,但不适用于播放音频的任何内容。
不能查看哪些应用正在播放音频并停止播放[无需硬编码应用名称?]
答案 0 :(得分:0)
简短回答:AppleScript不能将其作为通用解决方案