0

I am trying to pass a media stream from page 1 to page 2. I am getting a media stream with the same ID on page 2 as the media stream generated on page 1. But I am not able to add this media stream to the video tag that is present in the page 2 HTML code.

I have tried creating srcObject to the video element and also tried adding the media stream as URL.

const remoteVideo = document.querySelector('#remoteVideo');
function gotRemoteStream(event) {
  console.log('got remote stream');
  try {
    remoteVideo.srcObject = event.streams[0];
    console.log('added remote stream');
  } catch (error) {
      console.log(error);
  }

  console.log(remoteVideo.srcObject);
}

The last console.log returns -

MediaStream {id: "P7pInpAX7ee32KJOsPRNxZWEcdjjAg5Sq7pk", active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}

But this media stream does not get added to the video element tag in

<video id="remoteVideo" src="" playsinline autoplay></video>
Vijay
  • 61
  • 6
  • how do you route from page1 to page2 ? Are you using some kind of framework like angular, react js or Vue? – Serdar Mar 24 '19 at 07:09
  • I am using node(express) and socket.io. – Vijay Mar 24 '19 at 07:45
  • As far as I see your second page is not aware of your media stream. How are you passing it from page 1 to page 2 ? – Serdar Mar 25 '19 at 06:12
  • I am trying to implement WebRTC. So I am using TURN servers for signalling and the media transfer is supposed to be peer to peer. – Vijay Mar 25 '19 at 16:12

0 Answers0