简体   繁体   English

Javascript检测录音

[英]Javascript detect audio recording

I'm building a chrome extension and I would like to detect when the current page starts an audio recording using a content script that gets injected into the current page from the extension. 我正在构建一个chrome扩展程序,我想检测当前页面何时开始使用从扩展程序注入到当前页面的内容脚本开始录音。

I don't have access to the audio stream, nor the MediaRecorder objects (these are handled separately by the page itself, has nothing to do with the extension), and was wondering if there's any callback/event I could hook into in order to observe these events: start recording and stop recording. 我无权访问音频流,也没有MediaRecorder对象(这些对象由页面本身单独处理,与扩展无关),并且想知道是否可以挂入任何回调/事件以观察以下事件:开始记录并停止记录。

Since the Chrome tab changes appearance when the recording is started and when it is stopped, I was thinking there are certain events I could monitor so I can know if a recording has started or has stopped. 由于Chrome标签在录制开始和停止时会更改外观,因此我想可以监控某些事件,以便知道录制是开始还是停止。

Any help is much appreciated. 任何帮助深表感谢。

https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder_API https://developer.mozilla.org/zh-CN/docs/Web/API/MediaRecorder_API

There is the dataavailable event you can listen to, but that only fires after the audio has been recorded. 您可以收听有dataavailable事件,但是只有录制音频才会触发。

There seems to be no event to indicate when the recording starts. 似乎没有事件可指示何时开始录制。

You could add a feature request to chrome to have this event available for plugin devs. 您可以向chrome添加功能请求,以使该事件可用于插件开发者。

You can also download the source of chromium to see what happens internally the moment audio recording starts and see if you can capture one of those changes somehow. 您还可以下载的来源,以查看开始录音时内部发生的情况,并查看是否可以某种方式捕获其中的一种变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM