navigator.getusermedia [英] navigator.getusermedia
问题描述
我正在玩html5新规格,恰好是网络摄像头的功能。
I was playing around with the html5 new specifications, precisely the webcam functionalities.
通过遵循本教程。我收到以下错误:
By following this tutorial. I was getting the following error:
Native web camera streaming (getUserMedia) is not supported in this browser.
这个if语句占用了:
if (navigator.getUserMedia)
现在,我是确保在我的浏览器中启用了navigator.getUserMedia,因为这些示例此处可以正常工作完美
now, I am sure that navigator.getUserMedia is enabled in my browser, as these examples here work perfectly
因此,我使用以下内容修改了if中的代码:
so, I modified the code in the if, with the following:
if (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia)
但现在,我收到一个javascript错误:
but now, I am getting a javascript error:
Uncaught TypeError: Object #<Navigator> has no method 'getUserMedia'
此处此行:
navigator.getUserMedia('video', successCallback, errorCallback);
这真的没有意义!它正在我发布的最后一个链接上工作!
which doesn't really make sense! it IS working on the last link i posted!
任何想法?
提前致谢。
推荐答案
如果您正在测试 navigator.getUserMedia
, navigator.webkitGetUserMedia
, navigator.mozGetUserMedia
和 navigator.msGetUserMedia
那么你无法保证 navigator.getUserMedia()
可用。它可能是其他三个中的任何一个。你可以试试这样的东西(来自 getUserMedia.js ):
If you're testing for navigator.getUserMedia
, navigator.webkitGetUserMedia
, navigator.mozGetUserMedia
and navigator.msGetUserMedia
then you have no guarantee that navigator.getUserMedia()
is available. It could be that or any one of the other three. You could try something like this (from getUserMedia.js):
navigator.getUserMedia_ = ( navigator.getUserMedia
|| navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia
|| navigator.msGetUserMedia);
if ( !! navigator.getUserMedia_) {
navigator.getUserMedia_('video', successCallback, errorCallback);
//The rest of your code
这篇关于navigator.getusermedia的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!