If we need to create a URL for a stream, why can we set video.src for a stream for WebRTC?

The following code sample is provided in the Google WebRTC Tutorial .

I have two questions:

  • Why do we need to set window.stream for the stream? (What does “console accessible stream” mean?)
  • If we need to create a URL for the stream, why can we set video.src for the stream, which should be a blob?

Thanks.

function successCallback(stream) {
  window.stream = stream; // stream available to console
  if (window.URL) {
    video.src = window.URL.createObjectURL(stream);
  } else {
    video.src = stream;
  }
}
+3
source share
1 answer

Old and wrong code. video.src = streamwrong. It should be video.srcObject = stream. It just does not start, because today all browsers support it URL.

srcObject , ( Chrome, Firefox) :

if (typeof video.srcObject == "object") {
  video.srcObject = stream;
} else {
  video.src = URL.createObjectURL(stream);
}

adapter.js :

video.srcObject = stream;

, window.stream - - . , .

2013 WebRTC. WebRTC.

+8

All Articles