1
peer.on('stream', function (stream) {
            console.log('peer on stream called');
            console.log(stream);
            this.video = document.getElementById("peerVideo");            
            this.video.srcObject = stream;
            this.video.play();         
          })
          return peer
        } 

Here I am getting the video stream from a remote machine. I have logged and checked i am sure that i am getting a remote stream as the stream id at is source is same that i receive here.
this.video.srcObject = stream; this line generates a -> error Uncaught (in promise) DOMException: The play() request was interrupted by a new load request.

I tried a lot but don't know how to solve this issue.

Thanks for help.

2 Answers2

0

The problem is that the play() function is asynchronous and is loaded while the play function is running. The solution would be to start it after it is loaded.

Adding the autoplay attribute to the video object fixes the problem. And removing the call of video.play().

<video src="somefile.mp4" autoplay></video>    
Dirk V
  • 1,373
  • 12
  • 24
0

This issue can also happen if you have more than one subscribers on the stream event, in that case both subscribers will interfere with play on the same video element and interrupt each other.

Shivinder Singh
  • 143
  • 1
  • 7