This commit is contained in:
NoLogicAlan committed 2026-09-11 03:06:38 +03:00
1 parent 884018a6d1
commit fefe490c60
1 file changed
+4 -30
+4 -30
View File
@@ -80,12 +80,9 @@ export class FluxerAudioBridge extends EventEmitter {
const direct = await this._getTrackstreamUrl(trackInfo); const direct = await this._getTrackstreamUrl(trackInfo);
if (direct?.url && /webm|opus/i.test(direct.format || "")) { if (direct?.url && /webm|opus/i.test(direct.format || "")) {
this._usedTrackstream = true; this._usedTrackstream = true;
logger.player("[AudioBridge] Passthrough webm/opus via trackstream: " + (trackInfo.title || "unknown")); logger.player("[AudioBridge] Passthrough webm/opus via trackstream (zero-copy): " + (trackInfo.title || "unknown"));
const directLoaded = await this._httpRequestStream(direct.url, this._streamFetchHeaders(trackInfo)); await conn.play(direct.url);
this._sourceStream = directLoaded.stream;
this._sourceReq = directLoaded.req || null;
await conn.play(directLoaded.stream);
if (generation !== this._playGeneration) return "stopped"; if (generation !== this._playGeneration) return "stopped";
if (durationMs > 0) await this._waitDuration(durationMs); if (durationMs > 0) await this._waitDuration(durationMs);
@@ -108,11 +105,8 @@ export class FluxerAudioBridge extends EventEmitter {
const freshDirect = await this._getTrackstreamUrl(trackInfo); const freshDirect = await this._getTrackstreamUrl(trackInfo);
if (freshDirect?.url && /webm|opus/i.test(freshDirect.format || "")) { if (freshDirect?.url && /webm|opus/i.test(freshDirect.format || "")) {
this._usedTrackstream = true; this._usedTrackstream = true;
logger.player("[AudioBridge] Fresh trackstream is webm/opus — passthrough: " + (trackInfo.title || "unknown")); logger.player("[AudioBridge] Fresh trackstream is webm/opus — zero-copy passthrough: " + (trackInfo.title || "unknown"));
const freshLoaded = await this._httpRequestStream(freshDirect.url, this._streamFetchHeaders(trackInfo)); await conn.play(freshDirect.url);
this._sourceStream = freshLoaded.stream;
this._sourceReq = freshLoaded.req || null;
await conn.play(freshLoaded.stream);
if (generation !== this._playGeneration) return "stopped"; if (generation !== this._playGeneration) return "stopped";
if (durationMs > 0) await this._waitDuration(durationMs); if (durationMs > 0) await this._waitDuration(durationMs);
if (generation !== this._playGeneration) return "stopped"; if (generation !== this._playGeneration) return "stopped";
@@ -310,26 +304,6 @@ export class FluxerAudioBridge extends EventEmitter {
} }
} }
/**
* @param {object} trackInfo
* @returns {object}
* @private
*/
_streamFetchHeaders(trackInfo) {
const headers = {};
if (trackInfo?.url && /^https?:\/\//i.test(trackInfo.url)) {
try {
const host = new URL(trackInfo.url).hostname;
if (/(^|\.)bilibili\.com$/i.test(host)) {
headers["Referer"] = "https://www.bilibili.com/";
} else {
headers["Referer"] = new URL(trackInfo.url).origin + "/";
}
} catch (_) {}
}
return headers;
}
/** Stop current playback and clean up resources. */ /** Stop current playback and clean up resources. */
stop() { stop() {
const wasPlaying = this._playing; const wasPlaying = this._playing;