From 537a680073808edd25606d938f3b67ef00a64bc6 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Fri, 3 Apr 2026 12:12:20 +0200 Subject: [PATCH] idk --- web/js/audio.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/js/audio.js b/web/js/audio.js index 85cf156..345da4a 100644 --- a/web/js/audio.js +++ b/web/js/audio.js @@ -10,8 +10,8 @@ class WebSocketAudioPlayer { } _trimBuffer() { - if (!this.sourceBuffer.updating && this.audio.currentTime > 5) { - this.sourceBuffer.remove(0, this.audio.currentTime - 2); + if (!this.sourceBuffer.updating && this.audio.currentTime > 1) { + this.sourceBuffer.remove(0, this.audio.currentTime - 0.5); } } @@ -22,7 +22,10 @@ class WebSocketAudioPlayer { this.mediaSource.addEventListener('sourceopen', () => { 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.binaryType = 'arraybuffer';