mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-30 08:49:16 +02:00
idk
This commit is contained in:
+6
-3
@@ -10,8 +10,8 @@ class WebSocketAudioPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_trimBuffer() {
|
_trimBuffer() {
|
||||||
if (!this.sourceBuffer.updating && this.audio.currentTime > 5) {
|
if (!this.sourceBuffer.updating && this.audio.currentTime > 1) {
|
||||||
this.sourceBuffer.remove(0, this.audio.currentTime - 2);
|
this.sourceBuffer.remove(0, this.audio.currentTime - 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +22,10 @@ class WebSocketAudioPlayer {
|
|||||||
|
|
||||||
this.mediaSource.addEventListener('sourceopen', () => {
|
this.mediaSource.addEventListener('sourceopen', () => {
|
||||||
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/mpeg');
|
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/mpeg');
|
||||||
this.sourceBuffer.addEventListener('updateend', () => this._appendNext());
|
this.sourceBuffer.addEventListener('updateend', () => {
|
||||||
|
this._appendNext();
|
||||||
|
this._trimBuffer();
|
||||||
|
});
|
||||||
|
|
||||||
this.ws = new WebSocket(this.url);
|
this.ws = new WebSocket(this.url);
|
||||||
this.ws.binaryType = 'arraybuffer';
|
this.ws.binaryType = 'arraybuffer';
|
||||||
|
|||||||
Reference in New Issue
Block a user