Firefox:navigator.getUserMedia不是一个函数 [英] Firefox: navigator.getUserMedia is not a function

查看:3596
本文介绍了Firefox:navigator.getUserMedia不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在这样做

  var session = {
audio:true,
video:false
};
var recordRTC = null;
navigator.getUserMedia(session,initializeRecorder,onError);

但是,使用最新的FF我得到了一个javascript错误,说


navigator.getUserMedia不是函数

此博客文章: https ://blog.groupbuddies.com/posts/39-tutorial-html-audio-capture-streaming-to-nodejs-no-browser-extensions



类似于最新的Chrome:


未捕获的TypeError:undefined不是函数

但是我知道这个API是来自两个浏览器的支持



我做错了什么?

解决方案

尚未支持前提。请参阅 http://caniuse.com/#search=getusermedia



您需要获取浏览器特定的前缀并使用它。正如在另一个答案中发布的那样:

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

这会将 navigator.getUserMedia 它会检测到正确的前缀版本。


I'm playing with browser and audio.

I'm doing this

        var session = {
          audio: true,
          video: false
        };
        var recordRTC = null;
        navigator.getUserMedia(session, initializeRecorder, onError);

But, using latest FF available I got a javascript error, saying that

navigator.getUserMedia is not a function

I copied this code from this blog post: https://blog.groupbuddies.com/posts/39-tutorial-html-audio-capture-streaming-to-nodejs-no-browser-extensions

And similar on latest Chrome:

Uncaught TypeError: undefined is not a function

But I know that this api is supported from both browser

What am I doing wrong?

解决方案

It's not supported unprefixed yet. See http://caniuse.com/#search=getusermedia

You'll need to get the browser-specific prefix and use that. As posted in another answer:

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

This will set navigator.getUserMedia to whatever it detects to be the proper prefixed version.

这篇关于Firefox:navigator.getUserMedia不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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