Merge pull request #4639 from IgorA100/patch-885163

Fix: Solving the MUTED issue when using video-rtc.js & Added an "onplay" event triggered when playback starts
copilot/refactor-filepath-handling^2
Isaac Connor 2026-03-04 16:46:50 -05:00 committed by GitHub
commit 3dce095a10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 6 deletions

View File

@ -163,16 +163,23 @@ export class VideoRTC extends HTMLElement {
* https://developer.chrome.com/blog/autoplay/
*/
play() {
this.video.play().catch(() => {
if (!this.video.muted) {
this.video.play().then(_ => {
this.onplay();
})
.catch(er => {
if (er.name === 'NotAllowedError' && !this.video.muted) {
this.video.muted = true;
this.video.play().catch(er => {
console.warn(er);
});
this.play();
} else {
console.warn(er);
}
});
}
onplay() {
}
/**
* Send message to server via WebSocket
* @param {Object} value
@ -318,7 +325,7 @@ export class VideoRTC extends HTMLElement {
this.pc = null;
}
this.video.src = '';
this.video.removeAttribute('src');
this.video.srcObject = null;
}