onlycode.org

javascript
jquery
html
angularjs
css
node.js
ajax
html5
php
json
arrays
google-chrome
dom
regex
reactjs
ecmascript-6
javascript-events

your's history:
video is not displaying...

video is not displaying, just only code

webrtc | html | javascript

edit
yourConnection = new RTCPeerConnection(configuration);
theirConnection = new webkitRTCPeerConnection(configuration); // <-- wrong
iceServers: [{url: "stun:stun.1.google.com:19302"}] // <-- wrong
iceServers: [{urls: "stun:stun.1.google.com:19302"}]
navigator.getUserMedia({video: true, audio: true}, function(stream) { /* ... */ });
navigator.mediaDevices.getUserMedia({video: true, audio: true})
  .then(stream => { /* use stream here */ })
  .catch(error => console.log(error));
yourConnection.createOffer(function(offer) { /* ... */ }); 
yourConnection.createOffer(successCallback, failureCallback /*, optionsObject */);
const promise = yourConnection.createOffer(optionsObject);
theirVideo.src = URL.createObjectURL(stream);
theirVideo.srcObject = stream;
yourConnection.addStream(stream);
theirConnection.onaddstream = e => theirVideo.srcObject = e.stream;
for (const track of stream.getTracks()) {
  yourConnection.addTrack(track, stream);
}
theirConnection.ontrack = e => theirVideo.srcObject = e.streams[0];
const yourVideo = document.querySelector("#face_cam_vid");
const theirVideo = document.querySelector("#thevid");

(async () => {
  if (!("mediaDevices" in navigator) || !("RTCPeerConnection" in window)) {
    alert("Sorry, your browser does not support WebRTC.");
    return;
  }
  const stream = await navigator.mediaDevices.getUserMedia({video:true, audio:true});
  yourVideo.srcObject = stream;

  const configuration = {
    iceServers: [{urls: "stun:stun.1.google.com:19302"}]
  };
  const yours = new RTCPeerConnection(configuration);
  const theirs = new RTCPeerConnection(configuration);

  for (const track of stream.getTracks()) {
    yours.addTrack(track, stream);
  }
  theirs.ontrack = e => theirVideo.srcObject = e.streams[0];

  yours.onicecandidate = e => theirs.addIceCandidate(e.candidate);
  theirs.onicecandidate = e => yours.addIceCandidate(e.candidate);

  const offer = await yours.createOffer();
  await yours.setLocalDescription(offer);
  await theirs.setRemoteDescription(offer);

  const answer = await theirs.createAnswer();
  await theirs.setLocalDescription(answer);
  await yours.setRemoteDescription(answer);
})();

25
jib, 12.11.2018 22:33

Add your just only code

your name:    



If you need full text click here

Some similar links video is not displaying ↓:
Streaming a video file to an html5 video player with Node.js so that the video controls continue to work?

and video.src for changing video tag source not working in IE9

How to detect supported video formats for the HTML5 video tag?

play a video in reverse using HTML5 video element



This project is created for those who just need only code, wihout maaaaaaaaaaany words.