我有以下代码:
document.addEventListener('DOMContentLoaded', function () {
var video = document.querySelector('video');
window.navigator.webkitGetUserMedia({ video: true, audio: true }, function (stream) {
var url = window.webkitURL.createObjectURL(stream);
video.src = stream;
}, function (err) {
console.log('error: ', err);
});
});
html:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>getUserMedia Video Example</title>
<script src='index.js'></script>
</head>
<body>
<video controls autoplay />
</body>
</html>
为什么不显示视频?