admin管理员组文章数量:1415062
I have index.html and app.js - index.html
<!DOCTYPE html>
<html>
<head>
<title>Realtime munication with WebRTC</title>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<h1>Realtime munication with WebRTC</h1>
<video autoplay></video>
<script src="js/main.js"></script>
</body>
</html>
app.js =>
'use strict';
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = {
audio: false,
video: true
};
var video = document.querySelector('video');
function successCallback(stream) {
window.stream = stream; // stream available to console
if (window.URL) {
video.src = window.URL.createObjectURL(stream);
} else {
video.src = stream;
}
}
function errorCallback(error) {
console.log('navigator.getUserMedia error: ', error);
}
navigator.getUserMedia(constraints, successCallback, errorCallback);
So when I open run index.html I got error - :8888/getUserMedia/[object%20MediaStream]:1 GET http://localhost:8888/getUserMedia/[object%20MediaStream] getUserMedia is not a function.
I also tried on apache server. But got same error.
I have index.html and app.js - index.html
<!DOCTYPE html>
<html>
<head>
<title>Realtime munication with WebRTC</title>
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<h1>Realtime munication with WebRTC</h1>
<video autoplay></video>
<script src="js/main.js"></script>
</body>
</html>
app.js =>
'use strict';
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = {
audio: false,
video: true
};
var video = document.querySelector('video');
function successCallback(stream) {
window.stream = stream; // stream available to console
if (window.URL) {
video.src = window.URL.createObjectURL(stream);
} else {
video.src = stream;
}
}
function errorCallback(error) {
console.log('navigator.getUserMedia error: ', error);
}
navigator.getUserMedia(constraints, successCallback, errorCallback);
So when I open run index.html I got error - :8888/getUserMedia/[object%20MediaStream]:1 GET http://localhost:8888/getUserMedia/[object%20MediaStream] getUserMedia is not a function.
I also tried on apache server. But got same error.
Share Improve this question asked Jul 23, 2016 at 13:28 Aditya GuptaAditya Gupta 491 silver badge8 bronze badges 1- Did some stupid things. My code is all fine and working properly. I added different js file. Sorry! – Aditya Gupta Commented Jul 23, 2016 at 20:59
2 Answers
Reset to default 6include adapter.js and set
video.srcObject = stream;
Everything else is deprecated.
You just change
element.src = window.URL.createObjectURL(stream);
to:
element.srcObject = stream;
element.onloadedmetadata = function(e) { element.play(); };
本文标签: javascriptgot 404 error while using getUserMedia() APIStack Overflow
版权声明:本文标题:javascript - got 404 error while using getUserMedia() API - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745230615a2648806.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论