Fix Chrome issue

This commit is contained in:
Pierre HUBERT 2020-04-14 08:47:47 +02:00
parent d4c2152ecd
commit 778b20ee33

View File

@ -681,7 +681,23 @@ class CallWindow extends CustomEvents {
videoEl.muted = muted; videoEl.muted = muted;
videoEl.srcObject = stream videoEl.srcObject = stream
// Fix Chrome exception: DOMException: play() failed because the user didn't interact with the document first.
try {
await videoEl.play()
} catch(e) {
console.error("Caught play() error", e)
notify("Please click anywhere on the page to resume video call");
// Wait for user interaction before trying again
document.addEventListener("click", () => {
if(videoEl.isConnected)
videoEl.play() videoEl.play()
}, {
once: true
})
}
this.videoEls.set(peerID, videoEl) this.videoEls.set(peerID, videoEl)