最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to detect whether a browser tab is playing audio or not? - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question edited Dec 20, 2016 at 18:52 Crowcoder 11.5k3 gold badges38 silver badges46 bronze badges asked Nov 1, 2016 at 9:01 Ramy Ben AroyaRamy Ben Aroya 2,42316 silver badges20 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 5

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)

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.

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)

Perhaps the closest that you can do is something similar to what the MuteTab Chrome extension does (written by me, http://www.github./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

发布评论

评论列表(0)

  1. 暂无评论