mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
fix(stories): retain the last shot when replaying near the end (#1724)
Focused follow-up to manjunath22466's Stories contribution. A paused share link in the final 250 ms is not a completed scene. Add node:test coverage for near-end Play and true-end replay; update current-state documentation and the #1724 changelog fragment.
This commit is contained in:
1 parent
b8e622aac8
commit
8a0953c35d
4 files changed
+37
-3
No files matched your search
@@ -87,7 +87,9 @@ export function createGevPlayer(director, story, hooks = {}) {
|
||||
const mine = ++request;
|
||||
await idle();
|
||||
if (destroyed || mine !== request || director.running) return;
|
||||
if (wallMs >= durationMs - 250) {
|
||||
// Natural completion is rounded up by the clock subscriber; a
|
||||
// paused shared time inside the last 250 ms is not completion.
|
||||
if (wallMs >= durationMs) {
|
||||
wallMs = 0;
|
||||
shotIndex = 0;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ function deferredDirector({ running = false } = {}) {
|
||||
},
|
||||
|
||||
seekScene: (id, f) => calls.push(`seek ${f}`),
|
||||
startScene: () => {
|
||||
startScene: (_id, options) => {
|
||||
director.startAfterShotId = options.afterShotId;
|
||||
calls.push('start');
|
||||
director.running = true;
|
||||
return new Promise((resolve) => {
|
||||
@@ -107,6 +108,30 @@ test('a paused seek keeps its exact position near the end of a story', () => {
|
||||
assert.equal(player.state.playing, false);
|
||||
});
|
||||
|
||||
test('Play from a paused link in the final quarter-second stays in the final shot', async () => {
|
||||
const director = deferredDirector();
|
||||
const player = createGevPlayer(director, story);
|
||||
player.seek(59800); // 200 ms before the end of a two-shot scene
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
assert.equal(player.state.wallMs, 59800, 'the link is not treated as complete');
|
||||
assert.equal(director.startAfterShotId, 'a', 'resume in the final shot');
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
|
||||
test('Play after the actual end still starts the scene from shot one', async () => {
|
||||
const director = deferredDirector();
|
||||
const player = createGevPlayer(director, story);
|
||||
player.seek(60000);
|
||||
const playing = player.play();
|
||||
await turns();
|
||||
assert.equal(player.state.wallMs, 0);
|
||||
assert.equal(director.startAfterShotId, null);
|
||||
director.finishRun();
|
||||
await playing;
|
||||
});
|
||||
|
||||
test('Destroy cancels a waiting Play', async () => {
|
||||
const director = deferredDirector({ running: true });
|
||||
const player = createGevPlayer(director, story);
|
||||
|
||||
Reference in new issue
Block a user