音箱输入的示波器几秒钟后停止渲染 [英] oscilloscope of speaker input stops rendering after a few seconds

查看:154
本文介绍了音箱输入的示波器几秒钟后停止渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的脚本读取用户的麦克风的音频,并呈现在HTML画布的示波器。

The following script reads the audio from the user's microphone and renders an oscilloscope on a html canvas.

源来自Mozilla开发者网络的一个例子采取:<一href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API\"相对=nofollow>与网络音频API 可视化

The source is taken from an example of the mozilla developer network: Visualizations with Web Audio API

这里是提琴: http://jsfiddle.net/b7j8pktp/

mozGetUserMedia

(注:code有不同的浏览器没有叉​​机制:只适用于火狐)

(note: code has no fork mechanism for different browsers: works only with firefox)

它正常工作了几秒钟,然后立即停止渲染。

It works fine for a few seconds and then immediately stops rendering.

而这个工程完全稳定: http://mdn.github.io/voice -change-O-MATIC /

Whereas this works totally stable: http://mdn.github.io/voice-change-o-matic/

问题可以简化为以下code。麦克风激活图标(旁边在Firefox地址栏),约5秒后消失:

The problem can be reduced to the following code. The microphone activation icon (next to the the address bar in firefox) disappears after about 5 seconds:

navigator.mozGetUserMedia({audio: true},                           
    function() {}, function() {} );

http://jsfiddle.net/b7j8pktp/2/

推荐答案

这是在Firefox中一个已知的bug。刚刚从getUserMedia呼叫采取流并把它挂到像这样的窗口:

This is a known bug in Firefox. Just take the stream from the getUserMedia call and hook it up to the window like so:

navigator.mozGetUserMedia({音频:真正},功能(流){
  window.stream =流;
  //将code休息
},功能ERR(){
  //处理错误
});

希望我们可以得到它的尽快解决。问题是,我们未能参考,当我们做 AudioContext.createMediaStreamSource 调用,因此该流不被任何引用了当<添加到流code> getUserMedia 回调的回报,它是由循环收集器收集,当它运行,也就是几秒钟后。

Hopefully we can get it fixed soon. The problem is that we're failing to add a reference to the stream when we do the AudioContext.createMediaStreamSource call, so that the stream is not referenced by anything anymore when the getUserMedia callback returns, and it is collected by the cycle collector when it runs, that is, a couple seconds later.

您可以沿着 https://bugzilla.mozilla.org/show_bug.cgi跟随?ID = 934512

这篇关于音箱输入的示波器几秒钟后停止渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆