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>