chrome是否支持WebRTC的基于承诺的API?我无法让基于getUserMedia()承诺的API在Chrome中运行.
Mitel WebRTC client WebRTC Promise API Client Application
在控制台上,我看到以下错误
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.
我想利用基于promise的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
.