mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix(player): fix HLS live edge, silence stderr log warnings, and fix queue auto-advance
This commit is contained in:
1 parent
357197016b
commit
08634adb88
2 files changed
+19
-6
No files matched your search
@@ -737,6 +737,7 @@ export class FluxerAudioBridge extends EventEmitter {
|
|||||||
const headers = url.includes("soundcloud.cloud")
|
const headers = url.includes("soundcloud.cloud")
|
||||||
? "Origin: https://soundcloud.com\r\nReferer: https://soundcloud.com/\r\n"
|
? "Origin: https://soundcloud.com\r\nReferer: https://soundcloud.com/\r\n"
|
||||||
: "Origin: https://www.youtube.com\r\nReferer: https://www.youtube.com/\r\n";
|
: "Origin: https://www.youtube.com\r\nReferer: https://www.youtube.com/\r\n";
|
||||||
|
const isHls = url.includes(".m3u8") || /hls|m3u8/i.test(url);
|
||||||
const ffmpegArgs = [
|
const ffmpegArgs = [
|
||||||
"-re",
|
"-re",
|
||||||
"-headers", headers,
|
"-headers", headers,
|
||||||
@@ -744,6 +745,12 @@ export class FluxerAudioBridge extends EventEmitter {
|
|||||||
"-reconnect", "1",
|
"-reconnect", "1",
|
||||||
"-reconnect_streamed", "1",
|
"-reconnect_streamed", "1",
|
||||||
"-reconnect_delay_max", "5",
|
"-reconnect_delay_max", "5",
|
||||||
|
];
|
||||||
|
if (isHls) {
|
||||||
|
/* Start HLS live streams and DVR radios at the broadcast edge instead of starting from 0 (12h in the past) */
|
||||||
|
ffmpegArgs.push("-live_start_index", "-3");
|
||||||
|
}
|
||||||
|
ffmpegArgs.push(
|
||||||
"-i", url,
|
"-i", url,
|
||||||
"-vn",
|
"-vn",
|
||||||
"-filter:a", "volume=1.0",
|
"-filter:a", "volume=1.0",
|
||||||
@@ -751,7 +758,7 @@ export class FluxerAudioBridge extends EventEmitter {
|
|||||||
"-ar", "48000",
|
"-ar", "48000",
|
||||||
"-ac", "2",
|
"-ac", "2",
|
||||||
"pipe:1"
|
"pipe:1"
|
||||||
];
|
);
|
||||||
const proc = spawn("ffmpeg", ffmpegArgs, { stdio: ["ignore", "pipe", "pipe"] });
|
const proc = spawn("ffmpeg", ffmpegArgs, { stdio: ["ignore", "pipe", "pipe"] });
|
||||||
this._ffmpegProc = proc;
|
this._ffmpegProc = proc;
|
||||||
|
|
||||||
@@ -771,11 +778,8 @@ export class FluxerAudioBridge extends EventEmitter {
|
|||||||
logger.warn("[AudioBridge] FFmpeg process error: " + err.message);
|
logger.warn("[AudioBridge] FFmpeg process error: " + err.message);
|
||||||
});
|
});
|
||||||
proc.stderr.on("data", (chunk) => {
|
proc.stderr.on("data", (chunk) => {
|
||||||
const text = chunk.toString();
|
/* Buffer trailing stderr for error reporting on non-zero exit; avoid logging in-flight progress lines */
|
||||||
stderrBuf = (stderrBuf + text).slice(-600);
|
stderrBuf = (stderrBuf + chunk.toString()).slice(-600);
|
||||||
if (text.includes("403") || text.includes("404") || text.includes("Server returned")) {
|
|
||||||
logger.warn("[AudioBridge] FFmpeg HTTP: " + text.trim().split("\n").pop());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this._stream = this._buildPcmPipeline(proc.stdout);
|
this._stream = this._buildPcmPipeline(proc.stdout);
|
||||||
|
|||||||
@@ -388,9 +388,18 @@ const PlaybackMixin = {
|
|||||||
filterPayload: this.activeFilterPayload || null,
|
filterPayload: this.activeFilterPayload || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (result === null) {
|
||||||
|
throw new Error("Playback failed to start for track: " + (songData?.title ?? "unknown"));
|
||||||
|
}
|
||||||
|
|
||||||
if (result === "finished" && !this._skipping && !this.leaving && !this._paused) {
|
if (result === "finished" && !this._skipping && !this.leaving && !this._paused) {
|
||||||
this._handleTrackEnd();
|
this._handleTrackEnd();
|
||||||
} else if (result === "stopped") {
|
} else if (result === "stopped") {
|
||||||
|
if (!this._skipping && !this.leaving && !this._paused) {
|
||||||
|
/* Unintended stop (audio connection drop or source early-close): advance queue so playback does not stall */
|
||||||
|
logger.player(`[Player] Track ended unexpectedly with status '${result}', auto-advancing`);
|
||||||
|
this._handleTrackEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user