@remotion/player 3.2.14 → 3.2.15
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/Player.d.ts +3 -1
- package/dist/Player.js +8 -2
- package/dist/PlayerControls.d.ts +2 -0
- package/dist/PlayerControls.js +2 -2
- package/dist/PlayerSeekBar.d.ts +2 -0
- package/dist/PlayerSeekBar.js +19 -5
- package/dist/PlayerUI.d.ts +2 -0
- package/dist/PlayerUI.js +20 -8
- package/dist/calculate-scale.d.ts +7 -1
- package/dist/calculate-scale.js +13 -4
- package/dist/error-boundary.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/test/validate-in-out-frames.test.d.ts +1 -0
- package/dist/test/validate-in-out-frames.test.js +55 -0
- package/dist/utils/preview-size.d.ts +8 -1
- package/dist/utils/validate-in-out-frame.d.ts +6 -0
- package/dist/utils/validate-in-out-frame.js +54 -0
- package/dist/utils/validate-initial-frame.d.ts +0 -0
- package/dist/utils/validate-initial-frame.js +0 -0
- package/package.json +3 -3
package/dist/Player.d.ts
CHANGED
|
@@ -36,9 +36,11 @@ export declare type PlayerProps<T> = {
|
|
|
36
36
|
showPosterWhenPaused?: boolean;
|
|
37
37
|
showPosterWhenEnded?: boolean;
|
|
38
38
|
showPosterWhenUnplayed?: boolean;
|
|
39
|
+
inFrame?: number | null;
|
|
40
|
+
outFrame?: number | null;
|
|
39
41
|
} & PropsIfHasProps<T> & CompProps<T>;
|
|
40
42
|
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
|
|
41
|
-
export declare const PlayerFn: <T>({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls, loop, autoPlay, showVolumeControls, allowFullscreen, clickToPlay, doubleClickToFullscreen, spaceKeyToPlayOrPause, moveToBeginningWhenEnded, numberOfSharedAudioTags, errorFallback, playbackRate, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
|
|
43
|
+
export declare const PlayerFn: <T>({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls, loop, autoPlay, showVolumeControls, allowFullscreen, clickToPlay, doubleClickToFullscreen, spaceKeyToPlayOrPause, moveToBeginningWhenEnded, numberOfSharedAudioTags, errorFallback, playbackRate, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
|
|
42
44
|
declare module 'react' {
|
|
43
45
|
function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
44
46
|
}
|
package/dist/Player.js
CHANGED
|
@@ -11,6 +11,7 @@ const emitter_context_1 = require("./emitter-context");
|
|
|
11
11
|
const event_emitter_1 = require("./event-emitter");
|
|
12
12
|
const player_css_classname_1 = require("./player-css-classname");
|
|
13
13
|
const PlayerUI_1 = __importDefault(require("./PlayerUI"));
|
|
14
|
+
const validate_in_out_frame_1 = require("./utils/validate-in-out-frame");
|
|
14
15
|
const validate_initial_frame_1 = require("./utils/validate-initial-frame");
|
|
15
16
|
const validate_playbackrate_1 = require("./utils/validate-playbackrate");
|
|
16
17
|
const volume_persistance_1 = require("./volume-persistance");
|
|
@@ -21,7 +22,7 @@ const componentOrNullIfLazy = (props) => {
|
|
|
21
22
|
return null;
|
|
22
23
|
};
|
|
23
24
|
exports.componentOrNullIfLazy = componentOrNullIfLazy;
|
|
24
|
-
const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, ...componentProps }, ref) => {
|
|
25
|
+
const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, ...componentProps }, ref) => {
|
|
25
26
|
if (typeof window !== 'undefined') {
|
|
26
27
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
27
28
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -61,6 +62,11 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
61
62
|
remotion_1.Internals.validateDimension(compositionWidth, 'compositionWidth', 'of the <Player /> component');
|
|
62
63
|
remotion_1.Internals.validateDurationInFrames(durationInFrames, 'of the <Player/> component');
|
|
63
64
|
remotion_1.Internals.validateFps(fps, 'as a prop of the <Player/> component', false);
|
|
65
|
+
(0, validate_in_out_frame_1.validateInOutFrames)({
|
|
66
|
+
durationInFrames,
|
|
67
|
+
inFrame,
|
|
68
|
+
outFrame,
|
|
69
|
+
});
|
|
64
70
|
if (typeof controls !== 'boolean' && typeof controls !== 'undefined') {
|
|
65
71
|
throw new TypeError(`'controls' must be a boolean or undefined but got '${typeof controls}' instead`);
|
|
66
72
|
}
|
|
@@ -191,7 +197,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
191
197
|
}
|
|
192
198
|
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SharedAudioContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(emitter_context_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_1.default, { ref: rootRef, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: passedInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
|
|
193
199
|
? clickToPlay
|
|
194
|
-
: Boolean(controls), showVolumeControls: Boolean(showVolumeControls), setMediaVolume: setMediaVolumeAndPersist, mediaVolume: mediaVolume, mediaMuted: mediaMuted, doubleClickToFullscreen: Boolean(doubleClickToFullscreen), setMediaMuted: setMediaMuted, spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), renderPoster: renderPoster }) }) }) }) }) }) }) }) }));
|
|
200
|
+
: Boolean(controls), showVolumeControls: Boolean(showVolumeControls), setMediaVolume: setMediaVolumeAndPersist, mediaVolume: mediaVolume, mediaMuted: mediaMuted, doubleClickToFullscreen: Boolean(doubleClickToFullscreen), setMediaMuted: setMediaMuted, spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null }) }) }) }) }) }) }) }) }));
|
|
195
201
|
};
|
|
196
202
|
exports.PlayerFn = PlayerFn;
|
|
197
203
|
exports.Player = (0, react_1.forwardRef)(exports.PlayerFn);
|
package/dist/PlayerControls.d.ts
CHANGED
package/dist/PlayerControls.js
CHANGED
|
@@ -62,7 +62,7 @@ const timeLabel = {
|
|
|
62
62
|
fontFamily: 'sans-serif',
|
|
63
63
|
fontSize: 14,
|
|
64
64
|
};
|
|
65
|
-
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, }) => {
|
|
65
|
+
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, }) => {
|
|
66
66
|
const playButtonRef = (0, react_1.useRef)(null);
|
|
67
67
|
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
68
68
|
const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
|
|
@@ -90,6 +90,6 @@ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVo
|
|
|
90
90
|
}, []);
|
|
91
91
|
return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: buttonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: player.playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {}) }), showVolumeControls ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsx)(MediaVolumeSlider_1.MediaVolumeSlider, {})] })) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_1.formatTime)(frame / fps), " / ", (0, format_time_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), (0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: buttonStyle, onClick: isFullscreen
|
|
92
92
|
? onExitFullscreenButtonClick
|
|
93
|
-
: onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { minimized: !isFullscreen }) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_1.PlayerSeekBar, { onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, durationInFrames: durationInFrames })] }));
|
|
93
|
+
: onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { minimized: !isFullscreen }) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_1.PlayerSeekBar, { onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, durationInFrames: durationInFrames, inFrame: inFrame, outFrame: outFrame })] }));
|
|
94
94
|
};
|
|
95
95
|
exports.Controls = Controls;
|
package/dist/PlayerSeekBar.d.ts
CHANGED
package/dist/PlayerSeekBar.js
CHANGED
|
@@ -30,7 +30,7 @@ const containerStyle = {
|
|
|
30
30
|
};
|
|
31
31
|
const barBackground = {
|
|
32
32
|
height: BAR_HEIGHT,
|
|
33
|
-
backgroundColor: 'rgba(255, 255, 255, 0.
|
|
33
|
+
backgroundColor: 'rgba(255, 255, 255, 0.25)',
|
|
34
34
|
width: '100%',
|
|
35
35
|
borderRadius: BAR_HEIGHT / 2,
|
|
36
36
|
};
|
|
@@ -41,7 +41,7 @@ const findBodyInWhichDivIsLocated = (div) => {
|
|
|
41
41
|
}
|
|
42
42
|
return current;
|
|
43
43
|
};
|
|
44
|
-
const PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart }) => {
|
|
44
|
+
const PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFrame }) => {
|
|
45
45
|
const containerRef = (0, react_1.useRef)(null);
|
|
46
46
|
const barHovered = (0, use_hover_state_1.useHoverState)(containerRef);
|
|
47
47
|
const size = (0, use_element_size_1.useElementSize)(containerRef, {
|
|
@@ -123,10 +123,24 @@ const PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart }) => {
|
|
|
123
123
|
return {
|
|
124
124
|
height: BAR_HEIGHT,
|
|
125
125
|
backgroundColor: 'rgba(255, 255, 255, 1)',
|
|
126
|
-
width: (frame / (durationInFrames - 1)) * 100 + '%',
|
|
126
|
+
width: ((frame - (inFrame !== null && inFrame !== void 0 ? inFrame : 0)) / (durationInFrames - 1)) * 100 + '%',
|
|
127
|
+
marginLeft: ((inFrame !== null && inFrame !== void 0 ? inFrame : 0) / (durationInFrames - 1)) * 100 + '%',
|
|
127
128
|
borderRadius: BAR_HEIGHT / 2,
|
|
128
129
|
};
|
|
129
|
-
}, [durationInFrames, frame]);
|
|
130
|
-
|
|
130
|
+
}, [durationInFrames, frame, inFrame]);
|
|
131
|
+
const active = (0, react_1.useMemo)(() => {
|
|
132
|
+
return {
|
|
133
|
+
height: BAR_HEIGHT,
|
|
134
|
+
backgroundColor: 'rgba(255, 255, 255, 0.25)',
|
|
135
|
+
width: (((outFrame !== null && outFrame !== void 0 ? outFrame : durationInFrames - 1) - (inFrame !== null && inFrame !== void 0 ? inFrame : 0)) /
|
|
136
|
+
(durationInFrames - 1)) *
|
|
137
|
+
100 +
|
|
138
|
+
'%',
|
|
139
|
+
marginLeft: ((inFrame !== null && inFrame !== void 0 ? inFrame : 0) / (durationInFrames - 1)) * 100 + '%',
|
|
140
|
+
borderRadius: BAR_HEIGHT / 2,
|
|
141
|
+
position: 'absolute',
|
|
142
|
+
};
|
|
143
|
+
}, [durationInFrames, inFrame, outFrame]);
|
|
144
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, onPointerDown: onPointerDown, style: containerStyle, children: [(0, jsx_runtime_1.jsxs)("div", { style: barBackground, children: [(0, jsx_runtime_1.jsx)("div", { style: active }), (0, jsx_runtime_1.jsx)("div", { style: fillStyle })] }), (0, jsx_runtime_1.jsx)("div", { style: knobStyle })] }));
|
|
131
145
|
};
|
|
132
146
|
exports.PlayerSeekBar = PlayerSeekBar;
|
package/dist/PlayerUI.d.ts
CHANGED
|
@@ -32,5 +32,7 @@ declare const _default: (props: {
|
|
|
32
32
|
showPosterWhenPaused: boolean;
|
|
33
33
|
showPosterWhenEnded: boolean;
|
|
34
34
|
showPosterWhenUnplayed: boolean;
|
|
35
|
+
inFrame: number | null;
|
|
36
|
+
outFrame: number | null;
|
|
35
37
|
} & React.RefAttributes<PlayerRef | null>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
36
38
|
export default _default;
|
package/dist/PlayerUI.js
CHANGED
|
@@ -42,7 +42,7 @@ if (reactVersion === '0') {
|
|
|
42
42
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
43
43
|
}
|
|
44
44
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
45
|
-
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, mediaVolume, mediaMuted, doubleClickToFullscreen, setMediaMuted, setMediaVolume, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, }, ref) => {
|
|
45
|
+
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, mediaVolume, mediaMuted, doubleClickToFullscreen, setMediaMuted, setMediaVolume, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, inFrame, outFrame, }, ref) => {
|
|
46
46
|
var _a, _b, _c;
|
|
47
47
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
48
48
|
const video = remotion_1.Internals.useVideo();
|
|
@@ -60,8 +60,8 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
60
60
|
loop,
|
|
61
61
|
playbackRate,
|
|
62
62
|
moveToBeginningWhenEnded,
|
|
63
|
-
inFrame
|
|
64
|
-
outFrame
|
|
63
|
+
inFrame,
|
|
64
|
+
outFrame,
|
|
65
65
|
});
|
|
66
66
|
const player = (0, use_player_1.usePlayer)();
|
|
67
67
|
(0, react_1.useEffect)(() => {
|
|
@@ -233,11 +233,17 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
233
233
|
if (!config || !canvasSize) {
|
|
234
234
|
return null;
|
|
235
235
|
}
|
|
236
|
-
return (0, calculate_scale_1.
|
|
236
|
+
return (0, calculate_scale_1.calculateCanvasTransformation)({
|
|
237
237
|
canvasSize,
|
|
238
238
|
compositionHeight: config.height,
|
|
239
239
|
compositionWidth: config.width,
|
|
240
|
-
previewSize:
|
|
240
|
+
previewSize: {
|
|
241
|
+
size: 'auto',
|
|
242
|
+
translation: {
|
|
243
|
+
x: 0,
|
|
244
|
+
y: 0,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
241
247
|
});
|
|
242
248
|
}, [canvasSize, config]);
|
|
243
249
|
const outer = (0, react_1.useMemo)(() => {
|
|
@@ -260,11 +266,17 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
260
266
|
if (!config || !canvasSize) {
|
|
261
267
|
return {};
|
|
262
268
|
}
|
|
263
|
-
const { scale, xCorrection, yCorrection } = (0, calculate_scale_1.
|
|
269
|
+
const { scale, xCorrection, yCorrection } = (0, calculate_scale_1.calculateCanvasTransformation)({
|
|
264
270
|
canvasSize,
|
|
265
271
|
compositionHeight: config.height,
|
|
266
272
|
compositionWidth: config.width,
|
|
267
|
-
previewSize:
|
|
273
|
+
previewSize: {
|
|
274
|
+
size: 'auto',
|
|
275
|
+
translation: {
|
|
276
|
+
x: 0,
|
|
277
|
+
y: 0,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
268
280
|
});
|
|
269
281
|
return {
|
|
270
282
|
position: 'absolute',
|
|
@@ -332,7 +344,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
332
344
|
showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
|
|
333
345
|
showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
|
|
334
346
|
].some(Boolean);
|
|
335
|
-
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...((_c = inputProps) !== null && _c !== void 0 ? _c : {}) }) })) : null }) }), shouldShowPoster ? ((0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? ((0, jsx_runtime_1.jsx)(PlayerControls_1.Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart })) : null] }));
|
|
347
|
+
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...((_c = inputProps) !== null && _c !== void 0 ? _c : {}) }) })) : null }) }), shouldShowPoster ? ((0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? ((0, jsx_runtime_1.jsx)(PlayerControls_1.Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, inFrame: inFrame, outFrame: outFrame })) : null] }));
|
|
336
348
|
if (is_node_1.IS_NODE && !doesReactVersionSupportSuspense) {
|
|
337
349
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
338
350
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { PreviewSize } from './utils/preview-size';
|
|
2
2
|
import type { Size } from './utils/use-element-size';
|
|
3
|
-
export declare const calculateScale: ({
|
|
3
|
+
export declare const calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
|
|
4
|
+
previewSize: PreviewSize['size'];
|
|
5
|
+
compositionWidth: number;
|
|
6
|
+
compositionHeight: number;
|
|
7
|
+
canvasSize: Size;
|
|
8
|
+
}) => number;
|
|
9
|
+
export declare const calculateCanvasTransformation: ({ previewSize, compositionWidth, compositionHeight, canvasSize, }: {
|
|
4
10
|
previewSize: PreviewSize;
|
|
5
11
|
compositionWidth: number;
|
|
6
12
|
compositionHeight: number;
|
package/dist/calculate-scale.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateScale = void 0;
|
|
4
|
-
const calculateScale = ({
|
|
3
|
+
exports.calculateCanvasTransformation = exports.calculateScale = void 0;
|
|
4
|
+
const calculateScale = ({ canvasSize, compositionHeight, compositionWidth, previewSize, }) => {
|
|
5
5
|
const heightRatio = canvasSize.height / compositionHeight;
|
|
6
6
|
const widthRatio = canvasSize.width / compositionWidth;
|
|
7
7
|
const ratio = Math.min(heightRatio, widthRatio);
|
|
8
|
-
|
|
8
|
+
return previewSize === 'auto' ? ratio : Number(previewSize);
|
|
9
|
+
};
|
|
10
|
+
exports.calculateScale = calculateScale;
|
|
11
|
+
const calculateCanvasTransformation = ({ previewSize, compositionWidth, compositionHeight, canvasSize, }) => {
|
|
12
|
+
const scale = (0, exports.calculateScale)({
|
|
13
|
+
canvasSize,
|
|
14
|
+
compositionHeight,
|
|
15
|
+
compositionWidth,
|
|
16
|
+
previewSize: previewSize.size,
|
|
17
|
+
});
|
|
9
18
|
const correction = 0 - (1 - scale) / 2;
|
|
10
19
|
const xCorrection = correction * compositionWidth;
|
|
11
20
|
const yCorrection = correction * compositionHeight;
|
|
@@ -21,4 +30,4 @@ const calculateScale = ({ previewSize, compositionWidth, compositionHeight, canv
|
|
|
21
30
|
scale,
|
|
22
31
|
};
|
|
23
32
|
};
|
|
24
|
-
exports.
|
|
33
|
+
exports.calculateCanvasTransformation = calculateCanvasTransformation;
|
package/dist/error-boundary.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export declare class ErrorBoundary extends React.Component<{
|
|
|
15
15
|
hasError: Error;
|
|
16
16
|
};
|
|
17
17
|
componentDidCatch(error: Error): void;
|
|
18
|
-
render(): string | number | boolean |
|
|
18
|
+
render(): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
|
|
19
19
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { PlayerEmitter } from './event-emitter';
|
|
|
3
3
|
export { ErrorFallback, Player, PlayerProps } from './Player';
|
|
4
4
|
export { PlayerMethods, PlayerRef } from './player-methods';
|
|
5
5
|
export type { RenderLoading, RenderPoster } from './PlayerUI';
|
|
6
|
-
export { PreviewSize } from './utils/preview-size';
|
|
6
|
+
export { PreviewSize, Translation } from './utils/preview-size';
|
|
7
7
|
export { Size } from './utils/use-element-size';
|
|
8
8
|
export type { CallbackListener, EventTypes };
|
|
9
9
|
export declare const PlayerInternals: {
|
|
@@ -35,7 +35,7 @@ export declare const PlayerInternals: {
|
|
|
35
35
|
triggerOnWindowResize: boolean;
|
|
36
36
|
shouldApplyCssTransforms: boolean;
|
|
37
37
|
}) => import("./utils/use-element-size").Size | null;
|
|
38
|
-
|
|
38
|
+
calculateCanvasTransformation: ({ previewSize, compositionWidth, compositionHeight, canvasSize, }: {
|
|
39
39
|
previewSize: import("./utils/preview-size").PreviewSize;
|
|
40
40
|
compositionWidth: number;
|
|
41
41
|
compositionHeight: number;
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.PlayerInternals = {
|
|
|
16
16
|
usePlayer: use_player_1.usePlayer,
|
|
17
17
|
usePlayback: use_playback_1.usePlayback,
|
|
18
18
|
useElementSize: use_element_size_1.useElementSize,
|
|
19
|
-
|
|
19
|
+
calculateCanvasTransformation: calculate_scale_1.calculateCanvasTransformation,
|
|
20
20
|
useHoverState: use_hover_state_1.useHoverState,
|
|
21
21
|
updateAllElementsSizes: use_element_size_1.updateAllElementsSizes,
|
|
22
22
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const validate_in_out_frame_1 = require("../utils/validate-in-out-frame");
|
|
4
|
+
test('Validate in out frames', () => {
|
|
5
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
6
|
+
durationInFrames: 200,
|
|
7
|
+
inFrame: 201,
|
|
8
|
+
outFrame: undefined,
|
|
9
|
+
})).toThrow(/inFrame must be less than \(durationInFrames - 1\)/);
|
|
10
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
11
|
+
durationInFrames: 200,
|
|
12
|
+
inFrame: 199,
|
|
13
|
+
outFrame: 201,
|
|
14
|
+
})).toThrow(/outFrame must be less than \(durationInFrames - 1\)/);
|
|
15
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
16
|
+
durationInFrames: 200,
|
|
17
|
+
inFrame: -10,
|
|
18
|
+
outFrame: null,
|
|
19
|
+
})).toThrow(/inFrame must be greater than 0, but is -10/);
|
|
20
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
21
|
+
durationInFrames: 200,
|
|
22
|
+
inFrame: null,
|
|
23
|
+
outFrame: -10,
|
|
24
|
+
})).toThrow(/outFrame must be greater than 0, but is -10/);
|
|
25
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
26
|
+
durationInFrames: 200,
|
|
27
|
+
inFrame: 1.5,
|
|
28
|
+
outFrame: null,
|
|
29
|
+
})).toThrow(/"inFrame" must be an integer, but is 1.5/);
|
|
30
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
31
|
+
durationInFrames: 200,
|
|
32
|
+
inFrame: 20,
|
|
33
|
+
outFrame: 20,
|
|
34
|
+
})).toThrow(/outFrame must be greater than inFrame, but is 20/);
|
|
35
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
36
|
+
durationInFrames: 200,
|
|
37
|
+
inFrame: 21,
|
|
38
|
+
outFrame: 20,
|
|
39
|
+
})).toThrow(/outFrame must be greater than inFrame, but is 20 <= 21/);
|
|
40
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
41
|
+
durationInFrames: 200,
|
|
42
|
+
inFrame: null,
|
|
43
|
+
outFrame: 20,
|
|
44
|
+
})).not.toThrow();
|
|
45
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
46
|
+
durationInFrames: 200,
|
|
47
|
+
inFrame: null,
|
|
48
|
+
outFrame: null,
|
|
49
|
+
})).not.toThrow();
|
|
50
|
+
expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
51
|
+
durationInFrames: 200,
|
|
52
|
+
inFrame: 10,
|
|
53
|
+
outFrame: 20,
|
|
54
|
+
})).not.toThrow();
|
|
55
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const validateSingleFrameFrame: (frame: unknown, variableName: string) => number | null;
|
|
2
|
+
export declare const validateInOutFrames: ({ inFrame, durationInFrames, outFrame, }: {
|
|
3
|
+
inFrame: unknown;
|
|
4
|
+
outFrame: unknown;
|
|
5
|
+
durationInFrames: number;
|
|
6
|
+
}) => void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateInOutFrames = exports.validateSingleFrameFrame = void 0;
|
|
4
|
+
const validateSingleFrameFrame = (frame, variableName) => {
|
|
5
|
+
if (typeof frame === 'undefined' || frame === null) {
|
|
6
|
+
return frame !== null && frame !== void 0 ? frame : null;
|
|
7
|
+
}
|
|
8
|
+
if (typeof frame !== 'number') {
|
|
9
|
+
throw new TypeError(`"${variableName}" must be a number, but is ${JSON.stringify(frame)}`);
|
|
10
|
+
}
|
|
11
|
+
if (Number.isNaN(frame)) {
|
|
12
|
+
throw new TypeError(`"${variableName}" must not be NaN, but is ${JSON.stringify(frame)}`);
|
|
13
|
+
}
|
|
14
|
+
if (!Number.isFinite(frame)) {
|
|
15
|
+
throw new TypeError(`"${variableName}" must be finite, but is ${JSON.stringify(frame)}`);
|
|
16
|
+
}
|
|
17
|
+
if (frame % 1 !== 0) {
|
|
18
|
+
throw new TypeError(`"${variableName}" must be an integer, but is ${JSON.stringify(frame)}`);
|
|
19
|
+
}
|
|
20
|
+
return frame;
|
|
21
|
+
};
|
|
22
|
+
exports.validateSingleFrameFrame = validateSingleFrameFrame;
|
|
23
|
+
const validateInOutFrames = ({ inFrame, durationInFrames, outFrame, }) => {
|
|
24
|
+
const validatedInFrame = (0, exports.validateSingleFrameFrame)(inFrame, 'inFrame');
|
|
25
|
+
const validateOutFrame = (0, exports.validateSingleFrameFrame)(outFrame, 'outFrame');
|
|
26
|
+
if (validatedInFrame === null && validateOutFrame === null) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// Must not be over the duration
|
|
30
|
+
if (validatedInFrame !== null && validatedInFrame > durationInFrames - 1) {
|
|
31
|
+
throw new Error('inFrame must be less than (durationInFrames - 1), but is ' +
|
|
32
|
+
validatedInFrame);
|
|
33
|
+
}
|
|
34
|
+
if (validateOutFrame !== null && validateOutFrame > durationInFrames - 1) {
|
|
35
|
+
throw new Error('outFrame must be less than (durationInFrames - 1), but is ' +
|
|
36
|
+
validatedInFrame);
|
|
37
|
+
}
|
|
38
|
+
// Must not be under 0
|
|
39
|
+
if (validatedInFrame !== null && validatedInFrame < 0) {
|
|
40
|
+
throw new Error('inFrame must be greater than 0, but is ' + validatedInFrame);
|
|
41
|
+
}
|
|
42
|
+
if (validateOutFrame !== null && validateOutFrame < 0) {
|
|
43
|
+
throw new Error('outFrame must be greater than 0, but is ' + validateOutFrame);
|
|
44
|
+
}
|
|
45
|
+
if (validateOutFrame !== null &&
|
|
46
|
+
validatedInFrame !== null &&
|
|
47
|
+
validateOutFrame <= validatedInFrame) {
|
|
48
|
+
throw new Error('outFrame must be greater than inFrame, but is ' +
|
|
49
|
+
validateOutFrame +
|
|
50
|
+
' <= ' +
|
|
51
|
+
validatedInFrame);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.validateInOutFrames = validateInOutFrames;
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/player",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.15",
|
|
4
4
|
"description": "Remotion Player",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"remotion": "3.2.
|
|
31
|
+
"remotion": "3.2.15"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=16.8.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "7346704683815d274733cb3d280157b9ff570773"
|
|
67
67
|
}
|