From f51fdd73b2ed49ee5fe1b1745e8c2b50686475bb Mon Sep 17 00:00:00 2001 From: daveyijzermans Date: Fri, 3 Jul 2026 14:40:24 +0200 Subject: [PATCH] Fix permanent auto-mute on transient play() rejections The play() fallback treated every rejection as an autoplay-policy block and permanently muted the video. Transient rejections (e.g. AbortError when a new load interrupts play during stream reconnect or conditional card re-show) also tripped it, leaving kiosks silent until a full page reload. Only fall back to muted playback on NotAllowedError. Co-Authored-By: Claude Fable 5 --- custom_components/webrtc/www/video-rtc.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/custom_components/webrtc/www/video-rtc.js b/custom_components/webrtc/www/video-rtc.js index 8ecbce72..5789258c 100644 --- a/custom_components/webrtc/www/video-rtc.js +++ b/custom_components/webrtc/www/video-rtc.js @@ -164,12 +164,17 @@ export class VideoRTC extends HTMLElement { * https://developer.chrome.com/blog/autoplay/ */ play() { - this.video.play().catch(() => { - if (!this.video.muted) { + this.video.play().catch(er => { + // mute-fallback only on a real autoplay-policy block; transient + // rejections (e.g. AbortError while reconnecting) must not + // permanently mute the video + if (er.name === 'NotAllowedError' && !this.video.muted) { this.video.muted = true; - this.video.play().catch(er => { - console.warn(er); + this.video.play().catch(er2 => { + console.warn(er2); }); + } else { + console.warn(er); } }); }