@remotion/player 3.2.40 → 3.2.42
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/LICENSE.md +1 -1
- package/README.md +1 -1
- package/dist/Player.d.ts +3 -9
- package/dist/Player.js +4 -67
- package/dist/PlayerUI.d.ts +1 -5
- package/dist/PlayerUI.js +14 -50
- package/dist/SharedPlayerContext.d.ts +14 -0
- package/dist/SharedPlayerContext.js +71 -0
- package/dist/Thumbnail.d.ts +23 -0
- package/dist/Thumbnail.js +41 -0
- package/dist/ThumbnailUI.d.ts +11 -0
- package/dist/ThumbnailUI.js +107 -0
- package/dist/calc-style.d.ts +7 -0
- package/dist/calc-style.js +22 -0
- package/dist/calculate-scale.d.ts +25 -6
- package/dist/calculate-scale.js +53 -1
- package/dist/calculate-style.d.ts +19 -0
- package/dist/calculate-style.js +55 -0
- package/dist/emitter-context.d.ts +2 -1
- package/dist/emitter-context.js +2 -1
- package/dist/event-emitter.d.ts +23 -9
- package/dist/event-emitter.js +25 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -1
- package/dist/outer-style.d.ts +7 -0
- package/dist/outer-style.js +22 -0
- package/dist/player-methods.d.ts +6 -3
- package/dist/use-thumbnail.d.ts +6 -0
- package/dist/use-thumbnail.js +18 -0
- package/dist/utils/props-if-has-props.d.ts +5 -0
- package/dist/utils/props-if-has-props.js +2 -0
- package/package.json +3 -3
package/LICENSE.md
CHANGED
|
@@ -36,6 +36,6 @@ Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
|
|
|
36
36
|
|
|
37
37
|
## Company license
|
|
38
38
|
|
|
39
|
-
You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support.
|
|
39
|
+
You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](/docs/support)).
|
|
40
40
|
|
|
41
41
|
Visit [companies.remotion.dev](https://companies.remotion.dev) for pricing and to buy a license.
|
package/README.md
CHANGED
|
@@ -83,4 +83,4 @@ The most important props accepted:
|
|
|
83
83
|
| compositionWidth | The width of the composition in pixels |
|
|
84
84
|
| fps | The frame rate of the video |
|
|
85
85
|
|
|
86
|
-
For a complete reference of the available props, refer to [@remotion/player API](https://www.remotion.dev/docs/player/
|
|
86
|
+
For a complete reference of the available props, refer to [@remotion/player API](https://www.remotion.dev/docs/player/player).
|
package/dist/Player.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { ComponentType
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { CompProps } from 'remotion';
|
|
4
4
|
import type { PlayerRef } from './player-methods';
|
|
5
5
|
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
|
|
6
6
|
import type { RenderLoading, RenderPoster } from './PlayerUI';
|
|
7
|
-
|
|
8
|
-
inputProps?: Props;
|
|
9
|
-
} : {
|
|
10
|
-
inputProps: Props;
|
|
11
|
-
};
|
|
7
|
+
import type { PropsIfHasProps } from './utils/props-if-has-props';
|
|
12
8
|
export declare type ErrorFallback = (info: {
|
|
13
9
|
error: Error;
|
|
14
10
|
}) => React.ReactNode;
|
|
@@ -44,9 +40,7 @@ export declare type PlayerProps<T> = {
|
|
|
44
40
|
renderFullscreenButton?: RenderFullscreenButton;
|
|
45
41
|
} & PropsIfHasProps<T> & CompProps<T>;
|
|
46
42
|
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
|
|
47
|
-
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, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
|
|
48
43
|
declare module 'react' {
|
|
49
44
|
function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
50
45
|
}
|
|
51
|
-
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
|
|
52
|
-
export {};
|
|
46
|
+
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
package/dist/Player.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Player = exports.
|
|
6
|
+
exports.Player = exports.componentOrNullIfLazy = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const remotion_1 = require("remotion");
|
|
@@ -11,10 +11,10 @@ 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 SharedPlayerContext_1 = require("./SharedPlayerContext");
|
|
14
15
|
const validate_in_out_frame_1 = require("./utils/validate-in-out-frame");
|
|
15
16
|
const validate_initial_frame_1 = require("./utils/validate-initial-frame");
|
|
16
17
|
const validate_playbackrate_1 = require("./utils/validate-playbackrate");
|
|
17
|
-
const volume_persistance_1 = require("./volume-persistance");
|
|
18
18
|
const componentOrNullIfLazy = (props) => {
|
|
19
19
|
if ('component' in props) {
|
|
20
20
|
return props.component;
|
|
@@ -48,8 +48,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
48
48
|
const [rootId] = (0, react_1.useState)('player-comp');
|
|
49
49
|
const [emitter] = (0, react_1.useState)(() => new event_emitter_1.PlayerEmitter());
|
|
50
50
|
const rootRef = (0, react_1.useRef)(null);
|
|
51
|
-
const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
|
|
52
|
-
const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_1.getPreferredVolume)());
|
|
53
51
|
const audioAndVideoTags = (0, react_1.useRef)([]);
|
|
54
52
|
const imperativePlaying = (0, react_1.useRef)(false);
|
|
55
53
|
if (typeof compositionHeight !== 'number') {
|
|
@@ -106,10 +104,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
106
104
|
(0, react_1.useEffect)(() => {
|
|
107
105
|
emitter.dispatchRatechange(playbackRate);
|
|
108
106
|
}, [emitter, playbackRate]);
|
|
109
|
-
const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
|
|
110
|
-
setMediaVolume(vol);
|
|
111
|
-
(0, volume_persistance_1.persistVolume)(vol);
|
|
112
|
-
}, []);
|
|
113
107
|
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
114
108
|
const timelineContextValue = (0, react_1.useMemo)(() => {
|
|
115
109
|
return {
|
|
@@ -131,60 +125,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
131
125
|
setPlaying,
|
|
132
126
|
};
|
|
133
127
|
}, [setFrame]);
|
|
134
|
-
const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
135
|
-
return {
|
|
136
|
-
mediaMuted,
|
|
137
|
-
mediaVolume,
|
|
138
|
-
};
|
|
139
|
-
}, [mediaMuted, mediaVolume]);
|
|
140
|
-
const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
141
|
-
return {
|
|
142
|
-
setMediaMuted,
|
|
143
|
-
setMediaVolume: setMediaVolumeAndPersist,
|
|
144
|
-
};
|
|
145
|
-
}, [setMediaVolumeAndPersist]);
|
|
146
|
-
const compositionManagerContext = (0, react_1.useMemo)(() => {
|
|
147
|
-
return {
|
|
148
|
-
compositions: [
|
|
149
|
-
{
|
|
150
|
-
component: component,
|
|
151
|
-
durationInFrames,
|
|
152
|
-
height: compositionHeight,
|
|
153
|
-
width: compositionWidth,
|
|
154
|
-
fps,
|
|
155
|
-
id: 'player-comp',
|
|
156
|
-
props: inputProps,
|
|
157
|
-
nonce: 777,
|
|
158
|
-
scale: 1,
|
|
159
|
-
folderName: null,
|
|
160
|
-
defaultProps: undefined,
|
|
161
|
-
parentFolderName: null,
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
folders: [],
|
|
165
|
-
registerFolder: () => undefined,
|
|
166
|
-
unregisterFolder: () => undefined,
|
|
167
|
-
currentComposition: 'player-comp',
|
|
168
|
-
registerComposition: () => undefined,
|
|
169
|
-
registerSequence: () => undefined,
|
|
170
|
-
sequences: [],
|
|
171
|
-
setCurrentComposition: () => undefined,
|
|
172
|
-
unregisterComposition: () => undefined,
|
|
173
|
-
unregisterSequence: () => undefined,
|
|
174
|
-
registerAsset: () => undefined,
|
|
175
|
-
unregisterAsset: () => undefined,
|
|
176
|
-
currentCompositionMetadata: null,
|
|
177
|
-
setCurrentCompositionMetadata: () => undefined,
|
|
178
|
-
assets: [],
|
|
179
|
-
};
|
|
180
|
-
}, [
|
|
181
|
-
component,
|
|
182
|
-
durationInFrames,
|
|
183
|
-
compositionHeight,
|
|
184
|
-
compositionWidth,
|
|
185
|
-
fps,
|
|
186
|
-
inputProps,
|
|
187
|
-
]);
|
|
188
128
|
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
189
129
|
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
190
130
|
}, [inputProps]);
|
|
@@ -195,9 +135,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
195
135
|
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
|
|
196
136
|
}, []);
|
|
197
137
|
}
|
|
198
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
199
|
-
? clickToPlay
|
|
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, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null }) }) }) }) }) }) }) }) }) }) }));
|
|
138
|
+
return ((0, jsx_runtime_1.jsx)(SharedPlayerContext_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, 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' ? clickToPlay : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), 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, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null }) }) }) }));
|
|
201
139
|
};
|
|
202
|
-
exports.
|
|
203
|
-
exports.Player = (0, react_1.forwardRef)(exports.PlayerFn);
|
|
140
|
+
exports.Player = (0, react_1.forwardRef)(PlayerFn);
|
package/dist/PlayerUI.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare type ErrorFallback = (info: {
|
|
|
7
7
|
export declare type RenderLoading = (canvas: {
|
|
8
8
|
height: number;
|
|
9
9
|
width: number;
|
|
10
|
-
}) => React.
|
|
10
|
+
}) => React.ReactNode;
|
|
11
11
|
export declare type RenderPoster = RenderLoading;
|
|
12
12
|
declare const _default: (props: {
|
|
13
13
|
controls: boolean;
|
|
@@ -16,14 +16,10 @@ declare const _default: (props: {
|
|
|
16
16
|
allowFullscreen: boolean;
|
|
17
17
|
inputProps: unknown;
|
|
18
18
|
showVolumeControls: boolean;
|
|
19
|
-
mediaMuted: boolean;
|
|
20
19
|
style?: React.CSSProperties | undefined;
|
|
21
20
|
clickToPlay: boolean;
|
|
22
21
|
doubleClickToFullscreen: boolean;
|
|
23
22
|
spaceKeyToPlayOrPause: boolean;
|
|
24
|
-
setMediaVolume: (v: number) => void;
|
|
25
|
-
setMediaMuted: (v: boolean) => void;
|
|
26
|
-
mediaVolume: number;
|
|
27
23
|
errorFallback: ErrorFallback;
|
|
28
24
|
playbackRate: number;
|
|
29
25
|
renderLoading: RenderLoading | undefined;
|
package/dist/PlayerUI.js
CHANGED
|
@@ -33,7 +33,6 @@ const PlayerControls_1 = require("./PlayerControls");
|
|
|
33
33
|
const use_hover_state_1 = require("./use-hover-state");
|
|
34
34
|
const use_playback_1 = require("./use-playback");
|
|
35
35
|
const use_player_1 = require("./use-player");
|
|
36
|
-
const calculate_player_size_1 = require("./utils/calculate-player-size");
|
|
37
36
|
const is_node_1 = require("./utils/is-node");
|
|
38
37
|
const use_click_prevention_on_double_click_1 = require("./utils/use-click-prevention-on-double-click");
|
|
39
38
|
const use_element_size_1 = require("./utils/use-element-size");
|
|
@@ -42,7 +41,7 @@ if (reactVersion === '0') {
|
|
|
42
41
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
43
42
|
}
|
|
44
43
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
45
|
-
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls,
|
|
44
|
+
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, doubleClickToFullscreen, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, inFrame, outFrame, initiallyShowControls, renderFullscreen: renderFullscreenButton, renderPlayPauseButton, }, ref) => {
|
|
46
45
|
var _a, _b, _c, _d, _e;
|
|
47
46
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
48
47
|
const video = remotion_1.Internals.useVideo();
|
|
@@ -159,6 +158,8 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
159
158
|
});
|
|
160
159
|
}, [canvasSize, config]);
|
|
161
160
|
const scale = (_b = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _b !== void 0 ? _b : 1;
|
|
161
|
+
const { setMediaVolume, setMediaMuted } = (0, react_1.useContext)(remotion_1.Internals.SetMediaVolumeContext);
|
|
162
|
+
const { mediaMuted, mediaVolume } = (0, react_1.useContext)(remotion_1.Internals.MediaVolumeContext);
|
|
162
163
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
163
164
|
const methods = {
|
|
164
165
|
play: player.play,
|
|
@@ -227,52 +228,13 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
227
228
|
]);
|
|
228
229
|
const VideoComponent = video ? video.component : null;
|
|
229
230
|
const outerStyle = (0, react_1.useMemo)(() => {
|
|
230
|
-
|
|
231
|
-
return {};
|
|
232
|
-
}
|
|
233
|
-
return {
|
|
234
|
-
position: 'relative',
|
|
235
|
-
overflow: 'hidden',
|
|
236
|
-
...(0, calculate_player_size_1.calculatePlayerSize)({
|
|
237
|
-
compositionHeight: config.height,
|
|
238
|
-
compositionWidth: config.width,
|
|
239
|
-
currentSize: canvasSize,
|
|
240
|
-
height: style === null || style === void 0 ? void 0 : style.height,
|
|
241
|
-
width: style === null || style === void 0 ? void 0 : style.width,
|
|
242
|
-
}),
|
|
243
|
-
...style,
|
|
244
|
-
};
|
|
231
|
+
return (0, calculate_scale_1.calculateOuterStyle)({ canvasSize, config, style });
|
|
245
232
|
}, [canvasSize, config, style]);
|
|
246
233
|
const outer = (0, react_1.useMemo)(() => {
|
|
247
|
-
|
|
248
|
-
return {};
|
|
249
|
-
}
|
|
250
|
-
const { centerX, centerY } = layout;
|
|
251
|
-
return {
|
|
252
|
-
width: config.width * scale,
|
|
253
|
-
height: config.height * scale,
|
|
254
|
-
display: 'flex',
|
|
255
|
-
flexDirection: 'column',
|
|
256
|
-
position: 'absolute',
|
|
257
|
-
left: centerX,
|
|
258
|
-
top: centerY,
|
|
259
|
-
overflow: 'hidden',
|
|
260
|
-
};
|
|
234
|
+
return (0, calculate_scale_1.calculateOuter)({ config, layout, scale });
|
|
261
235
|
}, [config, layout, scale]);
|
|
262
236
|
const containerStyle = (0, react_1.useMemo)(() => {
|
|
263
|
-
|
|
264
|
-
return {};
|
|
265
|
-
}
|
|
266
|
-
return {
|
|
267
|
-
position: 'absolute',
|
|
268
|
-
width: config.width,
|
|
269
|
-
height: config.height,
|
|
270
|
-
display: 'flex',
|
|
271
|
-
transform: `scale(${scale})`,
|
|
272
|
-
marginLeft: layout.xCorrection,
|
|
273
|
-
marginTop: layout.yCorrection,
|
|
274
|
-
overflow: 'hidden',
|
|
275
|
-
};
|
|
237
|
+
return (0, calculate_scale_1.calculateContainerStyle)({ canvasSize, config, layout, scale });
|
|
276
238
|
}, [canvasSize, config, layout, scale]);
|
|
277
239
|
const onError = (0, react_1.useCallback)((error) => {
|
|
278
240
|
player.pause();
|
|
@@ -311,6 +273,14 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
311
273
|
setShouldAutoPlay(false);
|
|
312
274
|
}
|
|
313
275
|
}, [shouldAutoplay, player]);
|
|
276
|
+
const loadingMarkup = (0, react_1.useMemo)(() => {
|
|
277
|
+
return renderLoading
|
|
278
|
+
? renderLoading({
|
|
279
|
+
height: outerStyle.height,
|
|
280
|
+
width: outerStyle.width,
|
|
281
|
+
})
|
|
282
|
+
: null;
|
|
283
|
+
}, [outerStyle.height, outerStyle.width, renderLoading]);
|
|
314
284
|
if (!config) {
|
|
315
285
|
return null;
|
|
316
286
|
}
|
|
@@ -333,12 +303,6 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
333
303
|
if (is_node_1.IS_NODE && !doesReactVersionSupportSuspense) {
|
|
334
304
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
335
305
|
}
|
|
336
|
-
const loadingMarkup = renderLoading
|
|
337
|
-
? renderLoading({
|
|
338
|
-
height: outerStyle.height,
|
|
339
|
-
width: outerStyle.width,
|
|
340
|
-
})
|
|
341
|
-
: null;
|
|
342
306
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }) }));
|
|
343
307
|
};
|
|
344
308
|
exports.default = (0, react_1.forwardRef)(PlayerUI);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentType, LazyExoticComponent } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { TimelineContextValue } from 'remotion';
|
|
4
|
+
export declare const SharedPlayerContexts: React.FC<{
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
timelineContext: TimelineContextValue;
|
|
7
|
+
inputProps?: unknown;
|
|
8
|
+
fps: number;
|
|
9
|
+
compositionWidth: number;
|
|
10
|
+
compositionHeight: number;
|
|
11
|
+
durationInFrames: number;
|
|
12
|
+
component: LazyExoticComponent<ComponentType<unknown>>;
|
|
13
|
+
numberOfSharedAudioTags: number;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedPlayerContexts = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
|
+
const volume_persistance_1 = require("./volume-persistance");
|
|
8
|
+
const SharedPlayerContexts = ({ children, timelineContext, inputProps, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, }) => {
|
|
9
|
+
const compositionManagerContext = (0, react_1.useMemo)(() => {
|
|
10
|
+
return {
|
|
11
|
+
compositions: [
|
|
12
|
+
{
|
|
13
|
+
component: component,
|
|
14
|
+
durationInFrames,
|
|
15
|
+
height: compositionHeight,
|
|
16
|
+
width: compositionWidth,
|
|
17
|
+
fps,
|
|
18
|
+
id: 'player-comp',
|
|
19
|
+
props: inputProps,
|
|
20
|
+
nonce: 777,
|
|
21
|
+
scale: 1,
|
|
22
|
+
folderName: null,
|
|
23
|
+
defaultProps: undefined,
|
|
24
|
+
parentFolderName: null,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
folders: [],
|
|
28
|
+
registerFolder: () => undefined,
|
|
29
|
+
unregisterFolder: () => undefined,
|
|
30
|
+
currentComposition: 'player-comp',
|
|
31
|
+
registerComposition: () => undefined,
|
|
32
|
+
registerSequence: () => undefined,
|
|
33
|
+
sequences: [],
|
|
34
|
+
setCurrentComposition: () => undefined,
|
|
35
|
+
unregisterComposition: () => undefined,
|
|
36
|
+
unregisterSequence: () => undefined,
|
|
37
|
+
registerAsset: () => undefined,
|
|
38
|
+
unregisterAsset: () => undefined,
|
|
39
|
+
currentCompositionMetadata: null,
|
|
40
|
+
setCurrentCompositionMetadata: () => undefined,
|
|
41
|
+
assets: [],
|
|
42
|
+
};
|
|
43
|
+
}, [
|
|
44
|
+
component,
|
|
45
|
+
durationInFrames,
|
|
46
|
+
compositionHeight,
|
|
47
|
+
compositionWidth,
|
|
48
|
+
fps,
|
|
49
|
+
inputProps,
|
|
50
|
+
]);
|
|
51
|
+
const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
|
|
52
|
+
const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_1.getPreferredVolume)());
|
|
53
|
+
const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
54
|
+
return {
|
|
55
|
+
mediaMuted,
|
|
56
|
+
mediaVolume,
|
|
57
|
+
};
|
|
58
|
+
}, [mediaMuted, mediaVolume]);
|
|
59
|
+
const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
|
|
60
|
+
setMediaVolume(vol);
|
|
61
|
+
(0, volume_persistance_1.persistVolume)(vol);
|
|
62
|
+
}, []);
|
|
63
|
+
const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
64
|
+
return {
|
|
65
|
+
setMediaMuted,
|
|
66
|
+
setMediaVolume: setMediaVolumeAndPersist,
|
|
67
|
+
};
|
|
68
|
+
}, [setMediaVolumeAndPersist]);
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: timelineContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.DurationsContextProvider, { 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: children }) }) }) }) }) }) }) }));
|
|
70
|
+
};
|
|
71
|
+
exports.SharedPlayerContexts = SharedPlayerContexts;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CSSProperties, MutableRefObject } from 'react';
|
|
2
|
+
import type { CompProps } from 'remotion';
|
|
3
|
+
import type { ThumbnailMethods } from './player-methods';
|
|
4
|
+
import type { ErrorFallback, RenderLoading } from './PlayerUI';
|
|
5
|
+
import type { PropsIfHasProps } from './utils/props-if-has-props';
|
|
6
|
+
declare type ThumbnailProps<T> = PropsIfHasProps<T> & CompProps<T> & {
|
|
7
|
+
frameToDisplay: number;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
durationInFrames: number;
|
|
10
|
+
compositionWidth: number;
|
|
11
|
+
compositionHeight: number;
|
|
12
|
+
inputProps?: unknown;
|
|
13
|
+
fps: number;
|
|
14
|
+
errorFallback?: ErrorFallback;
|
|
15
|
+
renderLoading?: RenderLoading;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const ThumbnailFn: <T>({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback, renderLoading, ...componentProps }: ThumbnailProps<T>, ref: MutableRefObject<ThumbnailMethods>) => JSX.Element;
|
|
19
|
+
declare module 'react' {
|
|
20
|
+
function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
21
|
+
}
|
|
22
|
+
export declare const Thumbnail: <T>(props: ThumbnailProps<T> & import("react").RefAttributes<ThumbnailMethods>) => React.ReactElement | null;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Thumbnail = exports.ThumbnailFn = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const remotion_1 = require("remotion");
|
|
10
|
+
const emitter_context_1 = require("./emitter-context");
|
|
11
|
+
const event_emitter_1 = require("./event-emitter");
|
|
12
|
+
const SharedPlayerContext_1 = require("./SharedPlayerContext");
|
|
13
|
+
const ThumbnailUI_1 = __importDefault(require("./ThumbnailUI"));
|
|
14
|
+
const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback = () => '⚠️', renderLoading, ...componentProps }, ref) => {
|
|
15
|
+
const [thumbnailId] = (0, react_1.useState)(() => String((0, remotion_1.random)(null)));
|
|
16
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
17
|
+
const timelineState = (0, react_1.useMemo)(() => {
|
|
18
|
+
return {
|
|
19
|
+
playing: false,
|
|
20
|
+
frame: frameToDisplay,
|
|
21
|
+
rootId: thumbnailId,
|
|
22
|
+
imperativePlaying: {
|
|
23
|
+
current: false,
|
|
24
|
+
},
|
|
25
|
+
playbackRate: 1,
|
|
26
|
+
setPlaybackRate: () => {
|
|
27
|
+
throw new Error('thumbnail');
|
|
28
|
+
},
|
|
29
|
+
audioAndVideoTags: { current: [] },
|
|
30
|
+
};
|
|
31
|
+
}, [frameToDisplay, thumbnailId]);
|
|
32
|
+
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
33
|
+
const Component = remotion_1.Internals.useLazyComponent(componentProps);
|
|
34
|
+
const [emitter] = (0, react_1.useState)(() => new event_emitter_1.ThumbnailEmitter());
|
|
35
|
+
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
36
|
+
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
37
|
+
}, [inputProps]);
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(SharedPlayerContext_1.SharedPlayerContexts, { timelineContext: timelineState, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: 0, children: (0, jsx_runtime_1.jsx)(emitter_context_1.ThumbnailEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(ThumbnailUI_1.default, { className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style }) }) }));
|
|
39
|
+
};
|
|
40
|
+
exports.ThumbnailFn = ThumbnailFn;
|
|
41
|
+
exports.Thumbnail = (0, react_1.forwardRef)(exports.ThumbnailFn);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ThumbnailMethods } from './player-methods';
|
|
3
|
+
import type { ErrorFallback, RenderLoading } from './PlayerUI';
|
|
4
|
+
declare const _default: (props: {
|
|
5
|
+
inputProps: unknown;
|
|
6
|
+
style?: React.CSSProperties | undefined;
|
|
7
|
+
errorFallback: ErrorFallback;
|
|
8
|
+
renderLoading: RenderLoading | undefined;
|
|
9
|
+
className: string | undefined;
|
|
10
|
+
} & React.RefAttributes<ThumbnailMethods | null>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const remotion_1 = require("remotion");
|
|
29
|
+
const calculate_scale_1 = require("./calculate-scale");
|
|
30
|
+
const error_boundary_1 = require("./error-boundary");
|
|
31
|
+
const player_css_classname_1 = require("./player-css-classname");
|
|
32
|
+
const use_thumbnail_1 = require("./use-thumbnail");
|
|
33
|
+
const is_node_1 = require("./utils/is-node");
|
|
34
|
+
const use_element_size_1 = require("./utils/use-element-size");
|
|
35
|
+
const reactVersion = react_1.default.version.split('.')[0];
|
|
36
|
+
if (reactVersion === '0') {
|
|
37
|
+
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
38
|
+
}
|
|
39
|
+
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
40
|
+
const ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className }, ref) => {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
43
|
+
const video = remotion_1.Internals.useVideo();
|
|
44
|
+
const container = (0, react_1.useRef)(null);
|
|
45
|
+
const canvasSize = (0, use_element_size_1.useElementSize)(container, {
|
|
46
|
+
triggerOnWindowResize: false,
|
|
47
|
+
shouldApplyCssTransforms: false,
|
|
48
|
+
});
|
|
49
|
+
const layout = (0, react_1.useMemo)(() => {
|
|
50
|
+
if (!config || !canvasSize) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return (0, calculate_scale_1.calculateCanvasTransformation)({
|
|
54
|
+
canvasSize,
|
|
55
|
+
compositionHeight: config.height,
|
|
56
|
+
compositionWidth: config.width,
|
|
57
|
+
previewSize: 'auto',
|
|
58
|
+
});
|
|
59
|
+
}, [canvasSize, config]);
|
|
60
|
+
const scale = (_a = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _a !== void 0 ? _a : 1;
|
|
61
|
+
const thumbnail = (0, use_thumbnail_1.useThumbnail)();
|
|
62
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
63
|
+
const methods = {
|
|
64
|
+
getContainerNode: () => container.current,
|
|
65
|
+
getScale: () => scale,
|
|
66
|
+
};
|
|
67
|
+
return Object.assign(thumbnail.emitter, methods);
|
|
68
|
+
}, [scale, thumbnail.emitter]);
|
|
69
|
+
const VideoComponent = video ? video.component : null;
|
|
70
|
+
const outerStyle = (0, react_1.useMemo)(() => {
|
|
71
|
+
return (0, calculate_scale_1.calculateOuterStyle)({ config, style, canvasSize });
|
|
72
|
+
}, [canvasSize, config, style]);
|
|
73
|
+
const outer = (0, react_1.useMemo)(() => {
|
|
74
|
+
return (0, calculate_scale_1.calculateOuter)({ config, layout, scale });
|
|
75
|
+
}, [config, layout, scale]);
|
|
76
|
+
const containerStyle = (0, react_1.useMemo)(() => {
|
|
77
|
+
return (0, calculate_scale_1.calculateContainerStyle)({
|
|
78
|
+
canvasSize,
|
|
79
|
+
config,
|
|
80
|
+
layout,
|
|
81
|
+
scale,
|
|
82
|
+
});
|
|
83
|
+
}, [canvasSize, config, layout, scale]);
|
|
84
|
+
const onError = (0, react_1.useCallback)((error) => {
|
|
85
|
+
// Pay attention to `this context`
|
|
86
|
+
thumbnail.emitter.dispatchError(error);
|
|
87
|
+
}, [thumbnail.emitter]);
|
|
88
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
89
|
+
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
90
|
+
const loadingMarkup = (0, react_1.useMemo)(() => {
|
|
91
|
+
return renderLoading
|
|
92
|
+
? renderLoading({
|
|
93
|
+
height: outerStyle.height,
|
|
94
|
+
width: outerStyle.width,
|
|
95
|
+
})
|
|
96
|
+
: null;
|
|
97
|
+
}, [outerStyle.height, outerStyle.width, renderLoading]);
|
|
98
|
+
if (!config) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const content = ((0, jsx_runtime_1.jsx)("div", { style: outer, 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 }) }));
|
|
102
|
+
if (is_node_1.IS_NODE && !doesReactVersionSupportSuspense) {
|
|
103
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
104
|
+
}
|
|
105
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }) }));
|
|
106
|
+
};
|
|
107
|
+
exports.default = (0, react_1.forwardRef)(ThumbnailUI);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VideoConfig } from 'remotion';
|
|
2
|
+
import type { Size } from './utils/use-element-size';
|
|
3
|
+
export declare const calculateOuterStyle: ({ config, style, canvasSize, }: {
|
|
4
|
+
config: VideoConfig | null;
|
|
5
|
+
style: React.CSSProperties | undefined;
|
|
6
|
+
canvasSize: Size | null;
|
|
7
|
+
}) => React.CSSProperties;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateOuterStyle = void 0;
|
|
4
|
+
const calculate_player_size_1 = require("./utils/calculate-player-size");
|
|
5
|
+
const calculateOuterStyle = ({ config, style, canvasSize, }) => {
|
|
6
|
+
if (!config) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
position: 'relative',
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
...(0, calculate_player_size_1.calculatePlayerSize)({
|
|
13
|
+
compositionHeight: config.height,
|
|
14
|
+
compositionWidth: config.width,
|
|
15
|
+
currentSize: canvasSize,
|
|
16
|
+
height: style === null || style === void 0 ? void 0 : style.height,
|
|
17
|
+
width: style === null || style === void 0 ? void 0 : style.width,
|
|
18
|
+
}),
|
|
19
|
+
...style,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.calculateOuterStyle = calculateOuterStyle;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VideoConfig } from 'remotion';
|
|
1
2
|
import type { PreviewSize } from './utils/preview-size';
|
|
2
3
|
import type { Size } from './utils/use-element-size';
|
|
3
4
|
export declare const calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
|
|
@@ -6,15 +7,33 @@ export declare const calculateScale: ({ canvasSize, compositionHeight, compositi
|
|
|
6
7
|
compositionHeight: number;
|
|
7
8
|
canvasSize: Size;
|
|
8
9
|
}) => number;
|
|
9
|
-
|
|
10
|
-
previewSize: PreviewSize['size'];
|
|
11
|
-
compositionWidth: number;
|
|
12
|
-
compositionHeight: number;
|
|
13
|
-
canvasSize: Size;
|
|
14
|
-
}) => {
|
|
10
|
+
declare type Layout = {
|
|
15
11
|
centerX: number;
|
|
16
12
|
centerY: number;
|
|
17
13
|
xCorrection: number;
|
|
18
14
|
yCorrection: number;
|
|
19
15
|
scale: number;
|
|
20
16
|
};
|
|
17
|
+
export declare const calculateCanvasTransformation: ({ previewSize, compositionWidth, compositionHeight, canvasSize, }: {
|
|
18
|
+
previewSize: PreviewSize['size'];
|
|
19
|
+
compositionWidth: number;
|
|
20
|
+
compositionHeight: number;
|
|
21
|
+
canvasSize: Size;
|
|
22
|
+
}) => Layout;
|
|
23
|
+
export declare const calculateOuterStyle: ({ config, style, canvasSize, }: {
|
|
24
|
+
config: VideoConfig | null;
|
|
25
|
+
style: React.CSSProperties | undefined;
|
|
26
|
+
canvasSize: Size | null;
|
|
27
|
+
}) => React.CSSProperties;
|
|
28
|
+
export declare const calculateContainerStyle: ({ config, canvasSize, layout, scale, }: {
|
|
29
|
+
config: VideoConfig | null;
|
|
30
|
+
canvasSize: Size | null;
|
|
31
|
+
layout: Layout | null;
|
|
32
|
+
scale: number;
|
|
33
|
+
}) => React.CSSProperties;
|
|
34
|
+
export declare const calculateOuter: ({ layout, scale, config, }: {
|
|
35
|
+
layout: Layout | null;
|
|
36
|
+
scale: number;
|
|
37
|
+
config: VideoConfig | null;
|
|
38
|
+
}) => React.CSSProperties;
|
|
39
|
+
export {};
|
package/dist/calculate-scale.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateCanvasTransformation = exports.calculateScale = void 0;
|
|
3
|
+
exports.calculateOuter = exports.calculateContainerStyle = exports.calculateOuterStyle = exports.calculateCanvasTransformation = exports.calculateScale = void 0;
|
|
4
|
+
const calculate_player_size_1 = require("./utils/calculate-player-size");
|
|
4
5
|
const calculateScale = ({ canvasSize, compositionHeight, compositionWidth, previewSize, }) => {
|
|
5
6
|
const heightRatio = canvasSize.height / compositionHeight;
|
|
6
7
|
const widthRatio = canvasSize.width / compositionWidth;
|
|
@@ -31,3 +32,54 @@ const calculateCanvasTransformation = ({ previewSize, compositionWidth, composit
|
|
|
31
32
|
};
|
|
32
33
|
};
|
|
33
34
|
exports.calculateCanvasTransformation = calculateCanvasTransformation;
|
|
35
|
+
const calculateOuterStyle = ({ config, style, canvasSize, }) => {
|
|
36
|
+
if (!config) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
position: 'relative',
|
|
41
|
+
overflow: 'hidden',
|
|
42
|
+
...(0, calculate_player_size_1.calculatePlayerSize)({
|
|
43
|
+
compositionHeight: config.height,
|
|
44
|
+
compositionWidth: config.width,
|
|
45
|
+
currentSize: canvasSize,
|
|
46
|
+
height: style === null || style === void 0 ? void 0 : style.height,
|
|
47
|
+
width: style === null || style === void 0 ? void 0 : style.width,
|
|
48
|
+
}),
|
|
49
|
+
...style,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.calculateOuterStyle = calculateOuterStyle;
|
|
53
|
+
const calculateContainerStyle = ({ config, canvasSize, layout, scale, }) => {
|
|
54
|
+
if (!config || !canvasSize || !layout) {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
width: config.width,
|
|
60
|
+
height: config.height,
|
|
61
|
+
display: 'flex',
|
|
62
|
+
transform: `scale(${scale})`,
|
|
63
|
+
marginLeft: layout.xCorrection,
|
|
64
|
+
marginTop: layout.yCorrection,
|
|
65
|
+
overflow: 'hidden',
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.calculateContainerStyle = calculateContainerStyle;
|
|
69
|
+
const calculateOuter = ({ layout, scale, config, }) => {
|
|
70
|
+
if (!layout || !config) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
const { centerX, centerY } = layout;
|
|
74
|
+
return {
|
|
75
|
+
width: config.width * scale,
|
|
76
|
+
height: config.height * scale,
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'column',
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
left: centerX,
|
|
81
|
+
top: centerY,
|
|
82
|
+
overflow: 'hidden',
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
exports.calculateOuter = calculateOuter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { VideoConfig } from 'remotion';
|
|
3
|
+
import type { Size } from './utils/use-element-size';
|
|
4
|
+
export declare const calculateOuterStyle: ({ config, style, canvasSize, }: {
|
|
5
|
+
config: VideoConfig | null;
|
|
6
|
+
style: React.CSSProperties | undefined;
|
|
7
|
+
canvasSize: Size | null;
|
|
8
|
+
}) => React.CSSProperties;
|
|
9
|
+
export declare const calculateContainerStyle: ({ config, canvasSize, layout, scale, }: {
|
|
10
|
+
config: VideoConfig | null;
|
|
11
|
+
canvasSize: Size | null;
|
|
12
|
+
layout: unknown;
|
|
13
|
+
scale: number;
|
|
14
|
+
}) => React.CSSProperties;
|
|
15
|
+
export declare const calculateOuter: ({ layout, scale, config, }: {
|
|
16
|
+
layout: unknown;
|
|
17
|
+
scale: number;
|
|
18
|
+
config: VideoConfig | null;
|
|
19
|
+
}) => React.CSSProperties;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateOuter = exports.calculateContainerStyle = exports.calculateOuterStyle = void 0;
|
|
4
|
+
const calculate_player_size_1 = require("./utils/calculate-player-size");
|
|
5
|
+
const calculateOuterStyle = ({ config, style, canvasSize, }) => {
|
|
6
|
+
if (!config) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
position: 'relative',
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
...(0, calculate_player_size_1.calculatePlayerSize)({
|
|
13
|
+
compositionHeight: config.height,
|
|
14
|
+
compositionWidth: config.width,
|
|
15
|
+
currentSize: canvasSize,
|
|
16
|
+
height: style === null || style === void 0 ? void 0 : style.height,
|
|
17
|
+
width: style === null || style === void 0 ? void 0 : style.width,
|
|
18
|
+
}),
|
|
19
|
+
...style,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.calculateOuterStyle = calculateOuterStyle;
|
|
23
|
+
const calculateContainerStyle = ({ config, canvasSize, layout, scale, }) => {
|
|
24
|
+
if (!config || !canvasSize || !layout) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
width: config.width,
|
|
30
|
+
height: config.height,
|
|
31
|
+
display: 'flex',
|
|
32
|
+
transform: `scale(${scale})`,
|
|
33
|
+
marginLeft: layout.xCorrection,
|
|
34
|
+
marginTop: layout.yCorrection,
|
|
35
|
+
overflow: 'hidden',
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.calculateContainerStyle = calculateContainerStyle;
|
|
39
|
+
const calculateOuter = ({ layout, scale, config, }) => {
|
|
40
|
+
if (!layout || !config) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
const { centerX, centerY } = layout;
|
|
44
|
+
return {
|
|
45
|
+
width: config.width * scale,
|
|
46
|
+
height: config.height * scale,
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
left: centerX,
|
|
51
|
+
top: centerY,
|
|
52
|
+
overflow: 'hidden',
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.calculateOuter = calculateOuter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { PlayerEmitter } from './event-emitter';
|
|
2
|
+
import type { PlayerEmitter, ThumbnailEmitter } from './event-emitter';
|
|
3
3
|
export declare const PlayerEventEmitterContext: React.Context<PlayerEmitter | undefined>;
|
|
4
|
+
export declare const ThumbnailEmitterContext: React.Context<ThumbnailEmitter | undefined>;
|
package/dist/emitter-context.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PlayerEventEmitterContext = void 0;
|
|
6
|
+
exports.ThumbnailEmitterContext = exports.PlayerEventEmitterContext = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
exports.PlayerEventEmitterContext = react_1.default.createContext(undefined);
|
|
9
|
+
exports.ThumbnailEmitterContext = react_1.default.createContext(undefined);
|
package/dist/event-emitter.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare type RateChangeEventPayload = {
|
|
|
16
16
|
declare type FullscreenChangeEventPayload = {
|
|
17
17
|
isFullscreen: boolean;
|
|
18
18
|
};
|
|
19
|
-
declare type
|
|
19
|
+
declare type PlayerStateEventMap = {
|
|
20
20
|
seeked: SeekPayload;
|
|
21
21
|
pause: undefined;
|
|
22
22
|
play: undefined;
|
|
@@ -27,17 +27,24 @@ declare type StateEventMap = {
|
|
|
27
27
|
frameupdate: FrameUpdateEventPayload;
|
|
28
28
|
fullscreenchange: FullscreenChangeEventPayload;
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
declare type ThumbnailStateEventMap = {
|
|
31
|
+
error: ErrorPayload;
|
|
32
|
+
};
|
|
33
|
+
export declare type PlayerEventTypes = keyof PlayerStateEventMap;
|
|
34
|
+
export declare type ThumbnailEventTypes = keyof ThumbnailStateEventMap;
|
|
35
|
+
export declare type CallbackListener<T extends PlayerEventTypes> = (data: {
|
|
36
|
+
detail: PlayerStateEventMap[T];
|
|
33
37
|
}) => void;
|
|
34
|
-
declare type
|
|
35
|
-
[EventType in
|
|
38
|
+
declare type PlayerListeners = {
|
|
39
|
+
[EventType in PlayerEventTypes]: CallbackListener<EventType>[];
|
|
40
|
+
};
|
|
41
|
+
declare type ThumbnailListeners = {
|
|
42
|
+
[EventType in ThumbnailEventTypes]: CallbackListener<EventType>[];
|
|
36
43
|
};
|
|
37
44
|
export declare class PlayerEmitter {
|
|
38
|
-
listeners:
|
|
39
|
-
addEventListener<Q extends
|
|
40
|
-
removeEventListener<Q extends
|
|
45
|
+
listeners: PlayerListeners;
|
|
46
|
+
addEventListener<Q extends PlayerEventTypes>(name: Q, callback: CallbackListener<Q>): void;
|
|
47
|
+
removeEventListener<Q extends PlayerEventTypes>(name: Q, callback: CallbackListener<Q>): void;
|
|
41
48
|
private dispatchEvent;
|
|
42
49
|
dispatchSeek(frame: number): void;
|
|
43
50
|
dispatchPause(): void;
|
|
@@ -49,4 +56,11 @@ export declare class PlayerEmitter {
|
|
|
49
56
|
dispatchFrameUpdate(event: FrameUpdateEventPayload): void;
|
|
50
57
|
dispatchFullscreenChangeUpdate(event: FullscreenChangeEventPayload): void;
|
|
51
58
|
}
|
|
59
|
+
export declare class ThumbnailEmitter {
|
|
60
|
+
listeners: ThumbnailListeners;
|
|
61
|
+
addEventListener<Q extends ThumbnailEventTypes>(name: Q, callback: CallbackListener<Q>): void;
|
|
62
|
+
removeEventListener<Q extends ThumbnailEventTypes>(name: Q, callback: CallbackListener<Q>): void;
|
|
63
|
+
private dispatchEvent;
|
|
64
|
+
dispatchError(error: Error): void;
|
|
65
|
+
}
|
|
52
66
|
export {};
|
package/dist/event-emitter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlayerEmitter = void 0;
|
|
3
|
+
exports.ThumbnailEmitter = exports.PlayerEmitter = void 0;
|
|
4
4
|
class PlayerEmitter {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.listeners = {
|
|
@@ -61,3 +61,27 @@ class PlayerEmitter {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
exports.PlayerEmitter = PlayerEmitter;
|
|
64
|
+
class ThumbnailEmitter {
|
|
65
|
+
constructor() {
|
|
66
|
+
this.listeners = {
|
|
67
|
+
error: [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
addEventListener(name, callback) {
|
|
71
|
+
this.listeners[name].push(callback);
|
|
72
|
+
}
|
|
73
|
+
removeEventListener(name, callback) {
|
|
74
|
+
this.listeners[name] = this.listeners[name].filter((l) => l !== callback);
|
|
75
|
+
}
|
|
76
|
+
dispatchEvent(dispatchName, context) {
|
|
77
|
+
this.listeners[dispatchName].forEach((callback) => {
|
|
78
|
+
callback({ detail: context });
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
dispatchError(error) {
|
|
82
|
+
this.dispatchEvent('error', {
|
|
83
|
+
error,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.ThumbnailEmitter = ThumbnailEmitter;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { CallbackListener,
|
|
2
|
+
import type { CallbackListener, PlayerEventTypes } from './event-emitter';
|
|
3
3
|
import { PlayerEmitter } from './event-emitter';
|
|
4
4
|
export { Player, PlayerProps } from './Player';
|
|
5
|
-
export { PlayerMethods, PlayerRef } from './player-methods';
|
|
5
|
+
export { PlayerMethods, PlayerRef, ThumbnailMethods, ThumbnailRef, } from './player-methods';
|
|
6
6
|
export type { RenderFullscreenButton, RenderPlayPauseButton, } from './PlayerControls';
|
|
7
7
|
export type { ErrorFallback, RenderLoading, RenderPoster } from './PlayerUI';
|
|
8
|
+
export { Thumbnail } from './Thumbnail';
|
|
8
9
|
export { PreviewSize, Translation } from './utils/preview-size';
|
|
9
10
|
export { Size } from './utils/use-element-size';
|
|
10
|
-
export type { CallbackListener, EventTypes };
|
|
11
|
+
export type { CallbackListener, PlayerEventTypes as EventTypes };
|
|
11
12
|
export declare const PlayerInternals: {
|
|
12
13
|
PlayerEventEmitterContext: import("react").Context<PlayerEmitter | undefined>;
|
|
13
14
|
PlayerEmitter: typeof PlayerEmitter;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlayerInternals = exports.Player = void 0;
|
|
3
|
+
exports.PlayerInternals = exports.Thumbnail = exports.Player = void 0;
|
|
4
4
|
const calculate_scale_1 = require("./calculate-scale");
|
|
5
5
|
const emitter_context_1 = require("./emitter-context");
|
|
6
6
|
const event_emitter_1 = require("./event-emitter");
|
|
@@ -10,6 +10,8 @@ const use_player_1 = require("./use-player");
|
|
|
10
10
|
const use_element_size_1 = require("./utils/use-element-size");
|
|
11
11
|
var Player_1 = require("./Player");
|
|
12
12
|
Object.defineProperty(exports, "Player", { enumerable: true, get: function () { return Player_1.Player; } });
|
|
13
|
+
var Thumbnail_1 = require("./Thumbnail");
|
|
14
|
+
Object.defineProperty(exports, "Thumbnail", { enumerable: true, get: function () { return Thumbnail_1.Thumbnail; } });
|
|
13
15
|
exports.PlayerInternals = {
|
|
14
16
|
PlayerEventEmitterContext: emitter_context_1.PlayerEventEmitterContext,
|
|
15
17
|
PlayerEmitter: event_emitter_1.PlayerEmitter,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VideoConfig } from 'remotion';
|
|
2
|
+
import type { Size } from './utils/use-element-size';
|
|
3
|
+
export declare const calculateOuterStyle: ({ config, style, canvasSize, }: {
|
|
4
|
+
config: VideoConfig | null;
|
|
5
|
+
style: React.CSSProperties | undefined;
|
|
6
|
+
canvasSize: Size | null;
|
|
7
|
+
}) => React.CSSProperties;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateOuterStyle = void 0;
|
|
4
|
+
const calculate_player_size_1 = require("./utils/calculate-player-size");
|
|
5
|
+
const calculateOuterStyle = ({ config, style, canvasSize, }) => {
|
|
6
|
+
if (!config) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
position: 'relative',
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
...(0, calculate_player_size_1.calculatePlayerSize)({
|
|
13
|
+
compositionHeight: config.height,
|
|
14
|
+
compositionWidth: config.width,
|
|
15
|
+
currentSize: canvasSize,
|
|
16
|
+
height: style === null || style === void 0 ? void 0 : style.height,
|
|
17
|
+
width: style === null || style === void 0 ? void 0 : style.width,
|
|
18
|
+
}),
|
|
19
|
+
...style,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.calculateOuterStyle = calculateOuterStyle;
|
package/dist/player-methods.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { SyntheticEvent } from 'react';
|
|
2
2
|
import type { PlayerEmitter } from './event-emitter';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type ThumbnailMethods = {
|
|
4
|
+
getContainerNode: () => HTMLDivElement | null;
|
|
5
|
+
getScale: () => number;
|
|
6
|
+
};
|
|
7
|
+
export declare type PlayerMethods = ThumbnailMethods & {
|
|
4
8
|
play: (e?: SyntheticEvent) => void;
|
|
5
9
|
pause: () => void;
|
|
6
10
|
toggle: (e?: SyntheticEvent) => void;
|
|
7
11
|
seekTo: (frame: number) => void;
|
|
8
|
-
getContainerNode: () => HTMLDivElement | null;
|
|
9
12
|
getCurrentFrame: () => number;
|
|
10
13
|
requestFullscreen: () => void;
|
|
11
14
|
exitFullscreen: () => void;
|
|
@@ -16,6 +19,6 @@ export declare type PlayerMethods = {
|
|
|
16
19
|
isPlaying: () => boolean;
|
|
17
20
|
mute: () => void;
|
|
18
21
|
unmute: () => void;
|
|
19
|
-
getScale: () => number;
|
|
20
22
|
};
|
|
23
|
+
export declare type ThumbnailRef = PlayerEmitter & ThumbnailMethods;
|
|
21
24
|
export declare type PlayerRef = PlayerEmitter & PlayerMethods;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useThumbnail = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const emitter_context_1 = require("./emitter-context");
|
|
6
|
+
const useThumbnail = () => {
|
|
7
|
+
const emitter = (0, react_1.useContext)(emitter_context_1.ThumbnailEmitterContext);
|
|
8
|
+
if (!emitter) {
|
|
9
|
+
throw new TypeError('Expected Player event emitter context');
|
|
10
|
+
}
|
|
11
|
+
const returnValue = (0, react_1.useMemo)(() => {
|
|
12
|
+
return {
|
|
13
|
+
emitter,
|
|
14
|
+
};
|
|
15
|
+
}, [emitter]);
|
|
16
|
+
return returnValue;
|
|
17
|
+
};
|
|
18
|
+
exports.useThumbnail = useThumbnail;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/player",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.42",
|
|
4
4
|
"description": "Remotion Player",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"remotion": "3.2.
|
|
30
|
+
"remotion": "3.2.42"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=16.8.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "d297af4ecea4d09948bbf05eeb66dfa701be3787"
|
|
66
66
|
}
|