问题描述
我正在寻找一种方法来检测是否在Chrome的当前标签中播放了声音。我想强调的是,上下文是一个Web应用程序,不是Chrome扩展程序,也不是一个音频元素。我的假设是,浏览器知道该标签正在播放声音,通过在标签标题中显示一个可听图标,所以我猜测这里有某种浏览器HTML5 API。
简单的答案:没有
b
$ b
在这种情况下,一些什么是最好的情况。
Chrome在浏览器中有一个dev-only API,可以连接音频设备,但在真实环境中无法使用它。
Jared Sohn也有一个有趣的解决方案,原理是一个插件(应该可能是web)也会扫描网页播放音频的文件。您可以为您的网页重写这样的内容(通过抓取所有可能的音频源并单独检查它们)。
I am looking for a way to detect whether a sound is being played in the current tab of Chrome. I would like to emphasize that the context is a web app and not a chrome extension nor a single audio element. My assumption is that the browser "knows" that the tab is playing sound by displaying an audible icon in the tab header, so I am guessing that there is some kind of browser HTML5 API for that.
Simple answer: no
Long answer:
Some-what-ish would be the best case in this context.Chrome has a dev-only API for it's browser that hooks on audio devices connected, but it's not possible to use this in a real environment. (source)
There is also an interesting solution answered by Jared Sohn, the principle is that a plugin (should be web possible as well) scans the webpage for files playing audio. You could rewrite something like this for your webpage (by grabbing all possible sources for audio and checking them individually). (source)
这篇关于是否有可能检测浏览器选项卡是否播放音频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!