@remotion/player 4.0.547 → 4.0.548
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/Player.js +3 -2
- package/dist/cjs/PlayerUI.d.ts +2 -0
- package/dist/cjs/PlayerUI.js +2 -2
- package/dist/cjs/Thumbnail.js +3 -2
- package/dist/cjs/ThumbnailUI.d.ts +2 -0
- package/dist/cjs/ThumbnailUI.js +2 -2
- package/dist/cjs/error-boundary.d.ts +3 -1
- package/dist/cjs/error-boundary.js +99 -5
- package/dist/cjs/use-playback.js +80 -16
- package/dist/esm/index.mjs +224 -86
- package/package.json +3 -3
package/dist/cjs/Player.js
CHANGED
|
@@ -93,11 +93,12 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
93
93
|
throw new TypeError(`'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
|
|
94
94
|
}
|
|
95
95
|
(0, react_1.useState)(() => (0, use_remotion_license_acknowledge_js_1.acknowledgeRemotionLicenseMessage)(Boolean(acknowledgeRemotionLicense), logLevel));
|
|
96
|
-
const component = remotion_1.Internals.
|
|
96
|
+
const { component: resolvedComponent, renderingOwner, isReplacingComponent, } = remotion_1.Internals.useLazyComponentWithOwner({
|
|
97
97
|
compProps: componentProps,
|
|
98
98
|
componentName: 'Player',
|
|
99
99
|
noSuspense: Boolean(noSuspense),
|
|
100
100
|
});
|
|
101
|
+
const component = resolvedComponent;
|
|
101
102
|
(0, validate_initial_frame_js_1.validateInitialFrame)({ initialFrame, durationInFrames });
|
|
102
103
|
const [frame, setFrame] = (0, react_1.useState)(() => ({
|
|
103
104
|
[SharedPlayerContext_js_1.PLAYER_COMP_ID]: initialFrame !== null && initialFrame !== void 0 ? initialFrame : 0,
|
|
@@ -260,7 +261,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
260
261
|
mode: 'prevent-media-session',
|
|
261
262
|
});
|
|
262
263
|
}, [passedBrowserMediaControlsBehavior]);
|
|
263
|
-
const player = ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, playbackRateContext: playbackRateContextValue, preservePitch: preservePitch, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, preferredEffectBackend: preferredEffectBackend, sampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, volumePersistenceKey: volumePersistenceKey, initialVolume: initialVolume, inputProps: actualInputProps, audioEnabled: true, children: (0, jsx_runtime_1.jsx)(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: (0, jsx_runtime_1.jsx)(PlayerUI_js_1.default, { ref: rootRef, posterFillMode: posterFillMode, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: actualInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
|
|
264
|
+
const player = ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, playbackRateContext: playbackRateContextValue, preservePitch: preservePitch, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, preferredEffectBackend: preferredEffectBackend, sampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, volumePersistenceKey: volumePersistenceKey, initialVolume: initialVolume, inputProps: actualInputProps, audioEnabled: true, children: (0, jsx_runtime_1.jsx)(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: (0, jsx_runtime_1.jsx)(PlayerUI_js_1.default, { ref: rootRef, posterFillMode: posterFillMode, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, renderingOwner: renderingOwner, isReplacingComponent: isReplacingComponent, style: style, inputProps: actualInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
|
|
264
265
|
? clickToPlay
|
|
265
266
|
: Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: currentPlaybackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), showPosterWhenBuffering: Boolean(showPosterWhenBuffering), showPosterWhenBufferingAndPaused: Boolean(showPosterWhenBufferingAndPaused), renderPoster: renderPoster, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null, renderMuteButton: renderMuteButton !== null && renderMuteButton !== void 0 ? renderMuteButton : null, renderVolumeSlider: renderVolumeSlider !== null && renderVolumeSlider !== void 0 ? renderVolumeSlider : null, renderCustomControls: renderCustomControls !== null && renderCustomControls !== void 0 ? renderCustomControls : null, alwaysShowControls: alwaysShowControls, showPlaybackRateControl: showPlaybackRateControl, bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds !== null && bufferStateDelayInMilliseconds !== void 0 ? bufferStateDelayInMilliseconds : 300, hideControlsWhenPointerDoesntMove: hideControlsWhenPointerDoesntMove, overflowVisible: overflowVisible, browserMediaControlsBehavior: browserMediaControlsBehavior, overrideInternalClassName: overrideInternalClassName !== null && overrideInternalClassName !== void 0 ? overrideInternalClassName : undefined, noSuspense: Boolean(noSuspense) }) }) }) }) }));
|
|
266
267
|
return ((0, jsx_runtime_1.jsx)(playback_range_context_js_1.PlaybackRangeContext.Provider, { value: playbackRange, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.DefaultPremountContext.Provider, { value: defaultPremountInSeconds, children: onTimelineSequenceChange ? ((0, jsx_runtime_1.jsx)(remotion_1.Internals.SequenceRegistrationContext.Provider, { value: true, children: (0, jsx_runtime_1.jsxs)(remotion_1.Internals.SequenceManagerProvider, { children: [(0, jsx_runtime_1.jsx)(TimelineSequenceObserverComponent, { onTimelineSequenceChange: onTimelineSequenceChange }), player] }) })) : (player) }) }));
|
package/dist/cjs/PlayerUI.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ declare const _default: React.ForwardRefExoticComponent<{
|
|
|
26
26
|
readonly doubleClickToFullscreen: boolean;
|
|
27
27
|
readonly spaceKeyToPlayOrPause: boolean;
|
|
28
28
|
readonly errorFallback: ErrorFallback;
|
|
29
|
+
readonly renderingOwner: object | null;
|
|
30
|
+
readonly isReplacingComponent: boolean;
|
|
29
31
|
readonly playbackRate: number;
|
|
30
32
|
readonly renderLoading: RenderLoading | undefined;
|
|
31
33
|
readonly renderPoster: RenderPoster | undefined;
|
package/dist/cjs/PlayerUI.js
CHANGED
|
@@ -54,7 +54,7 @@ if (reactVersion === '0') {
|
|
|
54
54
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
55
55
|
}
|
|
56
56
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
57
|
-
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, doubleClickToFullscreen, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initiallyShowControls, renderFullscreen: renderFullscreenButton, renderPlayPauseButton, renderMuteButton, renderVolumeSlider, renderCustomControls, alwaysShowControls, showPlaybackRateControl, posterFillMode, bufferStateDelayInMilliseconds, hideControlsWhenPointerDoesntMove, overflowVisible, browserMediaControlsBehavior, overrideInternalClassName, noSuspense, }, ref) => {
|
|
57
|
+
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, doubleClickToFullscreen, spaceKeyToPlayOrPause, errorFallback, renderingOwner, isReplacingComponent, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initiallyShowControls, renderFullscreen: renderFullscreenButton, renderPlayPauseButton, renderMuteButton, renderVolumeSlider, renderCustomControls, alwaysShowControls, showPlaybackRateControl, posterFillMode, bufferStateDelayInMilliseconds, hideControlsWhenPointerDoesntMove, overflowVisible, browserMediaControlsBehavior, overrideInternalClassName, noSuspense, }, ref) => {
|
|
58
58
|
var _a, _b, _c;
|
|
59
59
|
const { inFrame, outFrame } = (0, react_1.useContext)(playback_range_context_js_1.PlaybackRangeContext);
|
|
60
60
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
@@ -459,7 +459,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
459
459
|
showPosterWhenBufferingAndPaused && showBufferIndicator && !playing,
|
|
460
460
|
].some(Boolean);
|
|
461
461
|
const { left, top, width, height, ...outerWithoutScale } = outer;
|
|
462
|
-
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { style: outer, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: [(0, jsx_runtime_1.jsxs)("div", { ref: canvasContentRef, style: containerStyle, className: (0, player_css_classname_js_1.playerCssClassname)(overrideInternalClassName), children: [VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CurrentScaleContext.Provider, { value: currentScale, children: (0, jsx_runtime_1.jsx)(canvas_overlay_context_js_1.CanvasOverlayContext.Provider, { value: null, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.props) !== null && _c !== void 0 ? _c : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) }) }) })) : null, shouldShowPoster && posterFillMode === 'composition-size' ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
462
|
+
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { style: outer, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: [(0, jsx_runtime_1.jsxs)("div", { ref: canvasContentRef, style: containerStyle, className: (0, player_css_classname_js_1.playerCssClassname)(overrideInternalClassName), children: [VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, renderingOwner: renderingOwner, isReplacingComponent: isReplacingComponent, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CurrentScaleContext.Provider, { value: currentScale, children: (0, jsx_runtime_1.jsx)(canvas_overlay_context_js_1.CanvasOverlayContext.Provider, { value: null, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.props) !== null && _c !== void 0 ? _c : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) }) }) })) : null, shouldShowPoster && posterFillMode === 'composition-size' ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
463
463
|
...outerWithoutScale,
|
|
464
464
|
width: config.width,
|
|
465
465
|
height: config.height,
|
package/dist/cjs/Thumbnail.js
CHANGED
|
@@ -61,16 +61,17 @@ const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, com
|
|
|
61
61
|
};
|
|
62
62
|
}, [bufferingStore]);
|
|
63
63
|
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
64
|
-
const
|
|
64
|
+
const { component: resolvedComponent, renderingOwner, isReplacingComponent, } = remotion_1.Internals.useLazyComponentWithOwner({
|
|
65
65
|
compProps: componentProps,
|
|
66
66
|
componentName: 'Thumbnail',
|
|
67
67
|
noSuspense: Boolean(noSuspense),
|
|
68
68
|
});
|
|
69
|
+
const Component = resolvedComponent;
|
|
69
70
|
const [emitter] = (0, react_1.useState)(() => new event_emitter_js_1.ThumbnailEmitter());
|
|
70
71
|
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
71
72
|
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
72
73
|
}, [inputProps]);
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContext, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineState, playbackRateContext: playbackRateContext, preservePitch: false, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: 0, initiallyMuted: true, logLevel: logLevel, audioLatencyHint: "playback", preferredEffectBackend: preferredEffectBackend, sampleRate: 48000, inputProps: passedInputProps, audioEnabled: false, _experimentalKeepAudioContextAlive: false, children: (0, jsx_runtime_1.jsx)(emitter_context_js_1.ThumbnailEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(ThumbnailUI_js_1.default, { ref: rootRef, className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style, overflowVisible: overflowVisible, overrideInternalClassName: overrideInternalClassName, noSuspense: Boolean(noSuspense) }) }) }) }) }));
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContext, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineState, playbackRateContext: playbackRateContext, preservePitch: false, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: 0, initiallyMuted: true, logLevel: logLevel, audioLatencyHint: "playback", preferredEffectBackend: preferredEffectBackend, sampleRate: 48000, inputProps: passedInputProps, audioEnabled: false, _experimentalKeepAudioContextAlive: false, children: (0, jsx_runtime_1.jsx)(emitter_context_js_1.ThumbnailEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(ThumbnailUI_js_1.default, { ref: rootRef, className: className, errorFallback: errorFallback, renderingOwner: renderingOwner, isReplacingComponent: isReplacingComponent, inputProps: passedInputProps, renderLoading: renderLoading, style: style, overflowVisible: overflowVisible, overrideInternalClassName: overrideInternalClassName, noSuspense: Boolean(noSuspense) }) }) }) }) }));
|
|
74
75
|
};
|
|
75
76
|
const forward = react_1.forwardRef;
|
|
76
77
|
/*
|
|
@@ -5,6 +5,8 @@ declare const _default: React.ForwardRefExoticComponent<{
|
|
|
5
5
|
readonly inputProps: Record<string, unknown>;
|
|
6
6
|
readonly style?: React.CSSProperties;
|
|
7
7
|
readonly errorFallback: ErrorFallback;
|
|
8
|
+
readonly renderingOwner: object | null;
|
|
9
|
+
readonly isReplacingComponent: boolean;
|
|
8
10
|
readonly renderLoading: RenderLoading | undefined;
|
|
9
11
|
readonly className: string | undefined;
|
|
10
12
|
readonly overflowVisible: boolean;
|
package/dist/cjs/ThumbnailUI.js
CHANGED
|
@@ -48,7 +48,7 @@ if (reactVersion === '0') {
|
|
|
48
48
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
49
49
|
}
|
|
50
50
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
51
|
-
const ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className, overflowVisible, noSuspense, overrideInternalClassName, }, ref) => {
|
|
51
|
+
const ThumbnailUI = ({ style, inputProps, errorFallback, renderingOwner, isReplacingComponent, renderLoading, className, overflowVisible, noSuspense, overrideInternalClassName, }, ref) => {
|
|
52
52
|
var _a, _b;
|
|
53
53
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
54
54
|
const video = remotion_1.Internals.useVideo();
|
|
@@ -121,7 +121,7 @@ const ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, classNam
|
|
|
121
121
|
if (!config) {
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
124
|
-
const content = ((0, jsx_runtime_1.jsx)("div", { style: outer, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: (0, player_css_classname_js_1.playerCssClassname)(overrideInternalClassName), children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CurrentScaleContext.Provider, { value: currentScaleContext, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.props) !== null && _b !== void 0 ? _b : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) }) })) : null }) }));
|
|
124
|
+
const content = ((0, jsx_runtime_1.jsx)("div", { style: outer, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: (0, player_css_classname_js_1.playerCssClassname)(overrideInternalClassName), children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, renderingOwner: renderingOwner, isReplacingComponent: isReplacingComponent, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CurrentScaleContext.Provider, { value: currentScaleContext, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.props) !== null && _b !== void 0 ? _b : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) }) })) : null }) }));
|
|
125
125
|
if (noSuspense || (is_node_js_1.IS_NODE && !doesReactVersionSupportSuspense)) {
|
|
126
126
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
127
127
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare class ErrorBoundary extends React.Component<{
|
|
3
3
|
onError: (error: Error) => void;
|
|
4
|
+
renderingOwner: object | null;
|
|
5
|
+
isReplacingComponent: boolean;
|
|
4
6
|
children: React.ReactNode;
|
|
5
7
|
errorFallback: (info: {
|
|
6
8
|
error: Error;
|
|
@@ -15,5 +17,5 @@ export declare class ErrorBoundary extends React.Component<{
|
|
|
15
17
|
hasError: Error;
|
|
16
18
|
};
|
|
17
19
|
componentDidCatch(error: Error): void;
|
|
18
|
-
render():
|
|
20
|
+
render(): React.JSX.Element;
|
|
19
21
|
}
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.ErrorBoundary = void 0;
|
|
7
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_1 =
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const remotion_1 = require("remotion");
|
|
9
40
|
const errorStyle = {
|
|
10
41
|
display: 'flex',
|
|
11
42
|
justifyContent: 'center',
|
|
@@ -14,6 +45,69 @@ const errorStyle = {
|
|
|
14
45
|
height: '100%',
|
|
15
46
|
width: '100%',
|
|
16
47
|
};
|
|
48
|
+
// Cancellation ownership is separate from the renderer's shared readiness scope.
|
|
49
|
+
const useOwnerLayoutEffect = typeof window === 'undefined' ? react_1.default.useEffect : react_1.default.useLayoutEffect;
|
|
50
|
+
const AsyncRenderErrorScope = ({ children, renderingOwner, isReplacingComponent, }) => {
|
|
51
|
+
const [failure, setFailure] = (0, react_1.useState)(null);
|
|
52
|
+
const currentOwner = react_1.default.useRef(null);
|
|
53
|
+
const scheduleFailure = (failureOwner, error, beforeFirstCommit) => {
|
|
54
|
+
const { generation } = failureOwner;
|
|
55
|
+
queueMicrotask(() => {
|
|
56
|
+
if (!failureOwner.active ||
|
|
57
|
+
currentOwner.current !== failureOwner ||
|
|
58
|
+
(!beforeFirstCommit && generation !== failureOwner.generation))
|
|
59
|
+
return;
|
|
60
|
+
const committedGeneration = failureOwner.generation;
|
|
61
|
+
setFailure((previous) => (previous === null || previous === void 0 ? void 0 : previous.owner) === failureOwner &&
|
|
62
|
+
previous.generation === committedGeneration
|
|
63
|
+
? previous
|
|
64
|
+
: { owner: failureOwner, generation: committedGeneration, error });
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const createOwner = () => {
|
|
68
|
+
const createdOwner = {
|
|
69
|
+
renderingOwner,
|
|
70
|
+
active: false,
|
|
71
|
+
firstError: null,
|
|
72
|
+
generation: 0,
|
|
73
|
+
onCancel: (error) => {
|
|
74
|
+
// Descendant render/layout work can report before this owner commits.
|
|
75
|
+
const beforeFirstCommit = !createdOwner.active && createdOwner.generation === 0;
|
|
76
|
+
if ((!createdOwner.active && !beforeFirstCommit) ||
|
|
77
|
+
createdOwner.firstError !== null)
|
|
78
|
+
return;
|
|
79
|
+
createdOwner.firstError = error;
|
|
80
|
+
if (!beforeFirstCommit)
|
|
81
|
+
scheduleFailure(createdOwner, error, false);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return createdOwner;
|
|
85
|
+
};
|
|
86
|
+
const [owner, setOwner] = (0, react_1.useState)(createOwner);
|
|
87
|
+
useOwnerLayoutEffect(() => {
|
|
88
|
+
owner.active = true;
|
|
89
|
+
currentOwner.current = owner;
|
|
90
|
+
if (owner.generation === 0 && owner.firstError !== null) {
|
|
91
|
+
scheduleFailure(owner, owner.firstError, true);
|
|
92
|
+
}
|
|
93
|
+
return () => {
|
|
94
|
+
owner.active = false;
|
|
95
|
+
owner.generation++;
|
|
96
|
+
owner.firstError = null;
|
|
97
|
+
if (currentOwner.current === owner)
|
|
98
|
+
currentOwner.current = null;
|
|
99
|
+
};
|
|
100
|
+
}, [owner]);
|
|
101
|
+
if (!Object.is(owner.renderingOwner, renderingOwner)) {
|
|
102
|
+
setOwner(createOwner());
|
|
103
|
+
}
|
|
104
|
+
if (!isReplacingComponent &&
|
|
105
|
+
Object.is(owner.renderingOwner, renderingOwner) &&
|
|
106
|
+
(failure === null || failure === void 0 ? void 0 : failure.owner) === owner &&
|
|
107
|
+
failure.generation === owner.generation)
|
|
108
|
+
throw failure.error;
|
|
109
|
+
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.CancelRenderContext.Provider, { value: owner.onCancel, children: children }));
|
|
110
|
+
};
|
|
17
111
|
class ErrorBoundary extends react_1.default.Component {
|
|
18
112
|
constructor() {
|
|
19
113
|
super(...arguments);
|
|
@@ -33,7 +127,7 @@ class ErrorBoundary extends react_1.default.Component {
|
|
|
33
127
|
error: this.state.hasError,
|
|
34
128
|
}) }));
|
|
35
129
|
}
|
|
36
|
-
return this.props.children;
|
|
130
|
+
return ((0, jsx_runtime_1.jsx)(AsyncRenderErrorScope, { renderingOwner: this.props.renderingOwner, isReplacingComponent: this.props.isReplacingComponent, children: this.props.children }));
|
|
37
131
|
}
|
|
38
132
|
}
|
|
39
133
|
exports.ErrorBoundary = ErrorBoundary;
|
package/dist/cjs/use-playback.js
CHANGED
|
@@ -53,7 +53,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
53
53
|
playbackRate,
|
|
54
54
|
videoConfig: config,
|
|
55
55
|
});
|
|
56
|
-
const updateAudioAnchor = (0, react_2.useCallback)(() => {
|
|
56
|
+
const updateAudioAnchor = (0, react_2.useCallback)((preserveFraction) => {
|
|
57
57
|
if (!(sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.audioContext) || fps === null || muted) {
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
@@ -67,8 +67,9 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
67
67
|
clock.playbackRate === playbackRate) {
|
|
68
68
|
const actualFirstFrame = inFrame !== null && inFrame !== void 0 ? inFrame : 0;
|
|
69
69
|
const actualLastFrame = outFrame !== null && outFrame !== void 0 ? outFrame : durationInFrames - 1;
|
|
70
|
+
const elapsed = performance.now() - clock.startedTime;
|
|
70
71
|
const { nextFrame, hasEnded } = (0, calculate_next_frame_js_1.calculateNextFrame)({
|
|
71
|
-
time:
|
|
72
|
+
time: elapsed,
|
|
72
73
|
currentFrame: clock.frame,
|
|
73
74
|
playbackSpeed: playbackRate,
|
|
74
75
|
fps,
|
|
@@ -83,6 +84,10 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
83
84
|
? actualLastFrame
|
|
84
85
|
: actualFirstFrame
|
|
85
86
|
: nextFrame;
|
|
87
|
+
if (preserveFraction && !hasEnded) {
|
|
88
|
+
const elapsedFrames = (elapsed * playbackRate) / (1000 / fps);
|
|
89
|
+
absoluteFrame += elapsedFrames - Math.trunc(elapsedFrames);
|
|
90
|
+
}
|
|
86
91
|
}
|
|
87
92
|
const changed = (0, set_global_time_anchor_js_1.setGlobalTimeAnchor)({
|
|
88
93
|
audioContext: sharedAudioContext.audioContext,
|
|
@@ -138,7 +143,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
138
143
|
clock.frame = getCurrentFrame();
|
|
139
144
|
clock.seekRevision = seekRevisionAtRender;
|
|
140
145
|
}
|
|
141
|
-
const changed = updateAudioAnchor();
|
|
146
|
+
const changed = updateAudioAnchor(false);
|
|
142
147
|
if (!changed &&
|
|
143
148
|
playing &&
|
|
144
149
|
!muted &&
|
|
@@ -158,6 +163,49 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
158
163
|
seekRevisionAtRender,
|
|
159
164
|
updateAudioAnchor,
|
|
160
165
|
]);
|
|
166
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
167
|
+
if (!sharedAudioContext || fps === null || durationInFrames === null) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const updateEnd = () => {
|
|
171
|
+
sharedAudioContext.setPlaybackEnd(!playing || muted
|
|
172
|
+
? 0
|
|
173
|
+
: !loop && playbackRate > 0
|
|
174
|
+
? sharedAudioContext.audioSyncAnchor.value +
|
|
175
|
+
((outFrame !== null && outFrame !== void 0 ? outFrame : durationInFrames - 1) + 1) / fps / playbackRate
|
|
176
|
+
: null, () => {
|
|
177
|
+
if (muted ||
|
|
178
|
+
loop ||
|
|
179
|
+
playbackRate <= 0 ||
|
|
180
|
+
!sharedAudioContext.audioContext) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (playing) {
|
|
184
|
+
return (sharedAudioContext.audioSyncAnchor.value +
|
|
185
|
+
((outFrame !== null && outFrame !== void 0 ? outFrame : durationInFrames - 1) + 1) / fps / playbackRate);
|
|
186
|
+
}
|
|
187
|
+
// play() resumes audio before the playing React commit. Compute
|
|
188
|
+
// the deadline from the live playhead before queued nodes start.
|
|
189
|
+
return (sharedAudioContext.audioContext.currentTime +
|
|
190
|
+
((outFrame !== null && outFrame !== void 0 ? outFrame : durationInFrames - 1) + 1 - getCurrentFrame()) /
|
|
191
|
+
fps /
|
|
192
|
+
playbackRate);
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
updateEnd();
|
|
196
|
+
const subscription = sharedAudioContext.audioSyncAnchorEmitter.subscribe(updateEnd);
|
|
197
|
+
return () => subscription.remove();
|
|
198
|
+
}, [
|
|
199
|
+
sharedAudioContext,
|
|
200
|
+
fps,
|
|
201
|
+
durationInFrames,
|
|
202
|
+
playing,
|
|
203
|
+
muted,
|
|
204
|
+
loop,
|
|
205
|
+
playbackRate,
|
|
206
|
+
outFrame,
|
|
207
|
+
getCurrentFrame,
|
|
208
|
+
]);
|
|
161
209
|
// Native pauses, resumes and interruptions are clock boundaries too.
|
|
162
210
|
(0, react_1.useLayoutEffect)(() => {
|
|
163
211
|
const audioContext = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.audioContext;
|
|
@@ -179,7 +227,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
179
227
|
return;
|
|
180
228
|
}
|
|
181
229
|
if (newState && shouldForceAnchorChange(newState)) {
|
|
182
|
-
updateAudioAnchor();
|
|
230
|
+
updateAudioAnchor(false);
|
|
183
231
|
}
|
|
184
232
|
};
|
|
185
233
|
audioContext === null || audioContext === void 0 ? void 0 : audioContext.addEventListener('statechange', callback);
|
|
@@ -223,9 +271,16 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
223
271
|
clock.frame = remotion_1.Internals.Timeline.clampFrameToCompositionRange(clock.frame, durationInFrames);
|
|
224
272
|
playbackClockRef.current = clock;
|
|
225
273
|
let hasBeenStopped = false;
|
|
274
|
+
let waitingSince = null;
|
|
226
275
|
let audioContextFailed = false;
|
|
227
276
|
let reqAnimFrameCall = null;
|
|
228
277
|
let unsubscribeBuffering = null;
|
|
278
|
+
const excludeWaitFromClock = () => {
|
|
279
|
+
if (waitingSince !== null) {
|
|
280
|
+
clock.startedTime += performance.now() - waitingSince;
|
|
281
|
+
waitingSince = null;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
229
284
|
const cancelQueuedFrame = () => {
|
|
230
285
|
if (reqAnimFrameCall !== null) {
|
|
231
286
|
if (reqAnimFrameCall.type === 'raf') {
|
|
@@ -271,7 +326,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
271
326
|
if (anchorSeekRevision.current !== seekRevision) {
|
|
272
327
|
// A same-frame seek may not cause a React commit. It still needs
|
|
273
328
|
// an exact anchor before advancing playback from that position.
|
|
274
|
-
updateAudioAnchor();
|
|
329
|
+
updateAudioAnchor(false);
|
|
275
330
|
anchorSeekRevision.current = seekRevision;
|
|
276
331
|
if (previousAudioBoundary.current !== null) {
|
|
277
332
|
previousAudioBoundary.current.seekRevision = seekRevision;
|
|
@@ -298,7 +353,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
298
353
|
: actualFirstFrame
|
|
299
354
|
: nextFrame;
|
|
300
355
|
const didJump = frameToDisplay !== currentFrame + framesToAdvance;
|
|
301
|
-
if (didJump) {
|
|
356
|
+
if (didJump && !hasEnded) {
|
|
302
357
|
// Re-anchor after the jump's target frame commits.
|
|
303
358
|
playbackJumpRevision.current++;
|
|
304
359
|
}
|
|
@@ -306,9 +361,10 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
306
361
|
if (frameToDisplay !== currentFrame) {
|
|
307
362
|
setFrameFromPlayback((c) => ({ ...c, [compositionId]: frameToDisplay }));
|
|
308
363
|
}
|
|
309
|
-
else if (didJump) {
|
|
364
|
+
else if (didJump && !hasEnded) {
|
|
365
|
+
// A terminal anchor would re-arm the expired audio cutoff before pause.
|
|
310
366
|
// A jump can land on the same frame without a React commit.
|
|
311
|
-
updateAudioAnchor();
|
|
367
|
+
updateAudioAnchor(false);
|
|
312
368
|
if (previousAudioBoundary.current !== null) {
|
|
313
369
|
previousAudioBoundary.current.jumpRevision =
|
|
314
370
|
playbackJumpRevision.current;
|
|
@@ -332,6 +388,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
332
388
|
? null
|
|
333
389
|
: ((_c = (_a = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.getIsResumingAudioContext) === null || _a === void 0 ? void 0 : _a.call(sharedAudioContext)) !== null && _c !== void 0 ? _c : null);
|
|
334
390
|
if (getIsResumingAudioContext !== null && !muted) {
|
|
391
|
+
waitingSince = performance.now();
|
|
335
392
|
getIsResumingAudioContext.then((result) => {
|
|
336
393
|
if (hasBeenStopped) {
|
|
337
394
|
return;
|
|
@@ -341,9 +398,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
341
398
|
sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend();
|
|
342
399
|
setPlayerMuted(true);
|
|
343
400
|
}
|
|
344
|
-
|
|
345
|
-
clock.startedTime = performance.now();
|
|
346
|
-
clock.framesAdvanced = 0;
|
|
401
|
+
excludeWaitFromClock();
|
|
347
402
|
queueNextFrame();
|
|
348
403
|
});
|
|
349
404
|
return;
|
|
@@ -352,6 +407,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
352
407
|
if (!muted && !audioContextFailed) {
|
|
353
408
|
(_b = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _b === void 0 ? void 0 : _b.call(sharedAudioContext);
|
|
354
409
|
}
|
|
410
|
+
waitingSince = performance.now();
|
|
355
411
|
unsubscribeBuffering = subscribeBuffering((state) => {
|
|
356
412
|
if (state.buffering) {
|
|
357
413
|
return;
|
|
@@ -361,11 +417,8 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
361
417
|
if (hasBeenStopped) {
|
|
362
418
|
return;
|
|
363
419
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
clock.startedTime = performance.now();
|
|
367
|
-
clock.framesAdvanced = 0;
|
|
368
|
-
updateAudioAnchor();
|
|
420
|
+
excludeWaitFromClock();
|
|
421
|
+
updateAudioAnchor(true);
|
|
369
422
|
if (!muted &&
|
|
370
423
|
!audioContextFailed &&
|
|
371
424
|
(sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext._experimentalKeepAudioContextAlive)) {
|
|
@@ -388,6 +441,15 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
388
441
|
const unsubscribeSeek = seek === null || seek === void 0 ? void 0 : seek.subscribe(() => {
|
|
389
442
|
clock.startedTime = performance.now();
|
|
390
443
|
clock.framesAdvanced = 0;
|
|
444
|
+
if (waitingSince !== null) {
|
|
445
|
+
waitingSince = clock.startedTime;
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
const unsubscribeBufferingStart = subscribeBuffering((state) => {
|
|
449
|
+
if (state.buffering && waitingSince === null && !hasBeenStopped) {
|
|
450
|
+
cancelQueuedFrame();
|
|
451
|
+
queueNextFrame();
|
|
452
|
+
}
|
|
391
453
|
});
|
|
392
454
|
queueNextFrame();
|
|
393
455
|
const onVisibilityChange = () => {
|
|
@@ -401,6 +463,8 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
401
463
|
return () => {
|
|
402
464
|
window.removeEventListener('visibilitychange', onVisibilityChange);
|
|
403
465
|
unsubscribeSeek === null || unsubscribeSeek === void 0 ? void 0 : unsubscribeSeek();
|
|
466
|
+
unsubscribeBufferingStart();
|
|
467
|
+
excludeWaitFromClock();
|
|
404
468
|
stop();
|
|
405
469
|
};
|
|
406
470
|
}, [
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2118,7 +2118,7 @@ var usePlayback = ({
|
|
|
2118
2118
|
playbackRate,
|
|
2119
2119
|
videoConfig: config
|
|
2120
2120
|
});
|
|
2121
|
-
const updateAudioAnchor = useCallback8(() => {
|
|
2121
|
+
const updateAudioAnchor = useCallback8((preserveFraction) => {
|
|
2122
2122
|
if (!sharedAudioContext?.audioContext || fps === null || muted) {
|
|
2123
2123
|
return false;
|
|
2124
2124
|
}
|
|
@@ -2127,8 +2127,9 @@ var usePlayback = ({
|
|
|
2127
2127
|
if (playing && clock !== null && durationInFrames !== null && clock.compositionId === compositionId && clock.fps === fps && clock.playbackRate === playbackRate) {
|
|
2128
2128
|
const actualFirstFrame = inFrame ?? 0;
|
|
2129
2129
|
const actualLastFrame = outFrame ?? durationInFrames - 1;
|
|
2130
|
+
const elapsed = performance.now() - clock.startedTime;
|
|
2130
2131
|
const { nextFrame, hasEnded } = calculateNextFrame({
|
|
2131
|
-
time:
|
|
2132
|
+
time: elapsed,
|
|
2132
2133
|
currentFrame: clock.frame,
|
|
2133
2134
|
playbackSpeed: playbackRate,
|
|
2134
2135
|
fps,
|
|
@@ -2138,6 +2139,10 @@ var usePlayback = ({
|
|
|
2138
2139
|
shouldLoop: loop
|
|
2139
2140
|
});
|
|
2140
2141
|
absoluteFrame = hasEnded && !moveToBeginningWhenEnded ? playbackRate > 0 ? actualLastFrame : actualFirstFrame : nextFrame;
|
|
2142
|
+
if (preserveFraction && !hasEnded) {
|
|
2143
|
+
const elapsedFrames = elapsed * playbackRate / (1000 / fps);
|
|
2144
|
+
absoluteFrame += elapsedFrames - Math.trunc(elapsedFrames);
|
|
2145
|
+
}
|
|
2141
2146
|
}
|
|
2142
2147
|
const changed = setGlobalTimeAnchor({
|
|
2143
2148
|
audioContext: sharedAudioContext.audioContext,
|
|
@@ -2188,7 +2193,7 @@ var usePlayback = ({
|
|
|
2188
2193
|
clock.frame = getCurrentFrame();
|
|
2189
2194
|
clock.seekRevision = seekRevisionAtRender;
|
|
2190
2195
|
}
|
|
2191
|
-
const changed = updateAudioAnchor();
|
|
2196
|
+
const changed = updateAudioAnchor(false);
|
|
2192
2197
|
if (!changed && playing && !muted && sharedAudioContext?._experimentalKeepAudioContextAlive) {
|
|
2193
2198
|
sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
|
|
2194
2199
|
}
|
|
@@ -2204,6 +2209,35 @@ var usePlayback = ({
|
|
|
2204
2209
|
seekRevisionAtRender,
|
|
2205
2210
|
updateAudioAnchor
|
|
2206
2211
|
]);
|
|
2212
|
+
useLayoutEffect2(() => {
|
|
2213
|
+
if (!sharedAudioContext || fps === null || durationInFrames === null) {
|
|
2214
|
+
return;
|
|
2215
|
+
}
|
|
2216
|
+
const updateEnd = () => {
|
|
2217
|
+
sharedAudioContext.setPlaybackEnd(!playing || muted ? 0 : !loop && playbackRate > 0 ? sharedAudioContext.audioSyncAnchor.value + ((outFrame ?? durationInFrames - 1) + 1) / fps / playbackRate : null, () => {
|
|
2218
|
+
if (muted || loop || playbackRate <= 0 || !sharedAudioContext.audioContext) {
|
|
2219
|
+
return null;
|
|
2220
|
+
}
|
|
2221
|
+
if (playing) {
|
|
2222
|
+
return sharedAudioContext.audioSyncAnchor.value + ((outFrame ?? durationInFrames - 1) + 1) / fps / playbackRate;
|
|
2223
|
+
}
|
|
2224
|
+
return sharedAudioContext.audioContext.currentTime + ((outFrame ?? durationInFrames - 1) + 1 - getCurrentFrame()) / fps / playbackRate;
|
|
2225
|
+
});
|
|
2226
|
+
};
|
|
2227
|
+
updateEnd();
|
|
2228
|
+
const subscription = sharedAudioContext.audioSyncAnchorEmitter.subscribe(updateEnd);
|
|
2229
|
+
return () => subscription.remove();
|
|
2230
|
+
}, [
|
|
2231
|
+
sharedAudioContext,
|
|
2232
|
+
fps,
|
|
2233
|
+
durationInFrames,
|
|
2234
|
+
playing,
|
|
2235
|
+
muted,
|
|
2236
|
+
loop,
|
|
2237
|
+
playbackRate,
|
|
2238
|
+
outFrame,
|
|
2239
|
+
getCurrentFrame
|
|
2240
|
+
]);
|
|
2207
2241
|
useLayoutEffect2(() => {
|
|
2208
2242
|
const audioContext = sharedAudioContext?.audioContext;
|
|
2209
2243
|
if (!audioContext) {
|
|
@@ -2221,7 +2255,7 @@ var usePlayback = ({
|
|
|
2221
2255
|
return;
|
|
2222
2256
|
}
|
|
2223
2257
|
if (newState && shouldForceAnchorChange(newState)) {
|
|
2224
|
-
updateAudioAnchor();
|
|
2258
|
+
updateAudioAnchor(false);
|
|
2225
2259
|
}
|
|
2226
2260
|
};
|
|
2227
2261
|
audioContext?.addEventListener("statechange", callback);
|
|
@@ -2256,9 +2290,16 @@ var usePlayback = ({
|
|
|
2256
2290
|
clock.frame = Internals10.Timeline.clampFrameToCompositionRange(clock.frame, durationInFrames);
|
|
2257
2291
|
playbackClockRef.current = clock;
|
|
2258
2292
|
let hasBeenStopped = false;
|
|
2293
|
+
let waitingSince = null;
|
|
2259
2294
|
let audioContextFailed = false;
|
|
2260
2295
|
let reqAnimFrameCall = null;
|
|
2261
2296
|
let unsubscribeBuffering = null;
|
|
2297
|
+
const excludeWaitFromClock = () => {
|
|
2298
|
+
if (waitingSince !== null) {
|
|
2299
|
+
clock.startedTime += performance.now() - waitingSince;
|
|
2300
|
+
waitingSince = null;
|
|
2301
|
+
}
|
|
2302
|
+
};
|
|
2262
2303
|
const cancelQueuedFrame = () => {
|
|
2263
2304
|
if (reqAnimFrameCall !== null) {
|
|
2264
2305
|
if (reqAnimFrameCall.type === "raf") {
|
|
@@ -2299,7 +2340,7 @@ var usePlayback = ({
|
|
|
2299
2340
|
clock.frame = getCurrentFrame();
|
|
2300
2341
|
clock.seekRevision = seekRevision;
|
|
2301
2342
|
if (anchorSeekRevision.current !== seekRevision) {
|
|
2302
|
-
updateAudioAnchor();
|
|
2343
|
+
updateAudioAnchor(false);
|
|
2303
2344
|
anchorSeekRevision.current = seekRevision;
|
|
2304
2345
|
if (previousAudioBoundary.current !== null) {
|
|
2305
2346
|
previousAudioBoundary.current.seekRevision = seekRevision;
|
|
@@ -2320,14 +2361,14 @@ var usePlayback = ({
|
|
|
2320
2361
|
clock.framesAdvanced += framesToAdvance;
|
|
2321
2362
|
const frameToDisplay = hasEnded && !moveToBeginningWhenEnded ? playbackRate > 0 ? actualLastFrame : actualFirstFrame : nextFrame;
|
|
2322
2363
|
const didJump = frameToDisplay !== currentFrame + framesToAdvance;
|
|
2323
|
-
if (didJump) {
|
|
2364
|
+
if (didJump && !hasEnded) {
|
|
2324
2365
|
playbackJumpRevision.current++;
|
|
2325
2366
|
}
|
|
2326
2367
|
clock.frame = frameToDisplay;
|
|
2327
2368
|
if (frameToDisplay !== currentFrame) {
|
|
2328
2369
|
setFrameFromPlayback((c) => ({ ...c, [compositionId]: frameToDisplay }));
|
|
2329
|
-
} else if (didJump) {
|
|
2330
|
-
updateAudioAnchor();
|
|
2370
|
+
} else if (didJump && !hasEnded) {
|
|
2371
|
+
updateAudioAnchor(false);
|
|
2331
2372
|
if (previousAudioBoundary.current !== null) {
|
|
2332
2373
|
previousAudioBoundary.current.jumpRevision = playbackJumpRevision.current;
|
|
2333
2374
|
}
|
|
@@ -2346,6 +2387,7 @@ var usePlayback = ({
|
|
|
2346
2387
|
}
|
|
2347
2388
|
const getIsResumingAudioContext = audioContextFailed ? null : sharedAudioContext?.getIsResumingAudioContext?.() ?? null;
|
|
2348
2389
|
if (getIsResumingAudioContext !== null && !muted) {
|
|
2390
|
+
waitingSince = performance.now();
|
|
2349
2391
|
getIsResumingAudioContext.then((result) => {
|
|
2350
2392
|
if (hasBeenStopped) {
|
|
2351
2393
|
return;
|
|
@@ -2355,8 +2397,7 @@ var usePlayback = ({
|
|
|
2355
2397
|
sharedAudioContext?.suspend();
|
|
2356
2398
|
setPlayerMuted(true);
|
|
2357
2399
|
}
|
|
2358
|
-
|
|
2359
|
-
clock.framesAdvanced = 0;
|
|
2400
|
+
excludeWaitFromClock();
|
|
2360
2401
|
queueNextFrame();
|
|
2361
2402
|
});
|
|
2362
2403
|
return;
|
|
@@ -2365,6 +2406,7 @@ var usePlayback = ({
|
|
|
2365
2406
|
if (!muted && !audioContextFailed) {
|
|
2366
2407
|
sharedAudioContext?.suspend?.();
|
|
2367
2408
|
}
|
|
2409
|
+
waitingSince = performance.now();
|
|
2368
2410
|
unsubscribeBuffering = subscribeBuffering((state) => {
|
|
2369
2411
|
if (state.buffering) {
|
|
2370
2412
|
return;
|
|
@@ -2374,9 +2416,8 @@ var usePlayback = ({
|
|
|
2374
2416
|
if (hasBeenStopped) {
|
|
2375
2417
|
return;
|
|
2376
2418
|
}
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
updateAudioAnchor();
|
|
2419
|
+
excludeWaitFromClock();
|
|
2420
|
+
updateAudioAnchor(true);
|
|
2380
2421
|
if (!muted && !audioContextFailed && sharedAudioContext?._experimentalKeepAudioContextAlive) {
|
|
2381
2422
|
sharedAudioContext.resume();
|
|
2382
2423
|
}
|
|
@@ -2396,6 +2437,15 @@ var usePlayback = ({
|
|
|
2396
2437
|
const unsubscribeSeek = seek?.subscribe(() => {
|
|
2397
2438
|
clock.startedTime = performance.now();
|
|
2398
2439
|
clock.framesAdvanced = 0;
|
|
2440
|
+
if (waitingSince !== null) {
|
|
2441
|
+
waitingSince = clock.startedTime;
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
const unsubscribeBufferingStart = subscribeBuffering((state) => {
|
|
2445
|
+
if (state.buffering && waitingSince === null && !hasBeenStopped) {
|
|
2446
|
+
cancelQueuedFrame();
|
|
2447
|
+
queueNextFrame();
|
|
2448
|
+
}
|
|
2399
2449
|
});
|
|
2400
2450
|
queueNextFrame();
|
|
2401
2451
|
const onVisibilityChange = () => {
|
|
@@ -2409,6 +2459,8 @@ var usePlayback = ({
|
|
|
2409
2459
|
return () => {
|
|
2410
2460
|
window.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2411
2461
|
unsubscribeSeek?.();
|
|
2462
|
+
unsubscribeBufferingStart();
|
|
2463
|
+
excludeWaitFromClock();
|
|
2412
2464
|
stop();
|
|
2413
2465
|
};
|
|
2414
2466
|
}, [
|
|
@@ -2463,9 +2515,9 @@ import React13, {
|
|
|
2463
2515
|
useLayoutEffect as useLayoutEffect3,
|
|
2464
2516
|
useMemo as useMemo14,
|
|
2465
2517
|
useRef as useRef12,
|
|
2466
|
-
useState as
|
|
2518
|
+
useState as useState13
|
|
2467
2519
|
} from "react";
|
|
2468
|
-
import { Composition, Internals as
|
|
2520
|
+
import { Composition, Internals as Internals16 } from "remotion";
|
|
2469
2521
|
import { NoReactInternals as NoReactInternals2 } from "remotion/no-react";
|
|
2470
2522
|
|
|
2471
2523
|
// src/player-css-classname.ts
|
|
@@ -2483,9 +2535,9 @@ import React11, {
|
|
|
2483
2535
|
useImperativeHandle,
|
|
2484
2536
|
useMemo as useMemo12,
|
|
2485
2537
|
useRef as useRef10,
|
|
2486
|
-
useState as
|
|
2538
|
+
useState as useState11
|
|
2487
2539
|
} from "react";
|
|
2488
|
-
import { Internals as
|
|
2540
|
+
import { Internals as Internals12 } from "remotion";
|
|
2489
2541
|
|
|
2490
2542
|
// src/buffer-indicator-state.ts
|
|
2491
2543
|
var reduceBufferIndicator = (state, event) => {
|
|
@@ -2511,7 +2563,8 @@ var reduceBufferIndicator = (state, event) => {
|
|
|
2511
2563
|
};
|
|
2512
2564
|
|
|
2513
2565
|
// src/error-boundary.tsx
|
|
2514
|
-
import React9 from "react";
|
|
2566
|
+
import React9, { useState as useState10 } from "react";
|
|
2567
|
+
import { Internals as Internals11 } from "remotion";
|
|
2515
2568
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
2516
2569
|
var errorStyle = {
|
|
2517
2570
|
display: "flex",
|
|
@@ -2521,6 +2574,65 @@ var errorStyle = {
|
|
|
2521
2574
|
height: "100%",
|
|
2522
2575
|
width: "100%"
|
|
2523
2576
|
};
|
|
2577
|
+
var useOwnerLayoutEffect = typeof window === "undefined" ? React9.useEffect : React9.useLayoutEffect;
|
|
2578
|
+
var AsyncRenderErrorScope = ({
|
|
2579
|
+
children,
|
|
2580
|
+
renderingOwner,
|
|
2581
|
+
isReplacingComponent
|
|
2582
|
+
}) => {
|
|
2583
|
+
const [failure, setFailure] = useState10(null);
|
|
2584
|
+
const currentOwner = React9.useRef(null);
|
|
2585
|
+
const scheduleFailure = (failureOwner, error, beforeFirstCommit) => {
|
|
2586
|
+
const { generation } = failureOwner;
|
|
2587
|
+
queueMicrotask(() => {
|
|
2588
|
+
if (!failureOwner.active || currentOwner.current !== failureOwner || !beforeFirstCommit && generation !== failureOwner.generation)
|
|
2589
|
+
return;
|
|
2590
|
+
const committedGeneration = failureOwner.generation;
|
|
2591
|
+
setFailure((previous) => previous?.owner === failureOwner && previous.generation === committedGeneration ? previous : { owner: failureOwner, generation: committedGeneration, error });
|
|
2592
|
+
});
|
|
2593
|
+
};
|
|
2594
|
+
const createOwner = () => {
|
|
2595
|
+
const createdOwner = {
|
|
2596
|
+
renderingOwner,
|
|
2597
|
+
active: false,
|
|
2598
|
+
firstError: null,
|
|
2599
|
+
generation: 0,
|
|
2600
|
+
onCancel: (error) => {
|
|
2601
|
+
const beforeFirstCommit = !createdOwner.active && createdOwner.generation === 0;
|
|
2602
|
+
if (!createdOwner.active && !beforeFirstCommit || createdOwner.firstError !== null)
|
|
2603
|
+
return;
|
|
2604
|
+
createdOwner.firstError = error;
|
|
2605
|
+
if (!beforeFirstCommit)
|
|
2606
|
+
scheduleFailure(createdOwner, error, false);
|
|
2607
|
+
}
|
|
2608
|
+
};
|
|
2609
|
+
return createdOwner;
|
|
2610
|
+
};
|
|
2611
|
+
const [owner, setOwner] = useState10(createOwner);
|
|
2612
|
+
useOwnerLayoutEffect(() => {
|
|
2613
|
+
owner.active = true;
|
|
2614
|
+
currentOwner.current = owner;
|
|
2615
|
+
if (owner.generation === 0 && owner.firstError !== null) {
|
|
2616
|
+
scheduleFailure(owner, owner.firstError, true);
|
|
2617
|
+
}
|
|
2618
|
+
return () => {
|
|
2619
|
+
owner.active = false;
|
|
2620
|
+
owner.generation++;
|
|
2621
|
+
owner.firstError = null;
|
|
2622
|
+
if (currentOwner.current === owner)
|
|
2623
|
+
currentOwner.current = null;
|
|
2624
|
+
};
|
|
2625
|
+
}, [owner]);
|
|
2626
|
+
if (!Object.is(owner.renderingOwner, renderingOwner)) {
|
|
2627
|
+
setOwner(createOwner());
|
|
2628
|
+
}
|
|
2629
|
+
if (!isReplacingComponent && Object.is(owner.renderingOwner, renderingOwner) && failure?.owner === owner && failure.generation === owner.generation)
|
|
2630
|
+
throw failure.error;
|
|
2631
|
+
return /* @__PURE__ */ jsx10(Internals11.CancelRenderContext.Provider, {
|
|
2632
|
+
value: owner.onCancel,
|
|
2633
|
+
children
|
|
2634
|
+
});
|
|
2635
|
+
};
|
|
2524
2636
|
|
|
2525
2637
|
class ErrorBoundary extends React9.Component {
|
|
2526
2638
|
state = { hasError: null };
|
|
@@ -2539,7 +2651,11 @@ class ErrorBoundary extends React9.Component {
|
|
|
2539
2651
|
})
|
|
2540
2652
|
});
|
|
2541
2653
|
}
|
|
2542
|
-
return
|
|
2654
|
+
return /* @__PURE__ */ jsx10(AsyncRenderErrorScope, {
|
|
2655
|
+
renderingOwner: this.props.renderingOwner,
|
|
2656
|
+
isReplacingComponent: this.props.isReplacingComponent,
|
|
2657
|
+
children: this.props.children
|
|
2658
|
+
});
|
|
2543
2659
|
}
|
|
2544
2660
|
}
|
|
2545
2661
|
|
|
@@ -2746,6 +2862,8 @@ var PlayerUI = ({
|
|
|
2746
2862
|
doubleClickToFullscreen,
|
|
2747
2863
|
spaceKeyToPlayOrPause,
|
|
2748
2864
|
errorFallback,
|
|
2865
|
+
renderingOwner,
|
|
2866
|
+
isReplacingComponent,
|
|
2749
2867
|
playbackRate,
|
|
2750
2868
|
renderLoading,
|
|
2751
2869
|
renderPoster,
|
|
@@ -2773,18 +2891,18 @@ var PlayerUI = ({
|
|
|
2773
2891
|
noSuspense
|
|
2774
2892
|
}, ref) => {
|
|
2775
2893
|
const { inFrame, outFrame } = useContext4(PlaybackRangeContext);
|
|
2776
|
-
const config =
|
|
2777
|
-
const video =
|
|
2894
|
+
const config = Internals12.useUnsafeVideoConfig();
|
|
2895
|
+
const video = Internals12.useVideo();
|
|
2778
2896
|
const container = useRef10(null);
|
|
2779
2897
|
const canvasSize = useElementSize(container, {
|
|
2780
2898
|
triggerOnWindowResize: false,
|
|
2781
2899
|
shouldApplyCssTransforms: false
|
|
2782
2900
|
});
|
|
2783
|
-
const [hasPausedToResume, setHasPausedToResume] =
|
|
2784
|
-
const [shouldAutoplay, setShouldAutoPlay] =
|
|
2785
|
-
const [isFullscreen, setIsFullscreen] =
|
|
2786
|
-
const [seeking, setSeeking] =
|
|
2787
|
-
const [hasPlayed, setHasPlayed] =
|
|
2901
|
+
const [hasPausedToResume, setHasPausedToResume] = useState11(false);
|
|
2902
|
+
const [shouldAutoplay, setShouldAutoPlay] = useState11(autoPlay);
|
|
2903
|
+
const [isFullscreen, setIsFullscreen] = useState11(() => false);
|
|
2904
|
+
const [seeking, setSeeking] = useState11(false);
|
|
2905
|
+
const [hasPlayed, setHasPlayed] = useState11(false);
|
|
2788
2906
|
const supportsFullScreen = useMemo12(() => {
|
|
2789
2907
|
if (typeof document === "undefined") {
|
|
2790
2908
|
return false;
|
|
@@ -2792,8 +2910,8 @@ var PlayerUI = ({
|
|
|
2792
2910
|
return Boolean(document.fullscreenEnabled || document.webkitFullscreenEnabled);
|
|
2793
2911
|
}, []);
|
|
2794
2912
|
const player = usePlayerMethods();
|
|
2795
|
-
const playing =
|
|
2796
|
-
const frame =
|
|
2913
|
+
const playing = Internals12.usePlaying();
|
|
2914
|
+
const frame = Internals12.Timeline.useTimelinePosition();
|
|
2797
2915
|
const play = useCallback11((e) => {
|
|
2798
2916
|
if (player.isPlaying()) {
|
|
2799
2917
|
return;
|
|
@@ -2801,8 +2919,8 @@ var PlayerUI = ({
|
|
|
2801
2919
|
setHasPlayed(true);
|
|
2802
2920
|
player.play(e);
|
|
2803
2921
|
}, [player]);
|
|
2804
|
-
const [playerMuted, setPlayerMuted] =
|
|
2805
|
-
const [mediaVolume, setMediaVolume] =
|
|
2922
|
+
const [playerMuted, setPlayerMuted] = Internals12.usePlayerMutedState();
|
|
2923
|
+
const [mediaVolume, setMediaVolume] = Internals12.useMediaVolumeState();
|
|
2806
2924
|
const canvasOverlay = useContext4(CanvasOverlayContext);
|
|
2807
2925
|
const canvasContentRef = useRef10(null);
|
|
2808
2926
|
useEffect12(() => {
|
|
@@ -2922,8 +3040,8 @@ var PlayerUI = ({
|
|
|
2922
3040
|
}
|
|
2923
3041
|
player.emitter.dispatchScaleChange(scale);
|
|
2924
3042
|
}, [player.emitter, scale]);
|
|
2925
|
-
const { subscribeBuffering, isBuffering } = useContext4(
|
|
2926
|
-
const [bufferIndicator, setBufferIndicator] =
|
|
3043
|
+
const { subscribeBuffering, isBuffering } = useContext4(Internals12.SetTimelineContext);
|
|
3044
|
+
const [bufferIndicator, setBufferIndicator] = useState11({
|
|
2927
3045
|
type: "idle"
|
|
2928
3046
|
});
|
|
2929
3047
|
const showBufferIndicator = bufferIndicator.type === "showing";
|
|
@@ -3155,7 +3273,9 @@ var PlayerUI = ({
|
|
|
3155
3273
|
VideoComponent ? /* @__PURE__ */ jsx12(ErrorBoundary, {
|
|
3156
3274
|
onError,
|
|
3157
3275
|
errorFallback,
|
|
3158
|
-
|
|
3276
|
+
renderingOwner,
|
|
3277
|
+
isReplacingComponent,
|
|
3278
|
+
children: /* @__PURE__ */ jsx12(Internals12.CurrentScaleContext.Provider, {
|
|
3159
3279
|
value: currentScale,
|
|
3160
3280
|
children: /* @__PURE__ */ jsx12(CanvasOverlayContext.Provider, {
|
|
3161
3281
|
value: null,
|
|
@@ -3244,11 +3364,11 @@ var PlayerUI = ({
|
|
|
3244
3364
|
var PlayerUI_default = forwardRef(PlayerUI);
|
|
3245
3365
|
|
|
3246
3366
|
// src/SharedPlayerContext.tsx
|
|
3247
|
-
import { useCallback as useCallback12, useMemo as useMemo13, useRef as useRef11, useState as
|
|
3248
|
-
import { Internals as
|
|
3367
|
+
import { useCallback as useCallback12, useMemo as useMemo13, useRef as useRef11, useState as useState12 } from "react";
|
|
3368
|
+
import { Internals as Internals14 } from "remotion";
|
|
3249
3369
|
|
|
3250
3370
|
// src/volume-persistence.ts
|
|
3251
|
-
import { Internals as
|
|
3371
|
+
import { Internals as Internals13 } from "remotion";
|
|
3252
3372
|
var DEFAULT_VOLUME_PERSISTENCE_KEY = "remotion.volumePreference";
|
|
3253
3373
|
var persistVolume = (volume, logLevel, volumePersistenceKey) => {
|
|
3254
3374
|
if (typeof window === "undefined") {
|
|
@@ -3257,7 +3377,7 @@ var persistVolume = (volume, logLevel, volumePersistenceKey) => {
|
|
|
3257
3377
|
try {
|
|
3258
3378
|
window.localStorage.setItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTENCE_KEY, String(volume));
|
|
3259
3379
|
} catch (e) {
|
|
3260
|
-
|
|
3380
|
+
Internals13.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
|
|
3261
3381
|
}
|
|
3262
3382
|
};
|
|
3263
3383
|
var getPreferredVolume = (volumePersistenceKey) => {
|
|
@@ -3342,8 +3462,8 @@ var SharedPlayerContexts = ({
|
|
|
3342
3462
|
fps,
|
|
3343
3463
|
inputProps
|
|
3344
3464
|
]);
|
|
3345
|
-
const [playerMuted, setPlayerMuted] =
|
|
3346
|
-
const [mediaVolume, setMediaVolume] =
|
|
3465
|
+
const [playerMuted, setPlayerMuted] = useState12(() => initiallyMuted);
|
|
3466
|
+
const [mediaVolume, setMediaVolume] = useState12(() => persistVolumeToStorage ? getPreferredVolume(volumePersistenceKey ?? null) : initialVolume);
|
|
3347
3467
|
const mediaVolumeContextValue = useMemo13(() => {
|
|
3348
3468
|
return {
|
|
3349
3469
|
playerMuted,
|
|
@@ -3380,38 +3500,38 @@ var SharedPlayerContexts = ({
|
|
|
3380
3500
|
isReadOnlyStudio: false
|
|
3381
3501
|
};
|
|
3382
3502
|
}, []);
|
|
3383
|
-
return /* @__PURE__ */ jsx13(
|
|
3503
|
+
return /* @__PURE__ */ jsx13(Internals14.RemotionEnvironmentContext.Provider, {
|
|
3384
3504
|
value: env,
|
|
3385
|
-
children: /* @__PURE__ */ jsx13(
|
|
3505
|
+
children: /* @__PURE__ */ jsx13(Internals14.LogLevelContext.Provider, {
|
|
3386
3506
|
value: logLevelContext,
|
|
3387
|
-
children: /* @__PURE__ */ jsx13(
|
|
3388
|
-
children: /* @__PURE__ */ jsx13(
|
|
3507
|
+
children: /* @__PURE__ */ jsx13(Internals14.CanUseRemotionHooksProvider, {
|
|
3508
|
+
children: /* @__PURE__ */ jsx13(Internals14.AbsoluteTimeContext.Provider, {
|
|
3389
3509
|
value: timelineContext,
|
|
3390
|
-
children: /* @__PURE__ */ jsx13(
|
|
3510
|
+
children: /* @__PURE__ */ jsx13(Internals14.PlaybackRateContext.Provider, {
|
|
3391
3511
|
value: playbackRateContext,
|
|
3392
|
-
children: /* @__PURE__ */ jsx13(
|
|
3512
|
+
children: /* @__PURE__ */ jsx13(Internals14.PlaybackPitchContext.Provider, {
|
|
3393
3513
|
value: preservePitch,
|
|
3394
|
-
children: /* @__PURE__ */ jsx13(
|
|
3514
|
+
children: /* @__PURE__ */ jsx13(Internals14.TimelineContext.Provider, {
|
|
3395
3515
|
value: timelineContext,
|
|
3396
|
-
children: /* @__PURE__ */ jsx13(
|
|
3516
|
+
children: /* @__PURE__ */ jsx13(Internals14.CompositionManager.Provider, {
|
|
3397
3517
|
value: compositionManagerContext,
|
|
3398
|
-
children: /* @__PURE__ */ jsx13(
|
|
3399
|
-
children: /* @__PURE__ */ jsx13(
|
|
3400
|
-
children: /* @__PURE__ */ jsx13(
|
|
3401
|
-
children: /* @__PURE__ */ jsx13(
|
|
3518
|
+
children: /* @__PURE__ */ jsx13(Internals14.VideoProvider, {
|
|
3519
|
+
children: /* @__PURE__ */ jsx13(Internals14.PrefetchProvider, {
|
|
3520
|
+
children: /* @__PURE__ */ jsx13(Internals14.DurationsContextProvider, {
|
|
3521
|
+
children: /* @__PURE__ */ jsx13(Internals14.MediaVolumeContext.Provider, {
|
|
3402
3522
|
value: mediaVolumeContextValue,
|
|
3403
|
-
children: /* @__PURE__ */ jsx13(
|
|
3523
|
+
children: /* @__PURE__ */ jsx13(Internals14.SetMediaVolumeContext.Provider, {
|
|
3404
3524
|
value: setMediaVolumeContextValue,
|
|
3405
|
-
children: /* @__PURE__ */ jsx13(
|
|
3406
|
-
children: /* @__PURE__ */ jsx13(
|
|
3525
|
+
children: /* @__PURE__ */ jsx13(Internals14.BufferingProvider, {
|
|
3526
|
+
children: /* @__PURE__ */ jsx13(Internals14.SharedAudioContextProvider, {
|
|
3407
3527
|
audioLatencyHint,
|
|
3408
3528
|
audioEnabled: shouldCreateAudioContext,
|
|
3409
3529
|
previewSampleRate: sampleRate,
|
|
3410
3530
|
_experimentalKeepAudioContextAlive,
|
|
3411
|
-
children: /* @__PURE__ */ jsx13(
|
|
3531
|
+
children: /* @__PURE__ */ jsx13(Internals14.SharedAudioTagsContextProvider, {
|
|
3412
3532
|
numberOfAudioTags: numberOfSharedAudioTags,
|
|
3413
|
-
children: /* @__PURE__ */ jsx13(
|
|
3414
|
-
value:
|
|
3533
|
+
children: /* @__PURE__ */ jsx13(Internals14.PreferredEffectBackendContext.Provider, {
|
|
3534
|
+
value: Internals14.validatePreferredEffectBackend(preferredEffectBackend),
|
|
3415
3535
|
children
|
|
3416
3536
|
})
|
|
3417
3537
|
})
|
|
@@ -3433,7 +3553,7 @@ var SharedPlayerContexts = ({
|
|
|
3433
3553
|
};
|
|
3434
3554
|
|
|
3435
3555
|
// src/use-remotion-license-acknowledge.ts
|
|
3436
|
-
import { Internals as
|
|
3556
|
+
import { Internals as Internals15 } from "remotion";
|
|
3437
3557
|
var warningShown = false;
|
|
3438
3558
|
var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
|
|
3439
3559
|
if (acknowledge) {
|
|
@@ -3443,7 +3563,7 @@ var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
|
|
|
3443
3563
|
return;
|
|
3444
3564
|
}
|
|
3445
3565
|
warningShown = true;
|
|
3446
|
-
|
|
3566
|
+
Internals15.Log.warn({ logLevel, tag: null }, "Note: Some companies are required to obtain a license to use Remotion. See: https://remotion.dev/license\nPass the `acknowledgeRemotionLicense` prop to `<Player />` function to make this message disappear.");
|
|
3447
3567
|
};
|
|
3448
3568
|
|
|
3449
3569
|
// src/utils/validate-in-out-frame.ts
|
|
@@ -3552,7 +3672,7 @@ var componentOrNullIfLazy = (props) => {
|
|
|
3552
3672
|
return null;
|
|
3553
3673
|
};
|
|
3554
3674
|
var TimelineSequenceObserverComponent = ({ onTimelineSequenceChange }) => {
|
|
3555
|
-
const registry = React13.useContext(
|
|
3675
|
+
const registry = React13.useContext(Internals16.SequenceRegistryContext);
|
|
3556
3676
|
useLayoutEffect3(() => {
|
|
3557
3677
|
if (registry === null) {
|
|
3558
3678
|
throw new Error("Timeline sequence observer requires a sequence registry");
|
|
@@ -3637,26 +3757,31 @@ var PlayerFn = ({
|
|
|
3637
3757
|
if (componentForValidation === Composition) {
|
|
3638
3758
|
throw new TypeError(`'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
|
|
3639
3759
|
}
|
|
3640
|
-
|
|
3641
|
-
const
|
|
3760
|
+
useState13(() => acknowledgeRemotionLicenseMessage(Boolean(acknowledgeRemotionLicense), logLevel));
|
|
3761
|
+
const {
|
|
3762
|
+
component: resolvedComponent,
|
|
3763
|
+
renderingOwner,
|
|
3764
|
+
isReplacingComponent
|
|
3765
|
+
} = Internals16.useLazyComponentWithOwner({
|
|
3642
3766
|
compProps: componentProps,
|
|
3643
3767
|
componentName: "Player",
|
|
3644
3768
|
noSuspense: Boolean(noSuspense)
|
|
3645
3769
|
});
|
|
3770
|
+
const component = resolvedComponent;
|
|
3646
3771
|
validateInitialFrame({ initialFrame, durationInFrames });
|
|
3647
|
-
const [frame, setFrame] =
|
|
3772
|
+
const [frame, setFrame] = useState13(() => ({
|
|
3648
3773
|
[PLAYER_COMP_ID]: initialFrame ?? 0
|
|
3649
3774
|
}));
|
|
3650
|
-
const seek =
|
|
3775
|
+
const seek = Internals16.useTimelineSeek(setFrame);
|
|
3651
3776
|
const frameRef = useRef12(frame);
|
|
3652
3777
|
frameRef.current = frame;
|
|
3653
3778
|
const rootRef = useRef12(null);
|
|
3654
3779
|
const audioAndVideoTags = useRef12([]);
|
|
3655
|
-
const playingStore = useMemo14(() =>
|
|
3656
|
-
const bufferingStore = useMemo14(() =>
|
|
3780
|
+
const playingStore = useMemo14(() => Internals16.createRuntimeValueStore({ playing: false }), []);
|
|
3781
|
+
const bufferingStore = useMemo14(() => Internals16.createRuntimeValueStore({ buffering: false }), []);
|
|
3657
3782
|
const readIsPlaying = useCallback13(() => playingStore.store.getSnapshot().playing, [playingStore]);
|
|
3658
3783
|
const readIsBuffering = useCallback13(() => bufferingStore.store.getSnapshot().buffering, [bufferingStore]);
|
|
3659
|
-
const [currentPlaybackRate, setCurrentPlaybackRate] =
|
|
3784
|
+
const [currentPlaybackRate, setCurrentPlaybackRate] = useState13(playbackRate);
|
|
3660
3785
|
if (typeof compositionHeight !== "number") {
|
|
3661
3786
|
throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
|
|
3662
3787
|
}
|
|
@@ -3720,8 +3845,8 @@ var PlayerFn = ({
|
|
|
3720
3845
|
setCurrentPlaybackRate(playbackRate);
|
|
3721
3846
|
}, [playbackRate]);
|
|
3722
3847
|
useImperativeHandle2(ref, () => rootRef.current, []);
|
|
3723
|
-
|
|
3724
|
-
|
|
3848
|
+
useState13(() => {
|
|
3849
|
+
Internals16.playbackLogging({
|
|
3725
3850
|
logLevel,
|
|
3726
3851
|
message: `[player] Mounting <Player>. User agent = ${typeof navigator === "undefined" ? "server" : navigator.userAgent}`,
|
|
3727
3852
|
tag: "player",
|
|
@@ -3776,7 +3901,7 @@ var PlayerFn = ({
|
|
|
3776
3901
|
]);
|
|
3777
3902
|
if (typeof window !== "undefined") {
|
|
3778
3903
|
useLayoutEffect3(() => {
|
|
3779
|
-
|
|
3904
|
+
Internals16.CSSUtils.injectCSS(Internals16.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
|
|
3780
3905
|
}, [overrideInternalClassName]);
|
|
3781
3906
|
}
|
|
3782
3907
|
const playbackRange = useMemo14(() => ({ inFrame: inFrame ?? null, outFrame: outFrame ?? null }), [inFrame, outFrame]);
|
|
@@ -3786,8 +3911,8 @@ var PlayerFn = ({
|
|
|
3786
3911
|
mode: "prevent-media-session"
|
|
3787
3912
|
};
|
|
3788
3913
|
}, [passedBrowserMediaControlsBehavior]);
|
|
3789
|
-
const player = /* @__PURE__ */ jsx14(
|
|
3790
|
-
children: /* @__PURE__ */ jsx14(
|
|
3914
|
+
const player = /* @__PURE__ */ jsx14(Internals16.IsPlayerContextProvider, {
|
|
3915
|
+
children: /* @__PURE__ */ jsx14(Internals16.SetTimelineContext.Provider, {
|
|
3791
3916
|
value: setTimelineContextValue,
|
|
3792
3917
|
children: /* @__PURE__ */ jsx14(SharedPlayerContexts, {
|
|
3793
3918
|
timelineContext: timelineContextValue,
|
|
@@ -3819,6 +3944,8 @@ var PlayerFn = ({
|
|
|
3819
3944
|
loop: Boolean(loop),
|
|
3820
3945
|
controls: Boolean(controls),
|
|
3821
3946
|
errorFallback,
|
|
3947
|
+
renderingOwner,
|
|
3948
|
+
isReplacingComponent,
|
|
3822
3949
|
style,
|
|
3823
3950
|
inputProps: actualInputProps,
|
|
3824
3951
|
allowFullscreen: Boolean(allowFullscreen),
|
|
@@ -3856,11 +3983,11 @@ var PlayerFn = ({
|
|
|
3856
3983
|
});
|
|
3857
3984
|
return /* @__PURE__ */ jsx14(PlaybackRangeContext.Provider, {
|
|
3858
3985
|
value: playbackRange,
|
|
3859
|
-
children: /* @__PURE__ */ jsx14(
|
|
3986
|
+
children: /* @__PURE__ */ jsx14(Internals16.DefaultPremountContext.Provider, {
|
|
3860
3987
|
value: defaultPremountInSeconds,
|
|
3861
|
-
children: onTimelineSequenceChange ? /* @__PURE__ */ jsx14(
|
|
3988
|
+
children: onTimelineSequenceChange ? /* @__PURE__ */ jsx14(Internals16.SequenceRegistrationContext.Provider, {
|
|
3862
3989
|
value: true,
|
|
3863
|
-
children: /* @__PURE__ */ jsxs10(
|
|
3990
|
+
children: /* @__PURE__ */ jsxs10(Internals16.SequenceManagerProvider, {
|
|
3864
3991
|
children: [
|
|
3865
3992
|
/* @__PURE__ */ jsx14(TimelineSequenceObserverComponent, {
|
|
3866
3993
|
onTimelineSequenceChange
|
|
@@ -3881,9 +4008,9 @@ import {
|
|
|
3881
4008
|
useLayoutEffect as useLayoutEffect4,
|
|
3882
4009
|
useMemo as useMemo17,
|
|
3883
4010
|
useRef as useRef14,
|
|
3884
|
-
useState as
|
|
4011
|
+
useState as useState14
|
|
3885
4012
|
} from "react";
|
|
3886
|
-
import { Internals as
|
|
4013
|
+
import { Internals as Internals18 } from "remotion";
|
|
3887
4014
|
|
|
3888
4015
|
// src/ThumbnailUI.tsx
|
|
3889
4016
|
import React14, {
|
|
@@ -3894,7 +4021,7 @@ import React14, {
|
|
|
3894
4021
|
useMemo as useMemo16,
|
|
3895
4022
|
useRef as useRef13
|
|
3896
4023
|
} from "react";
|
|
3897
|
-
import { Internals as
|
|
4024
|
+
import { Internals as Internals17 } from "remotion";
|
|
3898
4025
|
|
|
3899
4026
|
// src/use-thumbnail.ts
|
|
3900
4027
|
import { useContext as useContext5, useMemo as useMemo15 } from "react";
|
|
@@ -3922,14 +4049,16 @@ var ThumbnailUI = ({
|
|
|
3922
4049
|
style,
|
|
3923
4050
|
inputProps,
|
|
3924
4051
|
errorFallback,
|
|
4052
|
+
renderingOwner,
|
|
4053
|
+
isReplacingComponent,
|
|
3925
4054
|
renderLoading,
|
|
3926
4055
|
className,
|
|
3927
4056
|
overflowVisible,
|
|
3928
4057
|
noSuspense,
|
|
3929
4058
|
overrideInternalClassName
|
|
3930
4059
|
}, ref) => {
|
|
3931
|
-
const config =
|
|
3932
|
-
const video =
|
|
4060
|
+
const config = Internals17.useUnsafeVideoConfig();
|
|
4061
|
+
const video = Internals17.useVideo();
|
|
3933
4062
|
const container = useRef13(null);
|
|
3934
4063
|
const canvasSize = useElementSize(container, {
|
|
3935
4064
|
triggerOnWindowResize: false,
|
|
@@ -4004,7 +4133,9 @@ var ThumbnailUI = ({
|
|
|
4004
4133
|
children: VideoComponent ? /* @__PURE__ */ jsx15(ErrorBoundary, {
|
|
4005
4134
|
onError,
|
|
4006
4135
|
errorFallback,
|
|
4007
|
-
|
|
4136
|
+
renderingOwner,
|
|
4137
|
+
isReplacingComponent,
|
|
4138
|
+
children: /* @__PURE__ */ jsx15(Internals17.CurrentScaleContext.Provider, {
|
|
4008
4139
|
value: currentScaleContext,
|
|
4009
4140
|
children: /* @__PURE__ */ jsx15(VideoComponent, {
|
|
4010
4141
|
...video?.props ?? {},
|
|
@@ -4061,7 +4192,7 @@ var ThumbnailFn = ({
|
|
|
4061
4192
|
}
|
|
4062
4193
|
const rootRef = useRef14(null);
|
|
4063
4194
|
const audioAndVideoTags = useRef14([]);
|
|
4064
|
-
const bufferingStore = useMemo17(() =>
|
|
4195
|
+
const bufferingStore = useMemo17(() => Internals18.createRuntimeValueStore({ buffering: false }), []);
|
|
4065
4196
|
const timelineState = useMemo17(() => {
|
|
4066
4197
|
const value = {
|
|
4067
4198
|
isPlaying: () => false,
|
|
@@ -4108,17 +4239,22 @@ var ThumbnailFn = ({
|
|
|
4108
4239
|
};
|
|
4109
4240
|
}, [bufferingStore]);
|
|
4110
4241
|
useImperativeHandle4(ref, () => rootRef.current, []);
|
|
4111
|
-
const
|
|
4242
|
+
const {
|
|
4243
|
+
component: resolvedComponent,
|
|
4244
|
+
renderingOwner,
|
|
4245
|
+
isReplacingComponent
|
|
4246
|
+
} = Internals18.useLazyComponentWithOwner({
|
|
4112
4247
|
compProps: componentProps,
|
|
4113
4248
|
componentName: "Thumbnail",
|
|
4114
4249
|
noSuspense: Boolean(noSuspense)
|
|
4115
4250
|
});
|
|
4116
|
-
const
|
|
4251
|
+
const Component = resolvedComponent;
|
|
4252
|
+
const [emitter] = useState14(() => new ThumbnailEmitter);
|
|
4117
4253
|
const passedInputProps = useMemo17(() => {
|
|
4118
4254
|
return inputProps ?? {};
|
|
4119
4255
|
}, [inputProps]);
|
|
4120
|
-
return /* @__PURE__ */ jsx16(
|
|
4121
|
-
children: /* @__PURE__ */ jsx16(
|
|
4256
|
+
return /* @__PURE__ */ jsx16(Internals18.IsPlayerContextProvider, {
|
|
4257
|
+
children: /* @__PURE__ */ jsx16(Internals18.SetTimelineContext.Provider, {
|
|
4122
4258
|
value: setTimelineContext,
|
|
4123
4259
|
children: /* @__PURE__ */ jsx16(SharedPlayerContexts, {
|
|
4124
4260
|
timelineContext: timelineState,
|
|
@@ -4144,6 +4280,8 @@ var ThumbnailFn = ({
|
|
|
4144
4280
|
ref: rootRef,
|
|
4145
4281
|
className,
|
|
4146
4282
|
errorFallback,
|
|
4283
|
+
renderingOwner,
|
|
4284
|
+
isReplacingComponent,
|
|
4147
4285
|
inputProps: passedInputProps,
|
|
4148
4286
|
renderLoading,
|
|
4149
4287
|
style,
|
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.548",
|
|
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",
|
|
@@ -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.548"
|
|
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.548",
|
|
53
53
|
"eslint": "9.19.0",
|
|
54
54
|
"typescript": "7.1.0-beta"
|
|
55
55
|
},
|