diff --git a/custom_components/webrtc/www/video-rtc.js b/custom_components/webrtc/www/video-rtc.js index 8ecbce72..622ba91b 100644 --- a/custom_components/webrtc/www/video-rtc.js +++ b/custom_components/webrtc/www/video-rtc.js @@ -449,20 +449,24 @@ export class VideoRTC extends HTMLElement { } } - if (!sb.updating && sb.buffered && sb.buffered.length) { - const end = sb.buffered.end(sb.buffered.length - 1); - const start = end - 5; - const start0 = sb.buffered.start(0); - if (start > start0) { - sb.remove(start0, start); - ms.setLiveSeekableRange(start, end); + try { + if (!sb.updating && sb.buffered && sb.buffered.length) { + const end = sb.buffered.end(sb.buffered.length - 1); + const start = end - 5; + const start0 = sb.buffered.start(0); + if (start > start0) { + sb.remove(start0, start); + ms.setLiveSeekableRange(start, end); + } + if (this.video.currentTime < start) { + this.video.currentTime = start; + } + const gap = end - this.video.currentTime; + this.video.playbackRate = gap > 0.1 ? gap : 0.1; + // console.debug('VideoRTC.buffered', gap, this.video.playbackRate, this.video.readyState); } - if (this.video.currentTime < start) { - this.video.currentTime = start; - } - const gap = end - this.video.currentTime; - this.video.playbackRate = gap > 0.1 ? gap : 0.1; - // console.debug('VideoRTC.buffered', gap, this.video.playbackRate, this.video.readyState); + } catch (e) { + console.warn('VideoRTC.updateend', e); } });