小编Adi*_*pta的帖子

使用getUserMedia()API时出现404错误

我有index.html和app.js-index.html

<!DOCTYPE html>
<html>
<head>
  <title>Realtime communication with WebRTC</title>
  <link rel="stylesheet" href="css/main.css" />
</head>
<body>
  <h1>Realtime communication with WebRTC</h1>
  <video autoplay></video>
  <script src="js/main.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

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: ', …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome webrtc

2
推荐指数
1
解决办法
1695
查看次数

标签 统计

google-chrome ×1

javascript ×1

webrtc ×1