Add auto reconnect for broken MSE stream

This commit is contained in:
Alex X
2024-05-14 21:20:25 +03:00
parent d9fb734c85
commit 063fef5813

View File

@@ -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) {