update readme

This commit is contained in:
vdalex
2024-04-18 13:22:00 +03:00
parent 2ecc0a0991
commit 95fd366486
2 changed files with 20 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@@ -326,12 +326,9 @@ export default class RTSPtoWEBPlayer {
}
};
this.webSocket.onmessage = ({data}) => {
if (this.codec === null) {
if (typeof data === 'object') {
if (this.codec === null) {
this.codec = new TextDecoder('utf-8').decode(new Uint8Array(data).slice(1));
} else {
this.codec = data;
}
this.MSESourceBuffer = this.MSE.addSourceBuffer(`video/mp4; codecs="${this.codec}"`);
this.MSESourceBuffer.mode = 'segments';
this.MSE.duration = Infinity;
@@ -341,6 +338,18 @@ export default class RTSPtoWEBPlayer {
this.readPacket(data);
}
}
} else {
if (this.codec !== null) {
console.log(data);
} else {
this.codec = data;
this.MSESourceBuffer = this.MSE.addSourceBuffer(`video/mp4; codecs="${this.codec}"`);
this.MSESourceBuffer.mode = 'segments';
this.MSE.duration = Infinity;
this.MSESourceBuffer.addEventListener('updateend', this.pushPacket);
}
}
if (document[this.hidden] && this.video.buffered.length) {
this.video.currentTime = this.video.buffered.end(this.video.buffered.length - 1) - 1;
}