fix(player): return from background audio onto the episode it advanced to
An episode that ends while backgrounded in audio-only mode advances in the
backend, but player_exit_background_audio returned only a position, so the
video page reloaded the episode it was mounted with -- the previous one, at
the new episode's timestamp.
The command now returns BackgroundAudioResume { itemId, positionSeconds }.
planHandoffReturn yields "other-item" when the id differs from the mounted
one, and the player page navigates to that episode with resumeAt=<seconds>,
marking the outgoing episode watched and suppressing its stale stop report.
TRACES: UR-040, UR-023 | DR-296 | UT-265, UT-266
This commit is contained in:
@@ -138,6 +138,51 @@ describe("backgroundAudioHandoff", () => {
|
||||
});
|
||||
expect(plan.position).toBe(0);
|
||||
});
|
||||
|
||||
// An episode that ends while backgrounded advances in the backend. Reloading
|
||||
// the video the player was mounted with brought back the PREVIOUS episode,
|
||||
// at the new episode's timestamp.
|
||||
//
|
||||
// TRACES: UR-040, UR-023 | DR-296 | UT-265
|
||||
it("switches to the item the backend advanced to", () => {
|
||||
const plan = planHandoffReturn({
|
||||
useHtml5Element: false,
|
||||
position: 95,
|
||||
wasPlaying: true,
|
||||
nativeStateKind: "playing",
|
||||
mountedItemId: "ep1",
|
||||
resumeItemId: "ep2",
|
||||
});
|
||||
expect(plan.target).toBe("other-item");
|
||||
expect(plan.itemId).toBe("ep2");
|
||||
expect(plan.position).toBe(95);
|
||||
});
|
||||
|
||||
it("reloads in place when the backend is still on the mounted item", () => {
|
||||
const plan = planHandoffReturn({
|
||||
useHtml5Element: true,
|
||||
position: 95,
|
||||
wasPlaying: true,
|
||||
nativeStateKind: "playing",
|
||||
mountedItemId: "ep1",
|
||||
resumeItemId: "ep1",
|
||||
});
|
||||
expect(plan.target).toBe("html5-element");
|
||||
});
|
||||
|
||||
it("reloads in place when the backend reports no item", () => {
|
||||
// Queue emptied while backgrounded (e.g. the sleep timer): there is no
|
||||
// other item to go to, so the mounted one is the best we have.
|
||||
const plan = planHandoffReturn({
|
||||
useHtml5Element: false,
|
||||
position: 95,
|
||||
wasPlaying: false,
|
||||
nativeStateKind: undefined,
|
||||
mountedItemId: "ep1",
|
||||
resumeItemId: null,
|
||||
});
|
||||
expect(plan.target).toBe("native-backend");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user