mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
fix(player): start frame loop only after ffmpeg spawns in jdymusic path
PR #54's playViaPowerShellDownload called startFrameLoop() right after spawning the PowerShell downloader, before ffmpeg existed. The loop's "no ffmpeg + empty buffer → emit trackEnd" branch fired on the very first tick (~25ms), skipping every jdymusic song. Visible as: each PowerShell download sessionId logged "Track ended, advancing queue" before the download completed, so the queue burned through every track in a few seconds. Move startFrameLoop() into spawnFfmpegFromFile() where ffmpeg is known to be alive and producing PCM. state = "playing" still flips in playViaPowerShellDownload so external observers see the right status during download. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9efa818bbb
commit
c562fe05b0
1 file changed
+8
-1
+8
-1
@@ -279,8 +279,12 @@ export class AudioPlayer extends EventEmitter {
|
||||
this.emit("error", err);
|
||||
});
|
||||
|
||||
// Mark playing but DO NOT start the frame loop here — the loop's
|
||||
// "no ffmpeg + empty buffer → trackEnd" branch would fire on the very
|
||||
// first tick, before the PowerShell download even completes. The
|
||||
// frame loop is started inside spawnFfmpegFromFile() once ffmpeg is
|
||||
// alive and producing PCM.
|
||||
this.state = "playing";
|
||||
this.startFrameLoop();
|
||||
}
|
||||
|
||||
private spawnFfmpegFromFile(tempFile: string, seekSeconds: number, sessionId: number): void {
|
||||
@@ -329,6 +333,9 @@ export class AudioPlayer extends EventEmitter {
|
||||
this.emit("error", err);
|
||||
}
|
||||
});
|
||||
|
||||
// Now that ffmpeg is producing PCM, run the frame loop.
|
||||
this.startFrameLoop();
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
|
||||
Reference in new issue
Block a user