Resume interrupted tracks where they stopped
A track cut off without anyone asking (voice connection lost, bot leaving an empty channel, restart) used to start over from the beginning; on an hour-long mix, a drop near the end replayed it all. - The requeued track keeps resumeAt and ffmpeg seeks to it (-ss before -i, so it jumps there without decoding the start). It resumes 2 s before the cut; a track cut in its first 2 s starts over. - The player keeps playing without a connection (NoSubscriberBehavior.Play), so the position of a voice drop is taken when the connection drops, not 5 s later when it is given up. - The saved queue holds the current position, and it is saved every 30 s while playing: after a crash the track resumes at most 30 s earlier. - Loop mode replays a resumed track from the beginning; skip and stop are unchanged. - The web page and /queue show "Reprise à 49:15" for such a track, and the progress bar counts from the resume point. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
11ee972636
commit
793765fb79
8 changed files with 141 additions and 24 deletions
|
|
@ -60,6 +60,19 @@ test("createOpusStream yields Opus packets that Discord can play as is", { skip
|
|||
assert.ok(packets >= 45, `${packets} paquets`);
|
||||
});
|
||||
|
||||
test("createOpusStream can start in the middle of a track", { skip }, async () => {
|
||||
const resource = createAudioResource(createOpusStream(makeTone("three.mp3", 3), { startAt: 2 }), {
|
||||
inputType: StreamType.OggOpus,
|
||||
});
|
||||
|
||||
let packets = 0;
|
||||
for await (const _packet of resource.playStream) {
|
||||
packets += 1;
|
||||
}
|
||||
// Seule la dernière seconde est jouée : une cinquantaine de paquets de 20 ms, pas 150.
|
||||
assert.ok(packets >= 40 && packets <= 70, `${packets} paquets`);
|
||||
});
|
||||
|
||||
test("closing the Opus stream stops ffmpeg", { skip }, async () => {
|
||||
let child;
|
||||
const output = createOpusStream(makeTone("long.mp3", 120), {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue