@remotion/player 4.0.540 → 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.
- package/dist/cjs/calculate-next-frame.js +9 -0
- package/dist/cjs/index.d.ts +30 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/use-playback.js +23 -7
- package/dist/esm/index.mjs +1786 -1758
- package/package.json +4 -4
|
@@ -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/index.d.ts
CHANGED
|
@@ -34,6 +34,36 @@ export declare const PlayerInternals: {
|
|
|
34
34
|
readonly type: 'player' | 'studio';
|
|
35
35
|
readonly color?: string;
|
|
36
36
|
}>;
|
|
37
|
+
PlayerControls: import("react").FC<{
|
|
38
|
+
readonly fps: number;
|
|
39
|
+
readonly durationInFrames: number;
|
|
40
|
+
readonly showVolumeControls: boolean;
|
|
41
|
+
readonly onFullscreenButtonClick: import("react").MouseEventHandler<HTMLButtonElement>;
|
|
42
|
+
readonly isFullscreen: boolean;
|
|
43
|
+
readonly allowFullscreen: boolean;
|
|
44
|
+
readonly onExitFullscreenButtonClick: import("react").MouseEventHandler<HTMLButtonElement>;
|
|
45
|
+
readonly spaceKeyToPlayOrPause: boolean;
|
|
46
|
+
readonly onSeekEnd: () => void;
|
|
47
|
+
readonly onSeekStart: () => void;
|
|
48
|
+
readonly inFrame: number | null;
|
|
49
|
+
readonly outFrame: number | null;
|
|
50
|
+
readonly initiallyShowControls: number | boolean;
|
|
51
|
+
readonly canvasSize: import("./index.js").Size | null;
|
|
52
|
+
readonly renderPlayPauseButton: import("./PlayerControls.js").RenderPlayPauseButton | null;
|
|
53
|
+
readonly renderFullscreenButton: import("./PlayerControls.js").RenderFullscreenButton | null;
|
|
54
|
+
readonly alwaysShowControls: boolean;
|
|
55
|
+
readonly showPlaybackRateControl: boolean | number[];
|
|
56
|
+
readonly containerRef: React.RefObject<HTMLDivElement | null>;
|
|
57
|
+
readonly buffering: boolean;
|
|
58
|
+
readonly hideControlsWhenPointerDoesntMove: boolean | number;
|
|
59
|
+
readonly onPointerDown: ((ev: PointerEvent | import("react").SyntheticEvent) => void) | undefined;
|
|
60
|
+
readonly onDoubleClick: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
61
|
+
readonly renderMuteButton: import("./MediaVolumeSlider.js").RenderMuteButton | null;
|
|
62
|
+
readonly renderVolumeSlider: import("./render-volume-slider.js").RenderVolumeSlider | null;
|
|
63
|
+
readonly playing: boolean;
|
|
64
|
+
readonly toggle: (e?: import("react").SyntheticEvent | PointerEvent) => void;
|
|
65
|
+
readonly renderCustomControls: import("./player-methods.js").RenderCustomControls | null;
|
|
66
|
+
}>;
|
|
37
67
|
TimelineSequenceObserverContext: import("react").Context<import("./timeline-sequence-observer-context.js").TimelineSequenceObserver | null>;
|
|
38
68
|
CanvasOverlayContext: import("react").Context<import("react").ReactNode>;
|
|
39
69
|
CanvasContentContext: import("react").Context<{
|
package/dist/cjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const canvas_overlay_context_js_1 = require("./canvas-overlay-context.js");
|
|
|
8
8
|
const emitter_context_js_1 = require("./emitter-context.js");
|
|
9
9
|
const EmitterProvider_js_1 = require("./EmitterProvider.js");
|
|
10
10
|
const event_emitter_js_1 = require("./event-emitter.js");
|
|
11
|
+
const PlayerControls_js_1 = require("./PlayerControls.js");
|
|
11
12
|
const timeline_sequence_observer_context_js_1 = require("./timeline-sequence-observer-context.js");
|
|
12
13
|
const use_hover_state_js_1 = require("./use-hover-state.js");
|
|
13
14
|
const use_playback_js_1 = require("./use-playback.js");
|
|
@@ -28,6 +29,7 @@ exports.PlayerInternals = {
|
|
|
28
29
|
updateAllElementsSizes: use_element_size_js_1.updateAllElementsSizes,
|
|
29
30
|
PlayerEmitterProvider: EmitterProvider_js_1.PlayerEmitterProvider,
|
|
30
31
|
BufferingIndicator: BufferingIndicator_js_1.BufferingIndicator,
|
|
32
|
+
PlayerControls: PlayerControls_js_1.Controls,
|
|
31
33
|
TimelineSequenceObserverContext: timeline_sequence_observer_context_js_1.TimelineSequenceObserverContext,
|
|
32
34
|
CanvasOverlayContext: canvas_overlay_context_js_1.CanvasOverlayContext,
|
|
33
35
|
CanvasContentContext: canvas_overlay_context_js_1.CanvasContentContext,
|
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
|
}, [
|