小编Sta*_*ave的帖子

HTML5麦克风捕获在Firefox中停止5秒后停止

我正在使用getUserMedia()函数从麦克风捕获音频输入,在chrome中运行良好,但在5秒后firefox声音消失.如果我再次发送麦克风请求(没有重新加载页面)同样的事情发生.这是代码(我使用http://updates.html5rocks.com/2012/09/Live-Web-Audio-Input-Enabled作为指导):

//getting the function depending on browser

navigator.getMedia = ( navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);

// success callback when requesting audio input stream
function gotAudioStream(stream) {
    window.AudioContext = window.AudioContext || window.webkitAudioContext;
    var audioContext = new AudioContext();

    // Create an AudioNode from the stream.
    var mediaStreamSource = audioContext.createMediaStreamSource( stream );

    // Connect it to the destination to hear yourself (or any other node for processing!)
    mediaStreamSource.connect( audioContext.destination );
}


function gotError(err) {
      alert("An error occured! " + …
Run Code Online (Sandbox Code Playgroud)

audio getusermedia web-audio-api

17
推荐指数
1
解决办法
2747
查看次数

标签 统计

audio ×1

getusermedia ×1

web-audio-api ×1