Applescript: Check if computer is playing any sound

早过忘川 提交于 2019-12-23 03:51:40

问题


Trying to find a way for my script to check if there's any sound/audio being played currently on the computer. And if so, is there any way to find which app is playing sound?


回答1:


Maybe this helps:

One thing that happens when a sound is played is that the power management blocks the computer to go to sleep. With pmset -g you can see all the Power Management stuff that is going on.

So, when sleep is prevented by "coreaudiod" the machine is playing obviously some sound.

Here what pmset -g spits out when iTunes is playing:

Currently in use:
 womp                 0
 halfdim              1
 sms                  1
 hibernatefile        /var/vm/sleepimage
 gpuswitch            2
 networkoversleep     0
 disksleep            10
 sleep                10 (sleep prevented by iTunes, coreaudiod)
 hibernatemode        3
 ttyskeepawake        1
 displaysleep         10
 acwake               0
 lidwake              1




来源:https://stackoverflow.com/questions/27604207/applescript-check-if-computer-is-playing-any-sound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!