From 063fef5813c3f8de42c851cb40e0f8cff95db77b Mon Sep 17 00:00:00 2001 From: Alex X Date: Tue, 14 May 2024 21:20:25 +0300 Subject: [PATCH] Add auto reconnect for broken MSE stream --- www/video-rtc.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/www/video-rtc.js b/www/video-rtc.js index 7832e1051..56893aa98 100644 --- a/www/video-rtc.js +++ b/www/video-rtc.js @@ -19,7 +19,7 @@ export class VideoRTC extends HTMLElement { super(); this.DISCONNECT_TIMEOUT = 5000; - this.RECONNECT_TIMEOUT = 30000; + this.RECONNECT_TIMEOUT = 15000; this.CODECS = [ 'avc1.640029', // H.264 high 4.1 (Chromecast 1st and 2nd Gen) @@ -248,6 +248,11 @@ export class VideoRTC extends HTMLElement { this.appendChild(this.video); + this.video.addEventListener('error', ev => { + console.warn(ev); + if (this.ws) this.ws.close(); // run reconnect for broken MSE stream + }); + // all Safari lies about supported audio codecs const m = window.navigator.userAgent.match(/Version\/(\d+).+Safari/); if (m) {