Fix errors in JS player
This commit is contained in:
+18
-14
@@ -392,21 +392,23 @@ export class VideoRTC extends HTMLElement {
|
|||||||
sb.mode = "segments"; // segments or sequence
|
sb.mode = "segments"; // segments or sequence
|
||||||
sb.addEventListener("updateend", () => {
|
sb.addEventListener("updateend", () => {
|
||||||
if (sb.updating) return;
|
if (sb.updating) return;
|
||||||
if (bufLen > 0) {
|
|
||||||
try {
|
try {
|
||||||
sb.appendBuffer(buf.slice(0, bufLen));
|
if (bufLen > 0) {
|
||||||
} catch (e) {
|
const data = buf.slice(0, bufLen);
|
||||||
// console.debug(e);
|
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);
|
||||||
|
if (end > start) {
|
||||||
|
sb.remove(start, end);
|
||||||
|
ms.setLiveSeekableRange(end, end + 5);
|
||||||
|
}
|
||||||
|
// console.debug("VideoRTC.buffered", start, end);
|
||||||
}
|
}
|
||||||
bufLen = 0;
|
} catch (e) {
|
||||||
} else if (sb.buffered && sb.buffered.length) {
|
// console.debug(e);
|
||||||
const end = sb.buffered.end(sb.buffered.length - 1) - 5;
|
|
||||||
const start = sb.buffered.start(0);
|
|
||||||
if (end > start) {
|
|
||||||
sb.remove(start, end);
|
|
||||||
ms.setLiveSeekableRange(end, end + 5);
|
|
||||||
}
|
|
||||||
// console.debug("VideoRTC.buffered", start, end);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -504,6 +506,8 @@ export class VideoRTC extends HTMLElement {
|
|||||||
* @param ev {Event}
|
* @param ev {Event}
|
||||||
*/
|
*/
|
||||||
onpcvideo(ev) {
|
onpcvideo(ev) {
|
||||||
|
if (!this.pc) return;
|
||||||
|
|
||||||
/** @type {HTMLVideoElement} */
|
/** @type {HTMLVideoElement} */
|
||||||
const video2 = ev.target;
|
const video2 = ev.target;
|
||||||
const state = this.pc.connectionState;
|
const state = this.pc.connectionState;
|
||||||
|
|||||||
Reference in New Issue
Block a user