Skip to content

Commit

Permalink
Add auto reconnect for broken MSE stream
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 14, 2024
1 parent d9fb734 commit 063fef5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion www/video-rtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 063fef5

Please sign in to comment.