gpt4 book ai didi

javascript - 是否可以检测浏览器选项卡是否正在播放音频?

转载 作者:数据小太阳 更新时间:2023-10-29 05:32:21 41 4
gpt4 key购买 nike

我正在寻找一种方法来检测是否在 Chrome 的当前标签中播放声音。我想强调的是,上下文是一个网络应用程序,不是 chrome 扩展,也不是单个音频元素。我的假设是浏览器通过在选项卡标题中显示一个可听图标“知道”选项卡正在播放声音,所以我猜测存在某种浏览器 HTML5 API。

最佳答案

简单的回答:

长答案:

在这种情况下,Some-what-ish 是最好的情况。Chrome 为其浏览器提供了一个仅供开发人员使用的 API,可以挂接连接的音频设备,但不可能在真实环境中使用它。 (source)

The chrome.audio API is provided to allow users to get information about and control the audio devices attached to the system. This API is currently only implemented for ChromeOS.

Jared Sohn 也回答了一个有趣的解决方案,原理是插件(也应该是 web 可能的)扫描网页以查找播放音频的文件。您可以为您的网页重写这样的内容(通过获取所有可能的音频来源并单独检查它们)。 (source)

Perhaps the closest that you can do is something similar to what the MuteTab Chrome extension does (written by me, http://www.github.com/jaredsohn/mutetab), which basically scans the page for object, embed, audio, video, and applet tags and hides them from the page. Unfortunately, this misses web audio

关于javascript - 是否可以检测浏览器选项卡是否正在播放音频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40356873/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com