Fix pause/resume desync by stopping and restarting stream at offset instead of SIGSTOP/SIGCONT
This commit is contained in:
parent
0edacd59da
commit
fcb03ad8c2
1 changed files with 11 additions and 11 deletions
|
|
@ -563,22 +563,22 @@ const server = http.createServer(async (request, response) => {
|
|||
const action = String(body.action || "").trim();
|
||||
|
||||
if (action === "pause") {
|
||||
if (!canPauseCommand(session.ffmpegCommand)) {
|
||||
throw new Error("Pause is not available because FFmpeg is not active");
|
||||
if (session.playbackState !== "playing") {
|
||||
throw new Error("Pause is not available because session is not playing");
|
||||
}
|
||||
session.positionSeconds = sessionPlaybackPosition(session);
|
||||
session.startedAtSeconds = 0;
|
||||
session.ffmpegCommand.ffmpegProc.kill("SIGSTOP");
|
||||
const pausedPos = sessionPlaybackPosition(session);
|
||||
await stopSessionPlayback(session, false);
|
||||
session.positionSeconds = pausedPos;
|
||||
session.playbackState = "paused";
|
||||
session.workerStatus = "connected";
|
||||
} else if (action === "resume") {
|
||||
if (!canPauseCommand(session.ffmpegCommand)) {
|
||||
throw new Error("Resume is not available because FFmpeg is not active");
|
||||
if (session.playbackState !== "paused") {
|
||||
throw new Error("Resume is not available because session is not paused");
|
||||
}
|
||||
session.startedAtSeconds = nowSeconds();
|
||||
session.ffmpegCommand.ffmpegProc.kill("SIGCONT");
|
||||
session.playbackState = "playing";
|
||||
session.workerStatus = "streaming";
|
||||
if (!session.playback) {
|
||||
throw new Error("Cannot resume because no playback metadata exists");
|
||||
}
|
||||
await startPlayback(session, session.playback, session.positionSeconds);
|
||||
} else if (action === "stop" || action === "skip") {
|
||||
await stopSessionPlayback(session, true);
|
||||
} else if (action === "seek") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue