This commit is contained in:
NoLogicAlan committed 2026-10-14 02:05:50 +03:00
1 parent 64f5782d53
commit 93f12487d3
3 files changed
+85

No files matched your search

+22
View File
@@ -253,6 +253,26 @@ const PlaybackMixin = {
}
},
/**
* @private Shortly after a track starts, warm the NEXT queued track (resolve +
* trackstream URL) so the transition does not wait on NodeLink.
* @this {import('./Player.mjs').Player}
*/
_schedulePrefetchNext() {
if (this._prefetchTimer) clearTimeout(this._prefetchTimer);
this._prefetchTimer = setTimeout(() => {
this._prefetchTimer = null;
try {
if (this._destroyed || this.leaving || !this._audioBridge?.prefetchTrack) return;
if (this.queue.songLoop) return; // next track is the same one
const next = this.queue.data?.[0];
if (!next) return;
this._audioBridge.prefetchTrack(next, this._guildId);
} catch (_) {}
}, 6_000);
this._prefetchTimer.unref?.();
},
/**
* @private @async Play a track through the FluxerAudioBridge. For
* radio/external tracks without an encoded payload, attempts Lavalink URL
@@ -318,6 +338,8 @@ const PlaybackMixin = {
const totalMs = this._getTrackDurationMs(songData);
const durationMs = totalMs > 0 ? Math.max(0, totalMs - seekMs) : 0;
this._schedulePrefetchNext();
const result = await this._audioBridge.play(this._voiceConn, {
encoded: songData.encoded,
url: bridgeUrl,