fix(audio): support continuous playback of YouTube Live and HLS streams

- Decode aac_hls/m3u8 streams returned by trackstream via in-process ffmpeg
- Correct isStream/isLive detection from Lavalink track info
- Clamp live stream duration to zero to prevent premature end-of-track triggers
- Display LIVE badge for live broadcast tracks
This commit is contained in:
NoLogicAlan committed 2026-11-02 01:06:46 +03:00
1 parent 0ec41c9bb5
commit c419e9e7c6
4 files changed
+30 -5

No files matched your search

+23 -3
View File
@@ -460,8 +460,20 @@ export class FluxerAudioBridge extends EventEmitter {
} }
if (!/webm|opus/i.test(String(direct.format || ""))) { if (!/webm|opus/i.test(String(direct.format || ""))) {
// Last chance: sniff the direct URL's actual bytes — format strings /* If format is HLS / m3u8 (YouTube Live, SoundCloud live), directly decode via in-process ffmpeg */
// can lie (e.g. "mp4" that is really a WebM/Opus stream). if (/hls|m3u8/i.test(String(direct.format || "")) || (direct.url && direct.url.includes(".m3u8"))) {
logger.player("[AudioBridge] trackstream direct URL is HLS (" + (direct.format || "m3u8") + ") — playing via in-process ffmpeg: " + direct.url.substring(0, 80));
this._usedTrackstream = true;
try {
return await this._playViaFfmpeg(conn, direct.url, durationMs, generation);
} catch (ffErr) {
if (stale()) return "stopped";
logger.warn("[AudioBridge] trackstream HLS ffmpeg playback failed: " + ffErr.message);
return null;
}
}
/* Try in-process byte positioning for WebM/Ogg streams (e.g. if format string lied) */
try { try {
const opened = await this._openPositionedStream(direct.url, seekMs); const opened = await this._openPositionedStream(direct.url, seekMs);
if (stale()) return "stopped"; if (stale()) return "stopped";
@@ -471,11 +483,19 @@ export class FluxerAudioBridge extends EventEmitter {
return result; return result;
} catch (e3) { } catch (e3) {
if (stale()) return "stopped"; if (stale()) return "stopped";
logger.player("[AudioBridge] trackstream direct URL not playable in-process (" + e3.message + ")"); /* Non-WebM direct stream (AAC, MP4, HLS fallback): play via in-process FFmpeg */
logger.player("[AudioBridge] trackstream direct URL is non-webm (" + (direct.format || e3.message) + ") — playing via in-process ffmpeg: " + direct.url.substring(0, 80));
this._usedTrackstream = true;
try {
return await this._playViaFfmpeg(conn, direct.url, durationMs, generation);
} catch (ffErr) {
if (stale()) return "stopped";
logger.warn("[AudioBridge] trackstream ffmpeg fallback failed: " + ffErr.message);
return null; return null;
} }
} }
} }
}
// WebM/Opus direct URL — play with zero re-encode. // WebM/Opus direct URL — play with zero re-encode.
this._usedTrackstream = true; this._usedTrackstream = true;
+1 -1
View File
@@ -78,7 +78,7 @@ const DisplayMixin = {
? `${vid.title} - ${vid.url}` ? `${vid.title} - ${vid.url}`
: `[${vid.title}](${vid.url})`; : `[${vid.title}](${vid.url})`;
} }
if (vid.isLive || vid.type === "livestream") { if (vid.isLive || vid.isStream || vid.type === "livestream") {
const link = vid.url || ""; const link = vid.url || "";
return code return code
? `${vid.title} (LIVE) - ${link}` ? `${vid.title} (LIVE) - ${link}`
+4
View File
@@ -54,6 +54,10 @@ const PlaybackMixin = {
* @returns {number} * @returns {number}
*/ */
_getTrackDurationMs(track) { _getTrackDurationMs(track) {
/* Live streams have unbounded/indeterminate length: duration is always 0 */
if (track?.isLive || track?.isStream || track?.info?.isStream || track?.info?.isLive || track?.type === "livestream" || track?.type === "radio") {
return 0;
}
if (track?._durationMs != null && track._durationMs > 0) { if (track?._durationMs != null && track._durationMs > 0) {
return track._durationMs; return track._durationMs;
} }
+2 -1
View File
@@ -319,7 +319,8 @@ const SearchMixin = {
videoId: info.identifier ?? "", videoId: info.identifier ?? "",
encoded: track.encoded ?? info.encoded ?? "", encoded: track.encoded ?? info.encoded ?? "",
sourceName: info.sourceName ?? "unknown", sourceName: info.sourceName ?? "unknown",
isLive: info.isLive === true, isLive: info.isLive === true || info.isStream === true,
isStream: info.isStream === true || info.isLive === true,
title: Utils.cleanTitle(info.title ?? "Unknown"), title: Utils.cleanTitle(info.title ?? "Unknown"),
url: trackUri, url: trackUri,
thumbnail: info.artworkUrl ?? null, thumbnail: info.artworkUrl ?? null,