大佬,看报错原因是createObjectURL过时引起的报错,可以使用新的srcObject替换:
还存在一个拼写错误:'navagator' 改为 'navigator'
以下是修改后的代码您再试试哈
- $("[fgcname=video]").empty();
- $("[fgcname=video]").append("<video id='video' width='400' height='300' autoplay></video>");
- $("[fgcname=canvas]").empty();
- $("[fgcname=canvas]").append("<canvas id='canvas' width='400' height='300'></canvas>");
- var video = document.getElementById('video'),
- canvas = document.getElementById('canvas'),
- img = document.getElementById('img');
- navigator.getMedia = navigator.getUserMedia ||
- navigator.webkitGetUserMedia ||
- navigator.mozGetUserMedia ||
- navigator.msGetUserMedia;
- navigator.getMedia({
- video: true,
- audio: false
- }, function(stream) {
- console.log(stream);
- video.srcObject = stream;
- video.play();
- }, function(error) {
- console.log(error);
- });
复制代码
|