Fix errors in JS player

This commit is contained in:
Alexey Khit
2023-01-15 00:11:31 +03:00
parent 1c830d6e60
commit 39662e10af
+9 -5
View File
@@ -392,13 +392,12 @@ export class VideoRTC extends HTMLElement {
sb.mode = "segments"; // segments or sequence
sb.addEventListener("updateend", () => {
if (sb.updating) return;
if (bufLen > 0) {
try {
sb.appendBuffer(buf.slice(0, bufLen));
} catch (e) {
// console.debug(e);
}
if (bufLen > 0) {
const data = buf.slice(0, bufLen);
bufLen = 0;
sb.appendBuffer(data);
} else if (sb.buffered && sb.buffered.length) {
const end = sb.buffered.end(sb.buffered.length - 1) - 5;
const start = sb.buffered.start(0);
@@ -408,6 +407,9 @@ export class VideoRTC extends HTMLElement {
}
// console.debug("VideoRTC.buffered", start, end);
}
} catch (e) {
// console.debug(e);
}
});
const buf = new Uint8Array(2 * 1024 * 1024);
@@ -504,6 +506,8 @@ export class VideoRTC extends HTMLElement {
* @param ev {Event}
*/
onpcvideo(ev) {
if (!this.pc) return;
/** @type {HTMLVideoElement} */
const video2 = ev.target;
const state = this.pc.connectionState;