Applescript: Check if computer is playing any soun

2019-05-30 15:29发布

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条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-05-30 15:44

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


查看更多
登录 后发表回答