@remotion/player 4.0.0-alpha13 → 4.0.0-alpha16
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/PlaybackrateControl.d.ts +3 -0
- package/dist/cjs/PlaybackrateControl.js +50 -23
- package/dist/cjs/Player.d.ts +2 -2
- package/dist/cjs/PlayerControls.d.ts +4 -3
- package/dist/cjs/PlayerControls.js +7 -17
- package/dist/cjs/PlayerUI.d.ts +3 -3
- package/dist/cjs/PlayerUI.js +2 -2
- package/dist/cjs/Thumbnail.d.ts +1 -1
- package/dist/cjs/calculate-scale.d.ts +1 -1
- package/dist/cjs/event-emitter.d.ts +16 -16
- package/dist/cjs/icons.d.ts +0 -3
- package/dist/cjs/icons.js +1 -5
- package/dist/cjs/player-methods.d.ts +4 -4
- package/dist/cjs/use-player.d.ts +1 -1
- package/dist/cjs/use-thumbnail.d.ts +1 -1
- package/dist/cjs/use-video-controls-resize.d.ts +1 -1
- package/dist/cjs/utils/cancellable-promise.d.ts +1 -1
- package/dist/cjs/utils/preview-size.d.ts +2 -2
- package/dist/cjs/utils/props-if-has-props.d.ts +1 -1
- package/dist/cjs/utils/use-element-size.d.ts +1 -1
- package/dist/esm/PlaybackrateControl.d.ts +3 -0
- package/dist/esm/Player.d.ts +2 -2
- package/dist/esm/PlayerControls.d.ts +4 -3
- package/dist/esm/PlayerUI.d.ts +3 -3
- package/dist/esm/Thumbnail.d.ts +1 -1
- package/dist/esm/calculate-scale.d.ts +1 -1
- package/dist/esm/event-emitter.d.ts +16 -16
- package/dist/esm/icons.d.ts +0 -3
- package/dist/esm/index.mjs +58 -43
- package/dist/esm/player-methods.d.ts +4 -4
- package/dist/esm/use-player.d.ts +1 -1
- package/dist/esm/use-thumbnail.d.ts +1 -1
- package/dist/esm/use-video-controls-resize.d.ts +1 -1
- package/dist/esm/utils/cancellable-promise.d.ts +1 -1
- package/dist/esm/utils/preview-size.d.ts +2 -2
- package/dist/esm/utils/props-if-has-props.d.ts +1 -1
- package/dist/esm/utils/use-element-size.d.ts +1 -1
- package/dist/tsconfig-esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { Size } from './utils/use-element-size.js';
|
|
2
3
|
export declare const Checkmark: () => JSX.Element;
|
|
4
|
+
export declare const playerButtonStyle: React.CSSProperties;
|
|
3
5
|
export declare const PlaybackrateControl: React.FC<{
|
|
4
6
|
playbackRates: number[];
|
|
7
|
+
canvasSize: Size;
|
|
5
8
|
}>;
|
|
@@ -3,23 +3,15 @@ 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.PlaybackrateControl = exports.Checkmark = void 0;
|
|
6
|
+
exports.PlaybackrateControl = exports.playerButtonStyle = exports.Checkmark = 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");
|
|
10
|
-
const icons_js_1 = require("./icons.js");
|
|
11
10
|
const use_component_visible_js_1 = __importDefault(require("./utils/use-component-visible.js"));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
bottom: 35,
|
|
17
|
-
background: '#fff',
|
|
18
|
-
borderRadius: 4,
|
|
19
|
-
overflow: 'hidden',
|
|
20
|
-
color: 'black',
|
|
21
|
-
textAlign: 'left',
|
|
22
|
-
};
|
|
11
|
+
// To align
|
|
12
|
+
const BOTTOM = 35;
|
|
13
|
+
// Arbitrary to clamp the height of the popup
|
|
14
|
+
const THRESHOLD = 70;
|
|
23
15
|
const rateDiv = {
|
|
24
16
|
height: 30,
|
|
25
17
|
paddingRight: 15,
|
|
@@ -40,7 +32,7 @@ const checkmarkStyle = {
|
|
|
40
32
|
};
|
|
41
33
|
const Checkmark = () => ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 512 512", style: checkmarkStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", d: "M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z" }) }));
|
|
42
34
|
exports.Checkmark = Checkmark;
|
|
43
|
-
const PlaybackPopup = ({ setIsComponentVisible, playbackRates }) => {
|
|
35
|
+
const PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
44
36
|
const { setPlaybackRate, playbackRate } = (0, react_1.useContext)(remotion_1.Internals.Timeline.TimelineContext);
|
|
45
37
|
const [keyboardSelectedRate, setKeyboardSelectedRate] = (0, react_1.useState)(playbackRate);
|
|
46
38
|
(0, react_1.useEffect)(() => {
|
|
@@ -89,6 +81,20 @@ const PlaybackPopup = ({ setIsComponentVisible, playbackRates }) => {
|
|
|
89
81
|
setPlaybackRate(rate);
|
|
90
82
|
setIsComponentVisible(false);
|
|
91
83
|
}, [setIsComponentVisible, setPlaybackRate]);
|
|
84
|
+
const playbackPopup = (0, react_1.useMemo)(() => {
|
|
85
|
+
return {
|
|
86
|
+
position: 'absolute',
|
|
87
|
+
right: 0,
|
|
88
|
+
width: 125,
|
|
89
|
+
maxHeight: canvasSize.height - THRESHOLD - BOTTOM,
|
|
90
|
+
bottom: 35,
|
|
91
|
+
background: '#fff',
|
|
92
|
+
borderRadius: 4,
|
|
93
|
+
overflow: 'auto',
|
|
94
|
+
color: 'black',
|
|
95
|
+
textAlign: 'left',
|
|
96
|
+
};
|
|
97
|
+
}, [canvasSize.height]);
|
|
92
98
|
return ((0, jsx_runtime_1.jsx)("div", { style: playbackPopup, children: playbackRates.map((rate) => {
|
|
93
99
|
return ((0, jsx_runtime_1.jsx)(PlaybackrateOption, { selectedRate: playbackRate, onSelect: onSelect, rate: rate, keyboardSelectedRate: keyboardSelectedRate }, rate));
|
|
94
100
|
}) }));
|
|
@@ -114,23 +120,44 @@ const PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate
|
|
|
114
120
|
}, [hovered, keyboardSelectedRate, rate]);
|
|
115
121
|
return ((0, jsx_runtime_1.jsxs)("div", { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, tabIndex: 0, style: actualStyle, onClick: onClick, children: [(0, jsx_runtime_1.jsx)("div", { style: checkmarkContainer, children: rate === selectedRate ? (0, jsx_runtime_1.jsx)(exports.Checkmark, {}) : null }), rate.toFixed(1), "x"] }, rate));
|
|
116
122
|
};
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
const label = {
|
|
124
|
+
fontSize: 13,
|
|
125
|
+
fontWeight: 'bold',
|
|
126
|
+
color: 'white',
|
|
127
|
+
border: '2px solid white',
|
|
128
|
+
borderRadius: 20,
|
|
129
|
+
paddingLeft: 8,
|
|
130
|
+
paddingRight: 8,
|
|
131
|
+
paddingTop: 2,
|
|
132
|
+
paddingBottom: 2,
|
|
133
|
+
};
|
|
134
|
+
exports.playerButtonStyle = {
|
|
135
|
+
appearance: 'none',
|
|
136
|
+
backgroundColor: 'transparent',
|
|
122
137
|
border: 'none',
|
|
123
|
-
background: 'none',
|
|
124
|
-
height: 36,
|
|
125
138
|
cursor: 'pointer',
|
|
139
|
+
paddingLeft: 0,
|
|
140
|
+
paddingRight: 0,
|
|
141
|
+
paddingTop: 6,
|
|
142
|
+
paddingBottom: 6,
|
|
143
|
+
height: 37,
|
|
144
|
+
display: 'inline-flex',
|
|
145
|
+
marginBottom: 0,
|
|
146
|
+
marginTop: 0,
|
|
147
|
+
alignItems: 'center',
|
|
148
|
+
};
|
|
149
|
+
const button = {
|
|
150
|
+
...exports.playerButtonStyle,
|
|
151
|
+
position: 'relative',
|
|
126
152
|
};
|
|
127
|
-
const PlaybackrateControl = ({ playbackRates }) => {
|
|
153
|
+
const PlaybackrateControl = ({ playbackRates, canvasSize }) => {
|
|
128
154
|
const { ref, isComponentVisible, setIsComponentVisible } = (0, use_component_visible_js_1.default)(false);
|
|
155
|
+
const { playbackRate } = (0, react_1.useContext)(remotion_1.Internals.Timeline.TimelineContext);
|
|
129
156
|
const onClick = (0, react_1.useCallback)((e) => {
|
|
130
157
|
e.stopPropagation();
|
|
131
158
|
e.preventDefault();
|
|
132
159
|
setIsComponentVisible(!isComponentVisible);
|
|
133
160
|
}, [isComponentVisible, setIsComponentVisible]);
|
|
134
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, children: (0, jsx_runtime_1.jsxs)("button", { type: "button", "aria-label": "Change playback rate", style:
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, children: (0, jsx_runtime_1.jsxs)("button", { type: "button", "aria-label": "Change playback rate", style: button, onClick: onClick, children: [(0, jsx_runtime_1.jsxs)("div", { style: label, children: [playbackRate, "x"] }), isComponentVisible && ((0, jsx_runtime_1.jsx)(PlaybackPopup, { canvasSize: canvasSize, playbackRates: playbackRates, setIsComponentVisible: setIsComponentVisible }))] }) }));
|
|
135
162
|
};
|
|
136
163
|
exports.PlaybackrateControl = PlaybackrateControl;
|
package/dist/cjs/Player.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import type { PlayerRef } from './player-methods.js';
|
|
|
6
6
|
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls.js';
|
|
7
7
|
import type { RenderLoading, RenderPoster } from './PlayerUI.js';
|
|
8
8
|
import type { PropsIfHasProps } from './utils/props-if-has-props.js';
|
|
9
|
-
export
|
|
9
|
+
export type ErrorFallback = (info: {
|
|
10
10
|
error: Error;
|
|
11
11
|
}) => React.ReactNode;
|
|
12
|
-
export
|
|
12
|
+
export type PlayerProps<Schema extends AnyZodObject, Props> = {
|
|
13
13
|
durationInFrames: number;
|
|
14
14
|
compositionWidth: number;
|
|
15
15
|
compositionHeight: number;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { MouseEventHandler, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { usePlayer } from './use-player.js';
|
|
4
|
-
|
|
4
|
+
import type { Size } from './utils/use-element-size.js';
|
|
5
|
+
export type RenderPlayPauseButton = (props: {
|
|
5
6
|
playing: boolean;
|
|
6
7
|
}) => ReactNode;
|
|
7
|
-
export
|
|
8
|
+
export type RenderFullscreenButton = (props: {
|
|
8
9
|
isFullscreen: boolean;
|
|
9
10
|
}) => ReactNode;
|
|
10
11
|
declare global {
|
|
@@ -33,7 +34,7 @@ export declare const Controls: React.FC<{
|
|
|
33
34
|
inFrame: number | null;
|
|
34
35
|
outFrame: number | null;
|
|
35
36
|
initiallyShowControls: number | boolean;
|
|
36
|
-
|
|
37
|
+
canvasSize: Size | null;
|
|
37
38
|
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
38
39
|
renderFullscreenButton: RenderFullscreenButton | null;
|
|
39
40
|
alwaysShowControls: boolean;
|
|
@@ -38,20 +38,6 @@ const containerStyle = {
|
|
|
38
38
|
flexDirection: 'column',
|
|
39
39
|
transition: 'opacity 0.3s',
|
|
40
40
|
};
|
|
41
|
-
const buttonStyle = {
|
|
42
|
-
appearance: 'none',
|
|
43
|
-
backgroundColor: 'transparent',
|
|
44
|
-
border: 'none',
|
|
45
|
-
cursor: 'pointer',
|
|
46
|
-
paddingLeft: 0,
|
|
47
|
-
paddingRight: 0,
|
|
48
|
-
paddingTop: 6,
|
|
49
|
-
paddingBottom: 6,
|
|
50
|
-
height: 37,
|
|
51
|
-
display: 'inline',
|
|
52
|
-
marginBottom: 0,
|
|
53
|
-
marginTop: 0,
|
|
54
|
-
};
|
|
55
41
|
const controlsRow = {
|
|
56
42
|
display: 'flex',
|
|
57
43
|
flexDirection: 'row',
|
|
@@ -77,11 +63,15 @@ const flex1 = {
|
|
|
77
63
|
};
|
|
78
64
|
const fullscreen = {};
|
|
79
65
|
const PlayPauseButton = ({ playing }) => playing ? (0, jsx_runtime_1.jsx)(icons_js_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_js_1.PlayIcon, {});
|
|
80
|
-
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls,
|
|
66
|
+
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, canvasSize, renderPlayPauseButton, renderFullscreenButton, alwaysShowControls, showPlaybackRateControl, }) => {
|
|
67
|
+
var _a;
|
|
81
68
|
const playButtonRef = (0, react_1.useRef)(null);
|
|
82
69
|
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
83
70
|
const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
|
|
84
|
-
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = (0, use_video_controls_resize_js_1.useVideoControlsResize)({
|
|
71
|
+
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = (0, use_video_controls_resize_js_1.useVideoControlsResize)({
|
|
72
|
+
allowFullscreen,
|
|
73
|
+
playerWidth: (_a = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _a !== void 0 ? _a : 0,
|
|
74
|
+
});
|
|
85
75
|
const [shouldShowInitially, setInitiallyShowControls] = (0, react_1.useState)(() => {
|
|
86
76
|
if (typeof initiallyShowControls === 'boolean') {
|
|
87
77
|
return initiallyShowControls;
|
|
@@ -164,7 +154,7 @@ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVo
|
|
|
164
154
|
}
|
|
165
155
|
return null;
|
|
166
156
|
}, [showPlaybackRateControl]);
|
|
167
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style:
|
|
157
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: PlaybackrateControl_js_1.playerButtonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: renderPlayPauseButton === null ? ((0, jsx_runtime_1.jsx)(PlayPauseButton, { playing: player.playing })) : (renderPlayPauseButton({ playing: player.playing })) }), showVolumeControls ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsx)(MediaVolumeSlider_js_1.MediaVolumeSlider, { displayVerticalVolumeSlider: displayVerticalVolumeSlider })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_js_1.formatTime)(frame / fps), " / ", (0, format_time_js_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), playbackRates && canvasSize && ((0, jsx_runtime_1.jsx)(PlaybackrateControl_js_1.PlaybackrateControl, { canvasSize: canvasSize, playbackRates: playbackRates })), playbackRates && supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("div", { style: xSpacer })) : null, (0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: PlaybackrateControl_js_1.playerButtonStyle, onClick: isFullscreen
|
|
168
158
|
? onExitFullscreenButtonClick
|
|
169
159
|
: onFullscreenButtonClick, children: renderFullscreenButton === null ? ((0, jsx_runtime_1.jsx)(icons_js_1.FullscreenIcon, { isFullscreen: isFullscreen })) : (renderFullscreenButton({ isFullscreen })) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_js_1.PlayerSeekBar, { onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, durationInFrames: durationInFrames, inFrame: inFrame, outFrame: outFrame })] }));
|
|
170
160
|
};
|
package/dist/cjs/PlayerUI.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PlayerRef } from './player-methods.js';
|
|
3
3
|
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls.js';
|
|
4
|
-
export
|
|
4
|
+
export type ErrorFallback = (info: {
|
|
5
5
|
error: Error;
|
|
6
6
|
}) => React.ReactNode;
|
|
7
|
-
export
|
|
7
|
+
export type RenderLoading = (canvas: {
|
|
8
8
|
height: number;
|
|
9
9
|
width: number;
|
|
10
10
|
}) => React.ReactNode;
|
|
11
|
-
export
|
|
11
|
+
export type RenderPoster = RenderLoading;
|
|
12
12
|
declare const _default: React.ForwardRefExoticComponent<{
|
|
13
13
|
controls: boolean;
|
|
14
14
|
loop: boolean;
|
package/dist/cjs/PlayerUI.js
CHANGED
|
@@ -42,7 +42,7 @@ if (reactVersion === '0') {
|
|
|
42
42
|
}
|
|
43
43
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
44
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, showPlaybackRateControl, }, ref) => {
|
|
45
|
-
var _a, _b, _c
|
|
45
|
+
var _a, _b, _c;
|
|
46
46
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
47
47
|
const video = remotion_1.Internals.useVideo();
|
|
48
48
|
const container = (0, react_1.useRef)(null);
|
|
@@ -317,7 +317,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
317
317
|
showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
|
|
318
318
|
showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
|
|
319
319
|
].some(Boolean);
|
|
320
|
-
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 : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) })) : 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,
|
|
320
|
+
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 : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) })) : 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, canvasSize: canvasSize, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton, alwaysShowControls: alwaysShowControls, showPlaybackRateControl: showPlaybackRateControl })) : null] }));
|
|
321
321
|
if (is_node_js_1.IS_NODE && !doesReactVersionSupportSuspense) {
|
|
322
322
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
323
323
|
}
|
package/dist/cjs/Thumbnail.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { AnyZodObject } from 'zod';
|
|
|
4
4
|
import type { ThumbnailMethods } from './player-methods.js';
|
|
5
5
|
import type { ErrorFallback, RenderLoading } from './PlayerUI.js';
|
|
6
6
|
import type { PropsIfHasProps } from './utils/props-if-has-props.js';
|
|
7
|
-
|
|
7
|
+
type ThumbnailProps<Schema extends AnyZodObject, Props> = PropsIfHasProps<Schema, Props> & CompProps<Schema> & {
|
|
8
8
|
frameToDisplay: number;
|
|
9
9
|
style?: CSSProperties;
|
|
10
10
|
durationInFrames: number;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
type SeekPayload = {
|
|
2
2
|
frame: number;
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
type ErrorPayload = {
|
|
5
5
|
error: Error;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type TimeUpdateEventPayload = {
|
|
8
8
|
frame: number;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type FrameUpdateEventPayload = {
|
|
11
11
|
frame: number;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type RateChangeEventPayload = {
|
|
14
14
|
playbackRate: number;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type ScaleChangeEventPayload = {
|
|
17
17
|
scale: number;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type VolumeChangeEventPayload = {
|
|
20
20
|
volume: number;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type FullscreenChangeEventPayload = {
|
|
23
23
|
isFullscreen: boolean;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
type MuteChangeEventPayload = {
|
|
26
26
|
isMuted: boolean;
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
type PlayerStateEventMap = {
|
|
29
29
|
seeked: SeekPayload;
|
|
30
30
|
pause: undefined;
|
|
31
31
|
play: undefined;
|
|
@@ -39,18 +39,18 @@ declare type PlayerStateEventMap = {
|
|
|
39
39
|
fullscreenchange: FullscreenChangeEventPayload;
|
|
40
40
|
mutechange: MuteChangeEventPayload;
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
type ThumbnailStateEventMap = {
|
|
43
43
|
error: ErrorPayload;
|
|
44
44
|
};
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
45
|
+
export type PlayerEventTypes = keyof PlayerStateEventMap;
|
|
46
|
+
export type ThumbnailEventTypes = keyof ThumbnailStateEventMap;
|
|
47
|
+
export type CallbackListener<T extends PlayerEventTypes> = (data: {
|
|
48
48
|
detail: PlayerStateEventMap[T];
|
|
49
49
|
}) => void;
|
|
50
|
-
|
|
50
|
+
type PlayerListeners = {
|
|
51
51
|
[EventType in PlayerEventTypes]: CallbackListener<EventType>[];
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
type ThumbnailListeners = {
|
|
54
54
|
[EventType in ThumbnailEventTypes]: CallbackListener<EventType>[];
|
|
55
55
|
};
|
|
56
56
|
export declare class PlayerEmitter {
|
package/dist/cjs/icons.d.ts
CHANGED
package/dist/cjs/icons.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.VolumeOnIcon = exports.VolumeOffIcon = exports.FullscreenIcon = exports.PauseIcon = exports.PlayIcon = exports.fullscreenIconSize = exports.ICON_SIZE = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
exports.ICON_SIZE = 25;
|
|
6
6
|
exports.fullscreenIconSize = 16;
|
|
@@ -48,7 +48,3 @@ const VolumeOnIcon = () => {
|
|
|
48
48
|
return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M3 10v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71V6.41c0-.89-1.08-1.34-1.71-.71L7 9H4c-.55 0-1 .45-1 1zm13.5 2A4.5 4.5 0 0014 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 4.45v.2c0 .38.25.71.6.85C17.18 6.53 19 9.06 19 12s-1.82 5.47-4.4 6.5c-.36.14-.6.47-.6.85v.2c0 .63.63 1.07 1.21.85C18.6 19.11 21 15.84 21 12s-2.4-7.11-5.79-8.4c-.58-.23-1.21.22-1.21.85z", fill: "#fff" }) }));
|
|
49
49
|
};
|
|
50
50
|
exports.VolumeOnIcon = VolumeOnIcon;
|
|
51
|
-
const SettingsIcon = ({ iconSize }) => {
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", height: iconSize !== null && iconSize !== void 0 ? iconSize : exports.ICON_SIZE, viewBox: "0 0 512 512", style: { fill: '#fff' }, children: (0, jsx_runtime_1.jsx)("path", { d: "M495.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z" }) }));
|
|
53
|
-
};
|
|
54
|
-
exports.SettingsIcon = SettingsIcon;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { SyntheticEvent } from 'react';
|
|
2
2
|
import type { PlayerEmitter } from './event-emitter.js';
|
|
3
|
-
export
|
|
3
|
+
export type ThumbnailMethods = {
|
|
4
4
|
getContainerNode: () => HTMLDivElement | null;
|
|
5
5
|
getScale: () => number;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type PlayerMethods = ThumbnailMethods & {
|
|
8
8
|
play: (e?: SyntheticEvent) => void;
|
|
9
9
|
pause: () => void;
|
|
10
10
|
toggle: (e?: SyntheticEvent) => void;
|
|
@@ -20,5 +20,5 @@ export declare type PlayerMethods = ThumbnailMethods & {
|
|
|
20
20
|
mute: () => void;
|
|
21
21
|
unmute: () => void;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
24
|
-
export
|
|
23
|
+
export type ThumbnailRef = PlayerEmitter & ThumbnailMethods;
|
|
24
|
+
export type PlayerRef = PlayerEmitter & PlayerMethods;
|
package/dist/cjs/use-player.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SyntheticEvent } from 'react';
|
|
2
2
|
import type { PlayerEmitter } from './event-emitter.js';
|
|
3
|
-
|
|
3
|
+
type UsePlayerMethods = {
|
|
4
4
|
frameBack: (frames: number) => void;
|
|
5
5
|
frameForward: (frames: number) => void;
|
|
6
6
|
isLastFrame: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyZodObject, z } from 'zod';
|
|
2
|
-
export
|
|
2
|
+
export type PropsIfHasProps<Schema extends AnyZodObject, Props> = AnyZodObject extends Schema ? {} extends Props ? {
|
|
3
3
|
inputProps?: z.infer<Schema> & Props;
|
|
4
4
|
} : {
|
|
5
5
|
inputProps: Props;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { Size } from './utils/use-element-size.js';
|
|
2
3
|
export declare const Checkmark: () => JSX.Element;
|
|
4
|
+
export declare const playerButtonStyle: React.CSSProperties;
|
|
3
5
|
export declare const PlaybackrateControl: React.FC<{
|
|
4
6
|
playbackRates: number[];
|
|
7
|
+
canvasSize: Size;
|
|
5
8
|
}>;
|
package/dist/esm/Player.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import type { PlayerRef } from './player-methods.js';
|
|
|
6
6
|
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls.js';
|
|
7
7
|
import type { RenderLoading, RenderPoster } from './PlayerUI.js';
|
|
8
8
|
import type { PropsIfHasProps } from './utils/props-if-has-props.js';
|
|
9
|
-
export
|
|
9
|
+
export type ErrorFallback = (info: {
|
|
10
10
|
error: Error;
|
|
11
11
|
}) => React.ReactNode;
|
|
12
|
-
export
|
|
12
|
+
export type PlayerProps<Schema extends AnyZodObject, Props> = {
|
|
13
13
|
durationInFrames: number;
|
|
14
14
|
compositionWidth: number;
|
|
15
15
|
compositionHeight: number;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { MouseEventHandler, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { usePlayer } from './use-player.js';
|
|
4
|
-
|
|
4
|
+
import type { Size } from './utils/use-element-size.js';
|
|
5
|
+
export type RenderPlayPauseButton = (props: {
|
|
5
6
|
playing: boolean;
|
|
6
7
|
}) => ReactNode;
|
|
7
|
-
export
|
|
8
|
+
export type RenderFullscreenButton = (props: {
|
|
8
9
|
isFullscreen: boolean;
|
|
9
10
|
}) => ReactNode;
|
|
10
11
|
declare global {
|
|
@@ -33,7 +34,7 @@ export declare const Controls: React.FC<{
|
|
|
33
34
|
inFrame: number | null;
|
|
34
35
|
outFrame: number | null;
|
|
35
36
|
initiallyShowControls: number | boolean;
|
|
36
|
-
|
|
37
|
+
canvasSize: Size | null;
|
|
37
38
|
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
38
39
|
renderFullscreenButton: RenderFullscreenButton | null;
|
|
39
40
|
alwaysShowControls: boolean;
|
package/dist/esm/PlayerUI.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PlayerRef } from './player-methods.js';
|
|
3
3
|
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls.js';
|
|
4
|
-
export
|
|
4
|
+
export type ErrorFallback = (info: {
|
|
5
5
|
error: Error;
|
|
6
6
|
}) => React.ReactNode;
|
|
7
|
-
export
|
|
7
|
+
export type RenderLoading = (canvas: {
|
|
8
8
|
height: number;
|
|
9
9
|
width: number;
|
|
10
10
|
}) => React.ReactNode;
|
|
11
|
-
export
|
|
11
|
+
export type RenderPoster = RenderLoading;
|
|
12
12
|
declare const _default: React.ForwardRefExoticComponent<{
|
|
13
13
|
controls: boolean;
|
|
14
14
|
loop: boolean;
|
package/dist/esm/Thumbnail.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { AnyZodObject } from 'zod';
|
|
|
4
4
|
import type { ThumbnailMethods } from './player-methods.js';
|
|
5
5
|
import type { ErrorFallback, RenderLoading } from './PlayerUI.js';
|
|
6
6
|
import type { PropsIfHasProps } from './utils/props-if-has-props.js';
|
|
7
|
-
|
|
7
|
+
type ThumbnailProps<Schema extends AnyZodObject, Props> = PropsIfHasProps<Schema, Props> & CompProps<Schema> & {
|
|
8
8
|
frameToDisplay: number;
|
|
9
9
|
style?: CSSProperties;
|
|
10
10
|
durationInFrames: number;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
type SeekPayload = {
|
|
2
2
|
frame: number;
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
type ErrorPayload = {
|
|
5
5
|
error: Error;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type TimeUpdateEventPayload = {
|
|
8
8
|
frame: number;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type FrameUpdateEventPayload = {
|
|
11
11
|
frame: number;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type RateChangeEventPayload = {
|
|
14
14
|
playbackRate: number;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type ScaleChangeEventPayload = {
|
|
17
17
|
scale: number;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type VolumeChangeEventPayload = {
|
|
20
20
|
volume: number;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type FullscreenChangeEventPayload = {
|
|
23
23
|
isFullscreen: boolean;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
type MuteChangeEventPayload = {
|
|
26
26
|
isMuted: boolean;
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
type PlayerStateEventMap = {
|
|
29
29
|
seeked: SeekPayload;
|
|
30
30
|
pause: undefined;
|
|
31
31
|
play: undefined;
|
|
@@ -39,18 +39,18 @@ declare type PlayerStateEventMap = {
|
|
|
39
39
|
fullscreenchange: FullscreenChangeEventPayload;
|
|
40
40
|
mutechange: MuteChangeEventPayload;
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
type ThumbnailStateEventMap = {
|
|
43
43
|
error: ErrorPayload;
|
|
44
44
|
};
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
45
|
+
export type PlayerEventTypes = keyof PlayerStateEventMap;
|
|
46
|
+
export type ThumbnailEventTypes = keyof ThumbnailStateEventMap;
|
|
47
|
+
export type CallbackListener<T extends PlayerEventTypes> = (data: {
|
|
48
48
|
detail: PlayerStateEventMap[T];
|
|
49
49
|
}) => void;
|
|
50
|
-
|
|
50
|
+
type PlayerListeners = {
|
|
51
51
|
[EventType in PlayerEventTypes]: CallbackListener<EventType>[];
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
type ThumbnailListeners = {
|
|
54
54
|
[EventType in ThumbnailEventTypes]: CallbackListener<EventType>[];
|
|
55
55
|
};
|
|
56
56
|
export declare class PlayerEmitter {
|