【问题标题】:AppleScript: how do I check which apps are playing audio?AppleScript:如何检查哪些应用正在播放音频?
【发布时间】: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


    【解决方案1】:

    简答:AppleScript 无法将其作为通用解决方案

    【讨论】:

    • 好的,很高兴知道...谢谢。你是 2 对 2 回答我的问题!
    猜你喜欢
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2015-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多