Skip to content

Commit 063fef5

Browse files
committedMay 14, 2024
Add auto reconnect for broken MSE stream
1 parent d9fb734 commit 063fef5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎www/video-rtc.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class VideoRTC extends HTMLElement {
1919
super();
2020

2121
this.DISCONNECT_TIMEOUT = 5000;
22-
this.RECONNECT_TIMEOUT = 30000;
22+
this.RECONNECT_TIMEOUT = 15000;
2323

2424
this.CODECS = [
2525
'avc1.640029', // H.264 high 4.1 (Chromecast 1st and 2nd Gen)
@@ -248,6 +248,11 @@ export class VideoRTC extends HTMLElement {
248248

249249
this.appendChild(this.video);
250250

251+
this.video.addEventListener('error', ev => {
252+
console.warn(ev);
253+
if (this.ws) this.ws.close(); // run reconnect for broken MSE stream
254+
});
255+
251256
// all Safari lies about supported audio codecs
252257
const m = window.navigator.userAgent.match(/Version\/(\d+).+Safari/);
253258
if (m) {

0 commit comments

Comments
 (0)
Please sign in to comment.