@remotion/player 3.3.54 → 3.3.55
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.d.ts +5 -0
- package/dist/cjs/Player.js +6 -2
- package/dist/cjs/PlayerControls.d.ts +1 -2
- package/dist/cjs/PlayerControls.js +6 -8
- package/dist/cjs/PlayerUI.d.ts +1 -0
- package/dist/cjs/PlayerUI.js +2 -2
- package/dist/cjs/Thumbnail.d.ts +4 -0
- package/dist/cjs/Thumbnail.js +4 -0
- package/dist/cjs/use-video-controls-resize.d.ts +2 -0
- package/dist/cjs/use-video-controls-resize.js +5 -4
- package/dist/esm/Player.d.ts +5 -0
- package/dist/esm/Player.js +6 -2
- package/dist/esm/PlayerControls.d.ts +1 -2
- package/dist/esm/PlayerControls.js +4 -6
- package/dist/esm/PlayerUI.d.ts +1 -0
- package/dist/esm/PlayerUI.js +2 -2
- package/dist/esm/Thumbnail.d.ts +4 -0
- package/dist/esm/Thumbnail.js +4 -0
- package/dist/esm/calculate-scale.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.mjs +1830 -0
- package/dist/esm/test/test-utils.d.ts +2 -2
- package/dist/esm/use-video-controls-resize.d.ts +2 -0
- package/dist/esm/use-video-controls-resize.js +2 -1
- package/dist/esm/utils/delay.d.ts +1 -1
- package/dist/esm/utils/use-cancellable-promises.d.ts +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -8
package/dist/cjs/Player.d.ts
CHANGED
|
@@ -38,6 +38,11 @@ export declare type PlayerProps<T> = {
|
|
|
38
38
|
initiallyShowControls?: number | boolean;
|
|
39
39
|
renderPlayPauseButton?: RenderPlayPauseButton;
|
|
40
40
|
renderFullscreenButton?: RenderFullscreenButton;
|
|
41
|
+
alwaysShowControls?: boolean;
|
|
41
42
|
} & PropsIfHasProps<T> & CompProps<T>;
|
|
42
43
|
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
|
|
44
|
+
/**
|
|
45
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
|
|
46
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/player)
|
|
47
|
+
*/
|
|
43
48
|
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
|
package/dist/cjs/Player.js
CHANGED
|
@@ -22,7 +22,7 @@ const componentOrNullIfLazy = (props) => {
|
|
|
22
22
|
return null;
|
|
23
23
|
};
|
|
24
24
|
exports.componentOrNullIfLazy = componentOrNullIfLazy;
|
|
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, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, ...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, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, alwaysShowControls = false, ...componentProps }, ref) => {
|
|
26
26
|
if (typeof window !== 'undefined') {
|
|
27
27
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
28
28
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -137,7 +137,11 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
137
137
|
}
|
|
138
138
|
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_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_js_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_js_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'
|
|
139
139
|
? clickToPlay
|
|
140
|
-
: 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 }) }) }) }) }));
|
|
140
|
+
: 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, alwaysShowControls: alwaysShowControls }) }) }) }) }));
|
|
141
141
|
};
|
|
142
142
|
const forward = react_1.forwardRef;
|
|
143
|
+
/**
|
|
144
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
|
|
145
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/player)
|
|
146
|
+
*/
|
|
143
147
|
exports.Player = forward(PlayerFn);
|
|
@@ -7,8 +7,6 @@ export declare type RenderPlayPauseButton = (props: {
|
|
|
7
7
|
export declare type RenderFullscreenButton = (props: {
|
|
8
8
|
isFullscreen: boolean;
|
|
9
9
|
}) => ReactNode;
|
|
10
|
-
export declare const X_SPACER = 10;
|
|
11
|
-
export declare const X_PADDING = 12;
|
|
12
10
|
declare global {
|
|
13
11
|
interface Document {
|
|
14
12
|
webkitFullscreenEnabled?: boolean;
|
|
@@ -38,4 +36,5 @@ export declare const Controls: React.FC<{
|
|
|
38
36
|
playerWidth: number;
|
|
39
37
|
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
40
38
|
renderFullscreenButton: RenderFullscreenButton | null;
|
|
39
|
+
alwaysShowControls: boolean;
|
|
41
40
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controls =
|
|
3
|
+
exports.Controls = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
@@ -9,8 +9,6 @@ const icons_js_1 = require("./icons.js");
|
|
|
9
9
|
const MediaVolumeSlider_js_1 = require("./MediaVolumeSlider.js");
|
|
10
10
|
const PlayerSeekBar_js_1 = require("./PlayerSeekBar.js");
|
|
11
11
|
const use_video_controls_resize_js_1 = require("./use-video-controls-resize.js");
|
|
12
|
-
exports.X_SPACER = 10;
|
|
13
|
-
exports.X_PADDING = 12;
|
|
14
12
|
const gradientSteps = [
|
|
15
13
|
0, 0.013, 0.049, 0.104, 0.175, 0.259, 0.352, 0.45, 0.55, 0.648, 0.741, 0.825,
|
|
16
14
|
0.896, 0.951, 0.987,
|
|
@@ -34,8 +32,8 @@ const containerStyle = {
|
|
|
34
32
|
.join(', ')}, hsl(0, 0%, 0%) 100%)`,
|
|
35
33
|
backgroundSize: 'auto 145px',
|
|
36
34
|
display: 'flex',
|
|
37
|
-
paddingRight:
|
|
38
|
-
paddingLeft:
|
|
35
|
+
paddingRight: use_video_controls_resize_js_1.X_PADDING,
|
|
36
|
+
paddingLeft: use_video_controls_resize_js_1.X_PADDING,
|
|
39
37
|
flexDirection: 'column',
|
|
40
38
|
transition: 'opacity 0.3s',
|
|
41
39
|
};
|
|
@@ -75,7 +73,7 @@ const flex1 = {
|
|
|
75
73
|
};
|
|
76
74
|
const fullscreen = {};
|
|
77
75
|
const PlayPauseButton = ({ playing }) => playing ? (0, jsx_runtime_1.jsx)(icons_js_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_js_1.PlayIcon, {});
|
|
78
|
-
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, }) => {
|
|
76
|
+
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, alwaysShowControls, }) => {
|
|
79
77
|
const playButtonRef = (0, react_1.useRef)(null);
|
|
80
78
|
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
81
79
|
const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
|
|
@@ -103,12 +101,12 @@ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVo
|
|
|
103
101
|
});
|
|
104
102
|
const containerCss = (0, react_1.useMemo)(() => {
|
|
105
103
|
// Hide if playing and mouse outside
|
|
106
|
-
const shouldShow = hovered || !player.playing || shouldShowInitially;
|
|
104
|
+
const shouldShow = hovered || !player.playing || shouldShowInitially || alwaysShowControls;
|
|
107
105
|
return {
|
|
108
106
|
...containerStyle,
|
|
109
107
|
opacity: Number(shouldShow),
|
|
110
108
|
};
|
|
111
|
-
}, [hovered, shouldShowInitially, player.playing]);
|
|
109
|
+
}, [hovered, shouldShowInitially, player.playing, alwaysShowControls]);
|
|
112
110
|
(0, react_1.useEffect)(() => {
|
|
113
111
|
if (playButtonRef.current && spaceKeyToPlayOrPause) {
|
|
114
112
|
// This switches focus to play button when player.playing flag changes
|
package/dist/cjs/PlayerUI.d.ts
CHANGED
|
@@ -34,5 +34,6 @@ declare const _default: React.ForwardRefExoticComponent<{
|
|
|
34
34
|
initiallyShowControls: number | boolean;
|
|
35
35
|
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
36
36
|
renderFullscreen: RenderFullscreenButton | null;
|
|
37
|
+
alwaysShowControls: boolean;
|
|
37
38
|
} & React.RefAttributes<PlayerRef>>;
|
|
38
39
|
export default _default;
|
package/dist/cjs/PlayerUI.js
CHANGED
|
@@ -41,7 +41,7 @@ if (reactVersion === '0') {
|
|
|
41
41
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
42
42
|
}
|
|
43
43
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
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) => {
|
|
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, alwaysShowControls, }, ref) => {
|
|
45
45
|
var _a, _b, _c, _d, _e;
|
|
46
46
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
47
47
|
const video = remotion_1.Internals.useVideo();
|
|
@@ -299,7 +299,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
299
299
|
showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
|
|
300
300
|
showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
|
|
301
301
|
].some(Boolean);
|
|
302
|
-
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_js_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...((_d = inputProps) !== null && _d !== void 0 ? _d : {}) }) })) : 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_js_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, initiallyShowControls: initiallyShowControls, playerWidth: (_e = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _e !== void 0 ? _e : 0, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton })) : null] }));
|
|
302
|
+
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_js_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...((_d = inputProps) !== null && _d !== void 0 ? _d : {}) }) })) : 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_js_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, initiallyShowControls: initiallyShowControls, playerWidth: (_e = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _e !== void 0 ? _e : 0, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton, alwaysShowControls: alwaysShowControls })) : null] }));
|
|
303
303
|
if (is_node_js_1.IS_NODE && !doesReactVersionSupportSuspense) {
|
|
304
304
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
305
305
|
}
|
package/dist/cjs/Thumbnail.d.ts
CHANGED
|
@@ -16,5 +16,9 @@ declare type ThumbnailProps<T> = PropsIfHasProps<T> & CompProps<T> & {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
};
|
|
18
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
|
+
/**
|
|
20
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a single frame of a video.
|
|
21
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/thumbnail)
|
|
22
|
+
*/
|
|
19
23
|
export declare const Thumbnail: <T>(props: ThumbnailProps<T> & import("react").RefAttributes<ThumbnailMethods>) => React.ReactElement | null;
|
|
20
24
|
export {};
|
package/dist/cjs/Thumbnail.js
CHANGED
|
@@ -39,4 +39,8 @@ const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, com
|
|
|
39
39
|
};
|
|
40
40
|
exports.ThumbnailFn = ThumbnailFn;
|
|
41
41
|
const forward = react_1.forwardRef;
|
|
42
|
+
/**
|
|
43
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a single frame of a video.
|
|
44
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/thumbnail)
|
|
45
|
+
*/
|
|
42
46
|
exports.Thumbnail = forward(exports.ThumbnailFn);
|
|
@@ -2,6 +2,8 @@ declare type Info = {
|
|
|
2
2
|
maxTimeLabelWidth: number | null;
|
|
3
3
|
displayVerticalVolumeSlider: boolean;
|
|
4
4
|
};
|
|
5
|
+
export declare const X_SPACER = 10;
|
|
6
|
+
export declare const X_PADDING = 12;
|
|
5
7
|
export declare const useVideoControlsResize: ({ allowFullscreen: allowFullScreen, playerWidth, }: {
|
|
6
8
|
allowFullscreen: boolean;
|
|
7
9
|
playerWidth: number;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useVideoControlsResize = void 0;
|
|
3
|
+
exports.useVideoControlsResize = exports.X_PADDING = exports.X_SPACER = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const icons_js_1 = require("./icons.js");
|
|
6
6
|
const MediaVolumeSlider_js_1 = require("./MediaVolumeSlider.js");
|
|
7
|
-
|
|
7
|
+
exports.X_SPACER = 10;
|
|
8
|
+
exports.X_PADDING = 12;
|
|
8
9
|
const useVideoControlsResize = ({ allowFullscreen: allowFullScreen, playerWidth, }) => {
|
|
9
10
|
const resizeInfo = (0, react_1.useMemo)(() => {
|
|
10
11
|
const playPauseIconSize = icons_js_1.ICON_SIZE;
|
|
@@ -13,8 +14,8 @@ const useVideoControlsResize = ({ allowFullscreen: allowFullScreen, playerWidth,
|
|
|
13
14
|
const elementsSize = volumeIconSize +
|
|
14
15
|
playPauseIconSize +
|
|
15
16
|
_fullscreenIconSize +
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
exports.X_PADDING * 2 +
|
|
18
|
+
exports.X_SPACER * 2;
|
|
18
19
|
const maxTimeLabelWidth = playerWidth - elementsSize;
|
|
19
20
|
const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
|
|
20
21
|
const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - MediaVolumeSlider_js_1.VOLUME_SLIDER_WIDTH;
|
package/dist/esm/Player.d.ts
CHANGED
|
@@ -38,6 +38,11 @@ export declare type PlayerProps<T> = {
|
|
|
38
38
|
initiallyShowControls?: number | boolean;
|
|
39
39
|
renderPlayPauseButton?: RenderPlayPauseButton;
|
|
40
40
|
renderFullscreenButton?: RenderFullscreenButton;
|
|
41
|
+
alwaysShowControls?: boolean;
|
|
41
42
|
} & PropsIfHasProps<T> & CompProps<T>;
|
|
42
43
|
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
|
|
44
|
+
/**
|
|
45
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
|
|
46
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/player)
|
|
47
|
+
*/
|
|
43
48
|
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
|
package/dist/esm/Player.js
CHANGED
|
@@ -15,7 +15,7 @@ export const componentOrNullIfLazy = (props) => {
|
|
|
15
15
|
}
|
|
16
16
|
return null;
|
|
17
17
|
};
|
|
18
|
-
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, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, ...componentProps }, ref) => {
|
|
18
|
+
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, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, alwaysShowControls = false, ...componentProps }, ref) => {
|
|
19
19
|
if (typeof window !== 'undefined') {
|
|
20
20
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
21
21
|
useLayoutEffect(() => {
|
|
@@ -130,7 +130,11 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
130
130
|
}
|
|
131
131
|
return (_jsx(Internals.IsPlayerContextProvider, { children: _jsx(SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, children: _jsx(Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: _jsx(PlayerEventEmitterContext.Provider, { value: emitter, children: _jsx(PlayerUI, { 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'
|
|
132
132
|
? clickToPlay
|
|
133
|
-
: 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 }) }) }) }) }));
|
|
133
|
+
: 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, alwaysShowControls: alwaysShowControls }) }) }) }) }));
|
|
134
134
|
};
|
|
135
135
|
const forward = forwardRef;
|
|
136
|
+
/**
|
|
137
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
|
|
138
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/player)
|
|
139
|
+
*/
|
|
136
140
|
export const Player = forward(PlayerFn);
|
|
@@ -7,8 +7,6 @@ export declare type RenderPlayPauseButton = (props: {
|
|
|
7
7
|
export declare type RenderFullscreenButton = (props: {
|
|
8
8
|
isFullscreen: boolean;
|
|
9
9
|
}) => ReactNode;
|
|
10
|
-
export declare const X_SPACER = 10;
|
|
11
|
-
export declare const X_PADDING = 12;
|
|
12
10
|
declare global {
|
|
13
11
|
interface Document {
|
|
14
12
|
webkitFullscreenEnabled?: boolean;
|
|
@@ -38,4 +36,5 @@ export declare const Controls: React.FC<{
|
|
|
38
36
|
playerWidth: number;
|
|
39
37
|
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
40
38
|
renderFullscreenButton: RenderFullscreenButton | null;
|
|
39
|
+
alwaysShowControls: boolean;
|
|
41
40
|
}>;
|
|
@@ -5,9 +5,7 @@ import { formatTime } from './format-time.js';
|
|
|
5
5
|
import { FullscreenIcon, PauseIcon, PlayIcon } from './icons.js';
|
|
6
6
|
import { MediaVolumeSlider } from './MediaVolumeSlider.js';
|
|
7
7
|
import { PlayerSeekBar } from './PlayerSeekBar.js';
|
|
8
|
-
import { useVideoControlsResize } from './use-video-controls-resize.js';
|
|
9
|
-
export const X_SPACER = 10;
|
|
10
|
-
export const X_PADDING = 12;
|
|
8
|
+
import { useVideoControlsResize, X_PADDING } from './use-video-controls-resize.js';
|
|
11
9
|
const gradientSteps = [
|
|
12
10
|
0, 0.013, 0.049, 0.104, 0.175, 0.259, 0.352, 0.45, 0.55, 0.648, 0.741, 0.825,
|
|
13
11
|
0.896, 0.951, 0.987,
|
|
@@ -72,7 +70,7 @@ const flex1 = {
|
|
|
72
70
|
};
|
|
73
71
|
const fullscreen = {};
|
|
74
72
|
const PlayPauseButton = ({ playing }) => playing ? _jsx(PauseIcon, {}) : _jsx(PlayIcon, {});
|
|
75
|
-
export const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, }) => {
|
|
73
|
+
export const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, alwaysShowControls, }) => {
|
|
76
74
|
const playButtonRef = useRef(null);
|
|
77
75
|
const frame = Internals.Timeline.useTimelinePosition();
|
|
78
76
|
const [supportsFullscreen, setSupportsFullscreen] = useState(false);
|
|
@@ -100,12 +98,12 @@ export const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player,
|
|
|
100
98
|
});
|
|
101
99
|
const containerCss = useMemo(() => {
|
|
102
100
|
// Hide if playing and mouse outside
|
|
103
|
-
const shouldShow = hovered || !player.playing || shouldShowInitially;
|
|
101
|
+
const shouldShow = hovered || !player.playing || shouldShowInitially || alwaysShowControls;
|
|
104
102
|
return {
|
|
105
103
|
...containerStyle,
|
|
106
104
|
opacity: Number(shouldShow),
|
|
107
105
|
};
|
|
108
|
-
}, [hovered, shouldShowInitially, player.playing]);
|
|
106
|
+
}, [hovered, shouldShowInitially, player.playing, alwaysShowControls]);
|
|
109
107
|
useEffect(() => {
|
|
110
108
|
if (playButtonRef.current && spaceKeyToPlayOrPause) {
|
|
111
109
|
// This switches focus to play button when player.playing flag changes
|
package/dist/esm/PlayerUI.d.ts
CHANGED
|
@@ -34,5 +34,6 @@ declare const _default: React.ForwardRefExoticComponent<{
|
|
|
34
34
|
initiallyShowControls: number | boolean;
|
|
35
35
|
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
36
36
|
renderFullscreen: RenderFullscreenButton | null;
|
|
37
|
+
alwaysShowControls: boolean;
|
|
37
38
|
} & React.RefAttributes<PlayerRef>>;
|
|
38
39
|
export default _default;
|
package/dist/esm/PlayerUI.js
CHANGED
|
@@ -16,7 +16,7 @@ if (reactVersion === '0') {
|
|
|
16
16
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
17
17
|
}
|
|
18
18
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
19
|
-
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) => {
|
|
19
|
+
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, alwaysShowControls, }, ref) => {
|
|
20
20
|
var _a, _b, _c, _d, _e;
|
|
21
21
|
const config = Internals.useUnsafeVideoConfig();
|
|
22
22
|
const video = Internals.useVideo();
|
|
@@ -274,7 +274,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
274
274
|
showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
|
|
275
275
|
showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
|
|
276
276
|
].some(Boolean);
|
|
277
|
-
const content = (_jsxs(_Fragment, { children: [_jsx("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: _jsx("div", { style: containerStyle, className: PLAYER_CSS_CLASSNAME, children: VideoComponent ? (_jsx(ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: _jsx(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...((_d = inputProps) !== null && _d !== void 0 ? _d : {}) }) })) : null }) }), shouldShowPoster ? (_jsx("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? (_jsx(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, initiallyShowControls: initiallyShowControls, playerWidth: (_e = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _e !== void 0 ? _e : 0, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton })) : null] }));
|
|
277
|
+
const content = (_jsxs(_Fragment, { children: [_jsx("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: _jsx("div", { style: containerStyle, className: PLAYER_CSS_CLASSNAME, children: VideoComponent ? (_jsx(ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: _jsx(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...((_d = inputProps) !== null && _d !== void 0 ? _d : {}) }) })) : null }) }), shouldShowPoster ? (_jsx("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? (_jsx(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, initiallyShowControls: initiallyShowControls, playerWidth: (_e = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _e !== void 0 ? _e : 0, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton, alwaysShowControls: alwaysShowControls })) : null] }));
|
|
278
278
|
if (IS_NODE && !doesReactVersionSupportSuspense) {
|
|
279
279
|
return (_jsx("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
280
280
|
}
|
package/dist/esm/Thumbnail.d.ts
CHANGED
|
@@ -16,5 +16,9 @@ declare type ThumbnailProps<T> = PropsIfHasProps<T> & CompProps<T> & {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
};
|
|
18
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
|
+
/**
|
|
20
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a single frame of a video.
|
|
21
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/thumbnail)
|
|
22
|
+
*/
|
|
19
23
|
export declare const Thumbnail: <T>(props: ThumbnailProps<T> & import("react").RefAttributes<ThumbnailMethods>) => React.ReactElement | null;
|
|
20
24
|
export {};
|
package/dist/esm/Thumbnail.js
CHANGED
|
@@ -32,4 +32,8 @@ export const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeig
|
|
|
32
32
|
return (_jsx(Internals.IsPlayerContextProvider, { children: _jsx(SharedPlayerContexts, { timelineContext: timelineState, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: 0, children: _jsx(ThumbnailEmitterContext.Provider, { value: emitter, children: _jsx(ThumbnailUI, { className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style }) }) }) }));
|
|
33
33
|
};
|
|
34
34
|
const forward = forwardRef;
|
|
35
|
+
/**
|
|
36
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a single frame of a video.
|
|
37
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/thumbnail)
|
|
38
|
+
*/
|
|
35
39
|
export const Thumbnail = forward(ThumbnailFn);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { CallbackListener, PlayerEventTypes } from './event-emitter.js';
|
|
3
2
|
import { PlayerEmitter } from './event-emitter.js';
|
|
4
3
|
export { Player, PlayerProps } from './Player.js';
|
|
@@ -57,5 +56,5 @@ export declare const PlayerInternals: {
|
|
|
57
56
|
compositionWidth: number;
|
|
58
57
|
compositionHeight: number;
|
|
59
58
|
canvasSize: import("./utils/use-element-size.js").Size;
|
|
60
|
-
}) =>
|
|
59
|
+
}) => any;
|
|
61
60
|
};
|