WebRTC getUserMedia Promise API Support in Chrome

斯图佛

chrome是否支持基于承诺的WebRTC API?我无法在Chrome中使用基于getUserMedia()承诺的API。

<!DOCTYPE html>
<html>
    <head>
        <title> Mitel WebRTC client </title>
        <script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
        <script src='dist/webrtc.min.js'></script>

        <script type="text/javascript">
            function startUp() {

                var options = {
                    audio: true,
                    video: true
                };
                if (getUserMedia) {
                    getUserMedia(options)
                    .then(function (stream) {
                        console.log("Acquired audio and video!");
                    })
                    .catch(function (err) {
                        console.log(err.name + ": " + err.message);
                    });
                } else {
                    alert("WebRTC not supported on this browser");
                }
            }
        </script>
    </head>

    <body onload="startUp();">
        <h1>WebRTC Promise API Client Application</h1>
    </body>
</html>

在控制台上,我看到以下错误

This appears to be Chrome
adapter-latest.js:32 chrome: {"audio":true,"video":true}
adapter-latest.js:410 Uncaught TypeError: Failed to execute 'webkitGetUserMedia' on 'Navigator': The callback provided as parameter 2 is not a function.

我想利用基于承诺的API。我想念什么吗?

短臂

它尚未在Chrome中实现,但如果您使用官方的adapter.js WebRTC polyfill,它将在此处运行https : //jsfiddle.net/srn9db4h/

var constraints = { video: true, audio: true };

navigator.mediaDevices.getUserMedia(constraints)
  .then(stream => video.srcObject = stream)
  .catch(e => console.error(e));

Firefox和Edge本身就支持FWIW。

更新: Chrome(50)现在似乎支持此功能。而且Chrome 52甚至支持srcObject

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

getUserMedia错误webRTC

RTCMultiConnection上的WebRTC PermissionDeniedError getUserMedia

通过socketio发送webRTC getUserMedia webCam流

navigator.getUserMedia不是使用WebRTC的函数

通过UWP WebView使用WebRTC getUserMedia的问题

chrome不支持getUserMedia()

Chrome iOS中的webRTC

WebRTC Chrome相机限制

为什么XSockets.WebRTC getUserMedia返回未定义?

WebRTC getUserMedia()仅在Firefox上有效

将WebRTC getUserMedia与UWP WebView一起使用

chrome 47中的getUserMedia(),不使用https

WebRTC chrome远程音频转发

WebRTC getStat()API设置

使用 getUserMedia API 配置帧格式

我可以使用MediaDevices.getUserMedia()连接到多个Webrtc流的音频输入设备吗?

Android React Native应用在getUserMedia WebRTC调用时崩溃

被getUserMedia捕获后,将MediaStream发送到具有WebRTC的主机服务器

将4k Logitech网络摄像头与WebRTC / getUserMedia一起使用

WebRTC getUserMedia:在音频和视频+音频流之间切换

“ getUserMedia”在Chrome版本36.0.1985.125中不起作用

Firefox和Chrome中的getUserMedia()视频大小不同

为什么GetUserMedia无法在Google Chrome中显示视频?

navigator.getUserMedia无法在Android / Chrome上运行

如何在 Chrome 中使用 getUserMedia 对象获取播放视频

Chrome扩展程序-getUserMedia引发“ NotAllowedError:由于关机失败”

getUserMedia在Android Chrome的第一帧冻结

使用Chrome和本地主机(不带HTTPS)的JavaScript GetUserMedia

Chrome上的getUserMedia经常无法返回最佳分辨率