@remotion/player 4.0.541 → 4.0.542
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,15 @@ const calculateNextFrame = ({ time, currentFrame: startFrame, playbackSpeed, fps
|
|
|
8
8
|
const isCurrentFrameOutside = startFrame > actualLastFrame || startFrame < actualFirstFrame;
|
|
9
9
|
const isNextFrameOutside = nextFrame > actualLastFrame || nextFrame < actualFirstFrame;
|
|
10
10
|
const hasEnded = !shouldLoop && isNextFrameOutside && !isCurrentFrameOutside;
|
|
11
|
+
if (shouldLoop && isNextFrameOutside && !isCurrentFrameOutside) {
|
|
12
|
+
const playbackRange = actualLastFrame - actualFirstFrame + 1;
|
|
13
|
+
const frameWithinRange = (nextFrame - actualFirstFrame) % playbackRange;
|
|
14
|
+
return {
|
|
15
|
+
nextFrame: actualFirstFrame + ((frameWithinRange + playbackRange) % playbackRange),
|
|
16
|
+
framesToAdvance,
|
|
17
|
+
hasEnded,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
11
20
|
if (playbackSpeed > 0) {
|
|
12
21
|
// Play forwards
|
|
13
22
|
if (isNextFrameOutside) {
|
package/dist/cjs/use-playback.js
CHANGED
|
@@ -174,6 +174,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
174
174
|
let reqAnimFrameCall = null;
|
|
175
175
|
let playbackFrame = getCurrentFrame();
|
|
176
176
|
let lastSeekRevision = (_c = seek === null || seek === void 0 ? void 0 : seek.revision.current) !== null && _c !== void 0 ? _c : null;
|
|
177
|
+
let unsubscribeBuffering = null;
|
|
177
178
|
const cancelQueuedFrame = () => {
|
|
178
179
|
if (reqAnimFrameCall !== null) {
|
|
179
180
|
if (reqAnimFrameCall.type === 'raf') {
|
|
@@ -182,15 +183,19 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
182
183
|
else {
|
|
183
184
|
clearTimeout(reqAnimFrameCall.id);
|
|
184
185
|
}
|
|
186
|
+
reqAnimFrameCall = null;
|
|
185
187
|
}
|
|
186
188
|
};
|
|
187
189
|
const stop = () => {
|
|
188
190
|
hasBeenStopped = true;
|
|
189
191
|
cancelQueuedFrame();
|
|
192
|
+
unsubscribeBuffering === null || unsubscribeBuffering === void 0 ? void 0 : unsubscribeBuffering();
|
|
193
|
+
unsubscribeBuffering = null;
|
|
190
194
|
};
|
|
191
195
|
const callback = () => {
|
|
192
196
|
var _a, _b;
|
|
193
197
|
var _c;
|
|
198
|
+
reqAnimFrameCall = null;
|
|
194
199
|
if (hasBeenStopped) {
|
|
195
200
|
return;
|
|
196
201
|
}
|
|
@@ -198,7 +203,11 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
198
203
|
(_a = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _a === void 0 ? void 0 : _a.call(sharedAudioContext);
|
|
199
204
|
return;
|
|
200
205
|
}
|
|
201
|
-
if (
|
|
206
|
+
if (isBuffering()) {
|
|
207
|
+
queueNextFrame();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (!muted && !audioContextFailed) {
|
|
202
211
|
(_b = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.resume) === null || _b === void 0 ? void 0 : _b.call(sharedAudioContext);
|
|
203
212
|
}
|
|
204
213
|
const time = performance.now() - clock.startedTime;
|
|
@@ -228,7 +237,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
228
237
|
? actualLastFrame
|
|
229
238
|
: actualFirstFrame
|
|
230
239
|
: nextFrame;
|
|
231
|
-
if (frameToDisplay !== currentFrame
|
|
240
|
+
if (frameToDisplay !== currentFrame) {
|
|
232
241
|
playbackFrame = frameToDisplay;
|
|
233
242
|
setFrameFromPlayback((c) => ({ ...c, [compositionId]: frameToDisplay }));
|
|
234
243
|
}
|
|
@@ -270,11 +279,15 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
270
279
|
if (!muted && !audioContextFailed) {
|
|
271
280
|
(_b = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _b === void 0 ? void 0 : _b.call(sharedAudioContext);
|
|
272
281
|
}
|
|
273
|
-
|
|
282
|
+
unsubscribeBuffering = subscribeBuffering((state) => {
|
|
274
283
|
if (state.buffering) {
|
|
275
284
|
return;
|
|
276
285
|
}
|
|
277
|
-
|
|
286
|
+
unsubscribeBuffering === null || unsubscribeBuffering === void 0 ? void 0 : unsubscribeBuffering();
|
|
287
|
+
unsubscribeBuffering = null;
|
|
288
|
+
if (hasBeenStopped) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
278
291
|
if (!muted &&
|
|
279
292
|
!audioContextFailed &&
|
|
280
293
|
(sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext._experimentalKeepAudioContextAlive)) {
|
|
@@ -297,19 +310,22 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
297
310
|
}
|
|
298
311
|
reqAnimFrameCall = { type: 'raf', id: requestAnimationFrame(callback) };
|
|
299
312
|
};
|
|
313
|
+
const unsubscribeSeek = seek === null || seek === void 0 ? void 0 : seek.subscribe(() => {
|
|
314
|
+
clock.startedTime = performance.now();
|
|
315
|
+
clock.framesAdvanced = 0;
|
|
316
|
+
});
|
|
300
317
|
queueNextFrame();
|
|
301
318
|
const onVisibilityChange = () => {
|
|
302
|
-
if (
|
|
319
|
+
if (reqAnimFrameCall === null) {
|
|
303
320
|
return;
|
|
304
321
|
}
|
|
305
|
-
// If tab goes into the background, cancel requestAnimationFrame() and update immediately.
|
|
306
|
-
// , so the transition to setTimeout() can be fulfilled.
|
|
307
322
|
cancelQueuedFrame();
|
|
308
323
|
callback();
|
|
309
324
|
};
|
|
310
325
|
window.addEventListener('visibilitychange', onVisibilityChange);
|
|
311
326
|
return () => {
|
|
312
327
|
window.removeEventListener('visibilitychange', onVisibilityChange);
|
|
328
|
+
unsubscribeSeek === null || unsubscribeSeek === void 0 ? void 0 : unsubscribeSeek();
|
|
313
329
|
stop();
|
|
314
330
|
};
|
|
315
331
|
}, [
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1991,6 +1991,15 @@ var calculateNextFrame = ({
|
|
|
1991
1991
|
const isCurrentFrameOutside = startFrame > actualLastFrame || startFrame < actualFirstFrame;
|
|
1992
1992
|
const isNextFrameOutside = nextFrame > actualLastFrame || nextFrame < actualFirstFrame;
|
|
1993
1993
|
const hasEnded = !shouldLoop && isNextFrameOutside && !isCurrentFrameOutside;
|
|
1994
|
+
if (shouldLoop && isNextFrameOutside && !isCurrentFrameOutside) {
|
|
1995
|
+
const playbackRange = actualLastFrame - actualFirstFrame + 1;
|
|
1996
|
+
const frameWithinRange = (nextFrame - actualFirstFrame) % playbackRange;
|
|
1997
|
+
return {
|
|
1998
|
+
nextFrame: actualFirstFrame + (frameWithinRange + playbackRange) % playbackRange,
|
|
1999
|
+
framesToAdvance,
|
|
2000
|
+
hasEnded
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
1994
2003
|
if (playbackSpeed > 0) {
|
|
1995
2004
|
if (isNextFrameOutside) {
|
|
1996
2005
|
return {
|
|
@@ -2199,6 +2208,7 @@ var usePlayback = ({
|
|
|
2199
2208
|
let reqAnimFrameCall = null;
|
|
2200
2209
|
let playbackFrame = getCurrentFrame();
|
|
2201
2210
|
let lastSeekRevision = seek?.revision.current ?? null;
|
|
2211
|
+
let unsubscribeBuffering = null;
|
|
2202
2212
|
const cancelQueuedFrame = () => {
|
|
2203
2213
|
if (reqAnimFrameCall !== null) {
|
|
2204
2214
|
if (reqAnimFrameCall.type === "raf") {
|
|
@@ -2206,13 +2216,17 @@ var usePlayback = ({
|
|
|
2206
2216
|
} else {
|
|
2207
2217
|
clearTimeout(reqAnimFrameCall.id);
|
|
2208
2218
|
}
|
|
2219
|
+
reqAnimFrameCall = null;
|
|
2209
2220
|
}
|
|
2210
2221
|
};
|
|
2211
2222
|
const stop = () => {
|
|
2212
2223
|
hasBeenStopped = true;
|
|
2213
2224
|
cancelQueuedFrame();
|
|
2225
|
+
unsubscribeBuffering?.();
|
|
2226
|
+
unsubscribeBuffering = null;
|
|
2214
2227
|
};
|
|
2215
2228
|
const callback = () => {
|
|
2229
|
+
reqAnimFrameCall = null;
|
|
2216
2230
|
if (hasBeenStopped) {
|
|
2217
2231
|
return;
|
|
2218
2232
|
}
|
|
@@ -2220,7 +2234,11 @@ var usePlayback = ({
|
|
|
2220
2234
|
sharedAudioContext?.suspend?.();
|
|
2221
2235
|
return;
|
|
2222
2236
|
}
|
|
2223
|
-
if (
|
|
2237
|
+
if (isBuffering()) {
|
|
2238
|
+
queueNextFrame();
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
if (!muted && !audioContextFailed) {
|
|
2224
2242
|
sharedAudioContext?.resume?.();
|
|
2225
2243
|
}
|
|
2226
2244
|
const time = performance.now() - clock.startedTime;
|
|
@@ -2244,7 +2262,7 @@ var usePlayback = ({
|
|
|
2244
2262
|
});
|
|
2245
2263
|
clock.framesAdvanced += framesToAdvance;
|
|
2246
2264
|
const frameToDisplay = hasEnded && !moveToBeginningWhenEnded ? playbackRate > 0 ? actualLastFrame : actualFirstFrame : nextFrame;
|
|
2247
|
-
if (frameToDisplay !== currentFrame
|
|
2265
|
+
if (frameToDisplay !== currentFrame) {
|
|
2248
2266
|
playbackFrame = frameToDisplay;
|
|
2249
2267
|
setFrameFromPlayback((c) => ({ ...c, [compositionId]: frameToDisplay }));
|
|
2250
2268
|
}
|
|
@@ -2281,11 +2299,15 @@ var usePlayback = ({
|
|
|
2281
2299
|
if (!muted && !audioContextFailed) {
|
|
2282
2300
|
sharedAudioContext?.suspend?.();
|
|
2283
2301
|
}
|
|
2284
|
-
|
|
2302
|
+
unsubscribeBuffering = subscribeBuffering((state) => {
|
|
2285
2303
|
if (state.buffering) {
|
|
2286
2304
|
return;
|
|
2287
2305
|
}
|
|
2288
|
-
|
|
2306
|
+
unsubscribeBuffering?.();
|
|
2307
|
+
unsubscribeBuffering = null;
|
|
2308
|
+
if (hasBeenStopped) {
|
|
2309
|
+
return;
|
|
2310
|
+
}
|
|
2289
2311
|
if (!muted && !audioContextFailed && sharedAudioContext?._experimentalKeepAudioContextAlive) {
|
|
2290
2312
|
sharedAudioContext.resume();
|
|
2291
2313
|
}
|
|
@@ -2304,9 +2326,13 @@ var usePlayback = ({
|
|
|
2304
2326
|
}
|
|
2305
2327
|
reqAnimFrameCall = { type: "raf", id: requestAnimationFrame(callback) };
|
|
2306
2328
|
};
|
|
2329
|
+
const unsubscribeSeek = seek?.subscribe(() => {
|
|
2330
|
+
clock.startedTime = performance.now();
|
|
2331
|
+
clock.framesAdvanced = 0;
|
|
2332
|
+
});
|
|
2307
2333
|
queueNextFrame();
|
|
2308
2334
|
const onVisibilityChange = () => {
|
|
2309
|
-
if (
|
|
2335
|
+
if (reqAnimFrameCall === null) {
|
|
2310
2336
|
return;
|
|
2311
2337
|
}
|
|
2312
2338
|
cancelQueuedFrame();
|
|
@@ -2315,6 +2341,7 @@ var usePlayback = ({
|
|
|
2315
2341
|
window.addEventListener("visibilitychange", onVisibilityChange);
|
|
2316
2342
|
return () => {
|
|
2317
2343
|
window.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2344
|
+
unsubscribeSeek?.();
|
|
2318
2345
|
stop();
|
|
2319
2346
|
};
|
|
2320
2347
|
}, [
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/player"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/player",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.542",
|
|
7
7
|
"description": "React component for embedding a Remotion preview into your app",
|
|
8
8
|
"main": "dist/cjs/index.js",
|
|
9
9
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"formatting": "oxfmt src --check",
|
|
13
13
|
"format": "oxfmt src",
|
|
14
14
|
"lint": "eslint src",
|
|
15
|
-
"make": "
|
|
15
|
+
"make": "node ../.monorepo/tsrs.cjs -d && bun ensure-correct-version.ts && bun --env-file=../.env.bundle bundle.ts",
|
|
16
16
|
"test": "bun test src",
|
|
17
17
|
"prerelease": "cp ../../README.md . && cp ../../LICENSE.md ."
|
|
18
18
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"remotion": "4.0.
|
|
38
|
+
"remotion": "4.0.542"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.8.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-dom": "19.3.1",
|
|
50
50
|
"webpack": "5.105.0",
|
|
51
51
|
"zod": "4.6.7",
|
|
52
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
52
|
+
"@remotion/eslint-config-internal": "4.0.542",
|
|
53
53
|
"eslint": "9.19.0",
|
|
54
54
|
"typescript": "7.1.0-beta"
|
|
55
55
|
},
|