@remotion/player 4.0.0-webhook.27 → 4.1.0-alpha1
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 +8 -8
- package/README.md +1 -1
- package/dist/{MediaVolumeSlider.d.ts → cjs/MediaVolumeSlider.d.ts} +0 -0
- package/dist/{MediaVolumeSlider.js → cjs/MediaVolumeSlider.js} +41 -17
- package/dist/cjs/PlaybackrateControl.d.ts +8 -0
- package/dist/cjs/PlaybackrateControl.js +163 -0
- package/dist/cjs/Player.d.ts +52 -0
- package/dist/{Player.js → cjs/Player.js} +41 -87
- package/dist/{PlayerControls.d.ts → cjs/PlayerControls.d.ts} +14 -5
- package/dist/cjs/PlayerControls.js +161 -0
- package/dist/{PlayerSeekBar.d.ts → cjs/PlayerSeekBar.d.ts} +0 -0
- package/dist/{PlayerSeekBar.js → cjs/PlayerSeekBar.js} +6 -6
- package/dist/{PlayerUI.d.ts → cjs/PlayerUI.d.ts} +13 -12
- package/dist/{PlayerUI.js → cjs/PlayerUI.js} +54 -72
- package/dist/cjs/SharedPlayerContext.d.ts +15 -0
- package/dist/cjs/SharedPlayerContext.js +75 -0
- package/dist/cjs/Thumbnail.d.ts +24 -0
- package/dist/cjs/Thumbnail.js +46 -0
- package/dist/cjs/ThumbnailUI.d.ts +11 -0
- package/dist/cjs/ThumbnailUI.js +107 -0
- package/dist/{calculate-next-frame.d.ts → cjs/calculate-next-frame.d.ts} +0 -0
- package/dist/{calculate-next-frame.js → cjs/calculate-next-frame.js} +0 -0
- package/dist/cjs/calculate-scale.d.ts +39 -0
- package/dist/cjs/calculate-scale.js +85 -0
- package/dist/cjs/emitter-context.d.ts +4 -0
- package/dist/{emitter-context.js → cjs/emitter-context.js} +2 -1
- package/dist/{error-boundary.d.ts → cjs/error-boundary.d.ts} +0 -0
- package/dist/{error-boundary.js → cjs/error-boundary.js} +0 -0
- package/dist/cjs/event-emitter.d.ts +81 -0
- package/dist/{event-emitter.js → cjs/event-emitter.js} +43 -3
- package/dist/{format-time.d.ts → cjs/format-time.d.ts} +0 -0
- package/dist/{format-time.js → cjs/format-time.js} +0 -0
- package/dist/{icons.d.ts → cjs/icons.d.ts} +1 -1
- package/dist/{icons.js → cjs/icons.js} +4 -4
- package/dist/{index.d.ts → cjs/index.d.ts} +13 -11
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/is-backgrounded.d.ts +2 -0
- package/dist/cjs/is-backgrounded.js +24 -0
- package/dist/{player-css-classname.d.ts → cjs/player-css-classname.d.ts} +0 -0
- package/dist/{player-css-classname.js → cjs/player-css-classname.js} +0 -0
- package/dist/{player-methods.d.ts → cjs/player-methods.d.ts} +9 -6
- package/dist/{player-methods.js → cjs/player-methods.js} +0 -0
- package/dist/{test → cjs/test}/index.test.d.ts +0 -0
- package/dist/cjs/test/index.test.js +9 -0
- package/dist/{test → cjs/test}/test-utils.d.ts +0 -0
- package/dist/{test → cjs/test}/test-utils.js +0 -0
- package/dist/{test → cjs/test}/validate-in-out-frames.test.d.ts +0 -0
- package/dist/{test → cjs/test}/validate-in-out-frames.test.js +13 -12
- package/dist/{test → cjs/test}/validate-prop.test.d.ts +0 -0
- package/dist/cjs/test/validate-prop.test.js +131 -0
- package/dist/{use-hover-state.d.ts → cjs/use-hover-state.d.ts} +0 -0
- package/dist/{use-hover-state.js → cjs/use-hover-state.js} +0 -0
- package/dist/{use-playback.d.ts → cjs/use-playback.d.ts} +0 -0
- package/dist/{use-playback.js → cjs/use-playback.js} +46 -9
- package/dist/{use-player.d.ts → cjs/use-player.d.ts} +2 -2
- package/dist/{use-player.js → cjs/use-player.js} +2 -2
- package/dist/cjs/use-thumbnail.d.ts +6 -0
- package/dist/cjs/use-thumbnail.js +18 -0
- package/dist/{use-video-controls-resize.d.ts → cjs/use-video-controls-resize.d.ts} +8 -4
- package/dist/{use-video-controls-resize.js → cjs/use-video-controls-resize.js} +16 -13
- package/dist/{utils → cjs/utils}/calculate-player-size.d.ts +1 -1
- package/dist/{utils → cjs/utils}/calculate-player-size.js +9 -10
- package/dist/{utils → cjs/utils}/cancellable-promise.d.ts +1 -1
- package/dist/{utils → cjs/utils}/cancellable-promise.js +0 -0
- package/dist/{utils → cjs/utils}/delay.d.ts +0 -0
- package/dist/{utils → cjs/utils}/delay.js +0 -0
- package/dist/{utils → cjs/utils}/is-node.d.ts +0 -0
- package/dist/{utils → cjs/utils}/is-node.js +0 -0
- package/dist/{utils → cjs/utils}/preview-size.d.ts +2 -2
- package/dist/{utils → cjs/utils}/preview-size.js +0 -0
- package/dist/cjs/utils/props-if-has-props.d.ts +10 -0
- package/dist/cjs/utils/props-if-has-props.js +2 -0
- package/dist/{utils → cjs/utils}/use-cancellable-promises.d.ts +1 -1
- package/dist/{utils → cjs/utils}/use-cancellable-promises.js +0 -0
- package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.d.ts +0 -0
- package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.js +5 -5
- package/dist/cjs/utils/use-component-visible.d.ts +6 -0
- package/dist/cjs/utils/use-component-visible.js +21 -0
- package/dist/{utils → cjs/utils}/use-element-size.d.ts +2 -1
- package/dist/{utils → cjs/utils}/use-element-size.js +29 -12
- package/dist/{utils → cjs/utils}/validate-in-out-frame.d.ts +1 -1
- package/dist/{utils → cjs/utils}/validate-in-out-frame.js +13 -13
- package/dist/{utils → cjs/utils}/validate-initial-frame.d.ts +0 -0
- package/dist/{utils → cjs/utils}/validate-initial-frame.js +0 -0
- package/dist/{utils → cjs/utils}/validate-playbackrate.d.ts +0 -0
- package/dist/{utils → cjs/utils}/validate-playbackrate.js +0 -0
- package/dist/{volume-persistance.d.ts → cjs/volume-persistance.d.ts} +0 -0
- package/dist/{volume-persistance.js → cjs/volume-persistance.js} +0 -0
- package/dist/esm/MediaVolumeSlider.d.ts +5 -0
- package/dist/esm/PlaybackrateControl.d.ts +8 -0
- package/dist/esm/Player.d.ts +52 -0
- package/dist/esm/PlayerControls.d.ts +42 -0
- package/dist/esm/PlayerSeekBar.d.ts +8 -0
- package/dist/esm/PlayerUI.d.ts +40 -0
- package/dist/esm/SharedPlayerContext.d.ts +15 -0
- package/dist/esm/Thumbnail.d.ts +24 -0
- package/dist/esm/ThumbnailUI.d.ts +11 -0
- package/dist/esm/calculate-next-frame.d.ts +14 -0
- package/dist/esm/calculate-scale.d.ts +39 -0
- package/dist/esm/emitter-context.d.ts +4 -0
- package/dist/esm/error-boundary.d.ts +19 -0
- package/dist/esm/event-emitter.d.ts +81 -0
- package/dist/esm/format-time.d.ts +1 -0
- package/dist/esm/icons.d.ts +10 -0
- package/dist/esm/index.d.ts +61 -0
- package/dist/esm/index.mjs +2132 -0
- package/dist/esm/is-backgrounded.d.ts +2 -0
- package/dist/esm/player-css-classname.d.ts +1 -0
- package/dist/esm/player-methods.d.ts +24 -0
- package/dist/esm/test/index.test.d.ts +1 -0
- package/dist/esm/test/test-utils.d.ts +6 -0
- package/dist/esm/test/validate-in-out-frames.test.d.ts +1 -0
- package/dist/esm/test/validate-prop.test.d.ts +1 -0
- package/dist/esm/use-hover-state.d.ts +1 -0
- package/dist/esm/use-playback.d.ts +7 -0
- package/dist/esm/use-player.d.ts +19 -0
- package/dist/esm/use-thumbnail.d.ts +6 -0
- package/dist/esm/use-video-controls-resize.d.ts +11 -0
- package/dist/esm/utils/calculate-player-size.d.ts +9 -0
- package/dist/esm/utils/cancellable-promise.d.ts +5 -0
- package/dist/esm/utils/delay.d.ts +1 -0
- package/dist/esm/utils/is-node.d.ts +1 -0
- package/dist/esm/utils/preview-size.d.ts +8 -0
- package/dist/esm/utils/props-if-has-props.d.ts +10 -0
- package/dist/esm/utils/use-cancellable-promises.d.ts +7 -0
- package/dist/esm/utils/use-click-prevention-on-double-click.d.ts +3 -0
- package/dist/esm/utils/use-component-visible.d.ts +6 -0
- package/dist/esm/utils/use-element-size.d.ts +16 -0
- package/dist/esm/utils/validate-in-out-frame.d.ts +6 -0
- package/dist/esm/utils/validate-initial-frame.d.ts +4 -0
- package/dist/esm/utils/validate-playbackrate.d.ts +1 -0
- package/dist/esm/volume-persistance.d.ts +2 -0
- package/dist/tsconfig-esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +80 -66
- package/dist/Player.d.ts +0 -49
- package/dist/PlayerControls.js +0 -137
- package/dist/calculate-scale.d.ts +0 -20
- package/dist/calculate-scale.js +0 -33
- package/dist/emitter-context.d.ts +0 -3
- package/dist/event-emitter.d.ts +0 -52
- package/dist/index.js +0 -23
- package/dist/test/index.test.js +0 -8
- package/dist/test/validate-prop.test.js +0 -130
package/LICENSE.md
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
# Remotion License
|
|
2
2
|
|
|
3
|
-
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion create videos for free (even commercial), while a company license is required for for-profit
|
|
3
|
+
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
|
|
4
4
|
|
|
5
5
|
- [Free license](#free-license)
|
|
6
6
|
- [Company license](#company-license)
|
|
7
7
|
|
|
8
8
|
## Free license
|
|
9
9
|
|
|
10
|
-
Copyright ©
|
|
10
|
+
Copyright © 2023 [Remotion](https://www.remotion.dev/)
|
|
11
11
|
|
|
12
12
|
### Eligibility
|
|
13
13
|
|
|
14
14
|
You are eligible to use Remotion for free if you are:
|
|
15
15
|
|
|
16
16
|
- an individual
|
|
17
|
-
- a for-profit
|
|
18
|
-
- a non-profit or not-for-profit
|
|
17
|
+
- a for-profit organization with up to 3 employees
|
|
18
|
+
- a non-profit or not-for-profit organization
|
|
19
19
|
- evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
|
|
20
20
|
|
|
21
21
|
### Allowed use cases
|
|
22
22
|
|
|
23
|
-
Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify
|
|
23
|
+
Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
|
|
24
24
|
|
|
25
25
|
### Disallowed use cases
|
|
26
26
|
|
|
27
|
-
It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, sublicensing your own derivate of Remotion.
|
|
27
|
+
It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
|
|
28
28
|
|
|
29
29
|
### Warranty notice
|
|
30
30
|
|
|
31
|
-
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and
|
|
31
|
+
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
|
|
32
32
|
|
|
33
33
|
### Support
|
|
34
34
|
|
|
@@ -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).
|
|
File without changes
|
|
@@ -1,11 +1,34 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.MediaVolumeSlider = exports.VOLUME_SLIDER_WIDTH = void 0;
|
|
4
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
6
29
|
const remotion_1 = require("remotion");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
30
|
+
const icons_js_1 = require("./icons.js");
|
|
31
|
+
const use_hover_state_js_1 = require("./use-hover-state.js");
|
|
9
32
|
const BAR_HEIGHT = 5;
|
|
10
33
|
const KNOB_SIZE = 12;
|
|
11
34
|
exports.VOLUME_SLIDER_WIDTH = 100;
|
|
@@ -15,8 +38,12 @@ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
15
38
|
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
16
39
|
const parentDivRef = (0, react_1.useRef)(null);
|
|
17
40
|
const inputRef = (0, react_1.useRef)(null);
|
|
18
|
-
const hover = (0,
|
|
19
|
-
|
|
41
|
+
const hover = (0, use_hover_state_js_1.useHoverState)(parentDivRef);
|
|
42
|
+
// Need to import it from React to fix React 17 ESM support.
|
|
43
|
+
const randomId =
|
|
44
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
45
|
+
typeof react_1.default.useId === 'undefined' ? 'volume-slider' : react_1.default.useId();
|
|
46
|
+
const [randomClass] = (0, react_1.useState)(() => `__remotion-volume-slider-${(0, remotion_1.random)(randomId)}`.replace('.', ''));
|
|
20
47
|
const isMutedOrZero = mediaMuted || mediaVolume === 0;
|
|
21
48
|
const onVolumeChange = (e) => {
|
|
22
49
|
setMediaVolume(parseFloat(e.target.value));
|
|
@@ -43,7 +70,6 @@ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
43
70
|
display: 'inline-flex',
|
|
44
71
|
background: 'none',
|
|
45
72
|
border: 'none',
|
|
46
|
-
padding: '6px',
|
|
47
73
|
justifyContent: 'center',
|
|
48
74
|
alignItems: 'center',
|
|
49
75
|
touchAction: 'none',
|
|
@@ -53,8 +79,8 @@ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
53
79
|
const volumeContainer = (0, react_1.useMemo)(() => {
|
|
54
80
|
return {
|
|
55
81
|
display: 'inline',
|
|
56
|
-
width:
|
|
57
|
-
height:
|
|
82
|
+
width: icons_js_1.ICON_SIZE,
|
|
83
|
+
height: icons_js_1.ICON_SIZE,
|
|
58
84
|
cursor: 'pointer',
|
|
59
85
|
appearance: 'none',
|
|
60
86
|
background: 'none',
|
|
@@ -70,20 +96,24 @@ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
70
96
|
cursor: 'pointer',
|
|
71
97
|
height: BAR_HEIGHT,
|
|
72
98
|
width: exports.VOLUME_SLIDER_WIDTH,
|
|
99
|
+
backgroundImage: `linear-gradient(
|
|
100
|
+
to right,
|
|
101
|
+
white ${mediaVolume * 100}%, rgba(255, 255, 255, 0) ${mediaVolume * 100}%
|
|
102
|
+
)`,
|
|
73
103
|
};
|
|
74
104
|
if (displayVerticalVolumeSlider) {
|
|
75
105
|
return {
|
|
76
106
|
...commonStyle,
|
|
77
107
|
transform: `rotate(-90deg)`,
|
|
78
108
|
position: 'absolute',
|
|
79
|
-
bottom:
|
|
109
|
+
bottom: icons_js_1.ICON_SIZE + exports.VOLUME_SLIDER_WIDTH / 2 + 5,
|
|
80
110
|
};
|
|
81
111
|
}
|
|
82
112
|
return {
|
|
83
113
|
...commonStyle,
|
|
84
114
|
marginLeft: 5,
|
|
85
115
|
};
|
|
86
|
-
}, [displayVerticalVolumeSlider]);
|
|
116
|
+
}, [displayVerticalVolumeSlider, mediaVolume]);
|
|
87
117
|
const sliderStyle = `
|
|
88
118
|
.${randomClass}::-webkit-slider-thumb {
|
|
89
119
|
-webkit-appearance: none;
|
|
@@ -93,12 +123,6 @@ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
93
123
|
height: ${KNOB_SIZE}px;
|
|
94
124
|
width: ${KNOB_SIZE}px;
|
|
95
125
|
}
|
|
96
|
-
.${randomClass} {
|
|
97
|
-
background-image: linear-gradient(
|
|
98
|
-
to right,
|
|
99
|
-
white ${mediaVolume * 100}%, rgba(255, 255, 255, 0) ${mediaVolume * 100}%
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
126
|
|
|
103
127
|
.${randomClass}::-moz-range-thumb {
|
|
104
128
|
-webkit-appearance: none;
|
|
@@ -113,6 +137,6 @@ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
113
137
|
// eslint-disable-next-line react/no-danger
|
|
114
138
|
dangerouslySetInnerHTML: {
|
|
115
139
|
__html: sliderStyle,
|
|
116
|
-
} }), (0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(
|
|
140
|
+
} }), (0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(icons_js_1.VolumeOffIcon, {}) : (0, jsx_runtime_1.jsx)(icons_js_1.VolumeOnIcon, {}) }), (focused || hover) && !mediaMuted ? ((0, jsx_runtime_1.jsx)("input", { ref: inputRef, "aria-label": "Change volume", className: randomClass, max: 1, min: 0, onBlur: () => setFocused(false), onChange: onVolumeChange, step: 0.01, type: "range", value: mediaVolume, style: inputStyle })) : null] }));
|
|
117
141
|
};
|
|
118
142
|
exports.MediaVolumeSlider = MediaVolumeSlider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Size } from './utils/use-element-size.js';
|
|
3
|
+
export declare const Checkmark: () => JSX.Element;
|
|
4
|
+
export declare const playerButtonStyle: React.CSSProperties;
|
|
5
|
+
export declare const PlaybackrateControl: React.FC<{
|
|
6
|
+
playbackRates: number[];
|
|
7
|
+
canvasSize: Size;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,163 @@
|
|
|
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.PlaybackrateControl = exports.playerButtonStyle = exports.Checkmark = 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 use_component_visible_js_1 = __importDefault(require("./utils/use-component-visible.js"));
|
|
11
|
+
// To align
|
|
12
|
+
const BOTTOM = 35;
|
|
13
|
+
// Arbitrary to clamp the height of the popup
|
|
14
|
+
const THRESHOLD = 70;
|
|
15
|
+
const rateDiv = {
|
|
16
|
+
height: 30,
|
|
17
|
+
paddingRight: 15,
|
|
18
|
+
paddingLeft: 12,
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
};
|
|
23
|
+
const checkmarkContainer = {
|
|
24
|
+
width: 22,
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
};
|
|
28
|
+
const checkmarkStyle = {
|
|
29
|
+
width: 14,
|
|
30
|
+
height: 14,
|
|
31
|
+
color: 'black',
|
|
32
|
+
};
|
|
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" }) }));
|
|
34
|
+
exports.Checkmark = Checkmark;
|
|
35
|
+
const PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
36
|
+
const { setPlaybackRate, playbackRate } = (0, react_1.useContext)(remotion_1.Internals.Timeline.TimelineContext);
|
|
37
|
+
const [keyboardSelectedRate, setKeyboardSelectedRate] = (0, react_1.useState)(playbackRate);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
const listener = (e) => {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
if (e.key === 'ArrowUp') {
|
|
42
|
+
const currentIndex = playbackRates.findIndex((rate) => rate === keyboardSelectedRate);
|
|
43
|
+
if (currentIndex === 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (currentIndex === -1) {
|
|
47
|
+
setKeyboardSelectedRate(playbackRates[0]);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
setKeyboardSelectedRate(playbackRates[currentIndex - 1]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (e.key === 'ArrowDown') {
|
|
54
|
+
const currentIndex = playbackRates.findIndex((rate) => rate === keyboardSelectedRate);
|
|
55
|
+
if (currentIndex === playbackRates.length - 1) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (currentIndex === -1) {
|
|
59
|
+
setKeyboardSelectedRate(playbackRates[playbackRates.length - 1]);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
setKeyboardSelectedRate(playbackRates[currentIndex + 1]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (e.key === 'Enter') {
|
|
66
|
+
setPlaybackRate(keyboardSelectedRate);
|
|
67
|
+
setIsComponentVisible(false);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
window.addEventListener('keydown', listener);
|
|
71
|
+
return () => {
|
|
72
|
+
window.removeEventListener('keydown', listener);
|
|
73
|
+
};
|
|
74
|
+
}, [
|
|
75
|
+
playbackRates,
|
|
76
|
+
keyboardSelectedRate,
|
|
77
|
+
setPlaybackRate,
|
|
78
|
+
setIsComponentVisible,
|
|
79
|
+
]);
|
|
80
|
+
const onSelect = (0, react_1.useCallback)((rate) => {
|
|
81
|
+
setPlaybackRate(rate);
|
|
82
|
+
setIsComponentVisible(false);
|
|
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]);
|
|
98
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: playbackPopup, children: playbackRates.map((rate) => {
|
|
99
|
+
return ((0, jsx_runtime_1.jsx)(PlaybackrateOption, { selectedRate: playbackRate, onSelect: onSelect, rate: rate, keyboardSelectedRate: keyboardSelectedRate }, rate));
|
|
100
|
+
}) }));
|
|
101
|
+
};
|
|
102
|
+
const PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }) => {
|
|
103
|
+
const onClick = (0, react_1.useCallback)((e) => {
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
onSelect(rate);
|
|
107
|
+
}, [onSelect, rate]);
|
|
108
|
+
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
109
|
+
const onMouseEnter = (0, react_1.useCallback)(() => {
|
|
110
|
+
setHovered(true);
|
|
111
|
+
}, []);
|
|
112
|
+
const onMouseLeave = (0, react_1.useCallback)(() => {
|
|
113
|
+
setHovered(false);
|
|
114
|
+
}, []);
|
|
115
|
+
const actualStyle = (0, react_1.useMemo)(() => {
|
|
116
|
+
return {
|
|
117
|
+
...rateDiv,
|
|
118
|
+
backgroundColor: hovered || keyboardSelectedRate === rate ? '#eee' : 'transparent',
|
|
119
|
+
};
|
|
120
|
+
}, [hovered, keyboardSelectedRate, rate]);
|
|
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));
|
|
122
|
+
};
|
|
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',
|
|
137
|
+
border: 'none',
|
|
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',
|
|
152
|
+
};
|
|
153
|
+
const PlaybackrateControl = ({ playbackRates, canvasSize }) => {
|
|
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);
|
|
156
|
+
const onClick = (0, react_1.useCallback)((e) => {
|
|
157
|
+
e.stopPropagation();
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
setIsComponentVisible(!isComponentVisible);
|
|
160
|
+
}, [isComponentVisible, setIsComponentVisible]);
|
|
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 }))] }) }));
|
|
162
|
+
};
|
|
163
|
+
exports.PlaybackrateControl = PlaybackrateControl;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { CompProps } from 'remotion';
|
|
4
|
+
import type { AnyZodObject } from 'zod';
|
|
5
|
+
import type { PlayerRef } from './player-methods.js';
|
|
6
|
+
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls.js';
|
|
7
|
+
import type { RenderLoading, RenderPoster } from './PlayerUI.js';
|
|
8
|
+
import type { PropsIfHasProps } from './utils/props-if-has-props.js';
|
|
9
|
+
export type ErrorFallback = (info: {
|
|
10
|
+
error: Error;
|
|
11
|
+
}) => React.ReactNode;
|
|
12
|
+
export type PlayerProps<Schema extends AnyZodObject, Props> = {
|
|
13
|
+
durationInFrames: number;
|
|
14
|
+
compositionWidth: number;
|
|
15
|
+
compositionHeight: number;
|
|
16
|
+
fps: number;
|
|
17
|
+
showVolumeControls?: boolean;
|
|
18
|
+
controls?: boolean;
|
|
19
|
+
errorFallback?: ErrorFallback;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
autoPlay?: boolean;
|
|
23
|
+
allowFullscreen?: boolean;
|
|
24
|
+
clickToPlay?: boolean;
|
|
25
|
+
doubleClickToFullscreen?: boolean;
|
|
26
|
+
spaceKeyToPlayOrPause?: boolean;
|
|
27
|
+
numberOfSharedAudioTags?: number;
|
|
28
|
+
playbackRate?: number;
|
|
29
|
+
renderLoading?: RenderLoading;
|
|
30
|
+
moveToBeginningWhenEnded?: boolean;
|
|
31
|
+
className?: string;
|
|
32
|
+
initialFrame?: number;
|
|
33
|
+
renderPoster?: RenderPoster;
|
|
34
|
+
showPosterWhenPaused?: boolean;
|
|
35
|
+
showPosterWhenEnded?: boolean;
|
|
36
|
+
showPosterWhenUnplayed?: boolean;
|
|
37
|
+
inFrame?: number | null;
|
|
38
|
+
outFrame?: number | null;
|
|
39
|
+
initiallyShowControls?: number | boolean;
|
|
40
|
+
renderPlayPauseButton?: RenderPlayPauseButton;
|
|
41
|
+
renderFullscreenButton?: RenderFullscreenButton;
|
|
42
|
+
alwaysShowControls?: boolean;
|
|
43
|
+
schema?: Schema;
|
|
44
|
+
initiallyMuted?: boolean;
|
|
45
|
+
showPlaybackRateControl?: boolean | number[];
|
|
46
|
+
} & CompProps<Props> & PropsIfHasProps<Schema, Props>;
|
|
47
|
+
export declare const componentOrNullIfLazy: <Props>(props: CompProps<Props>) => ComponentType<Props> | null;
|
|
48
|
+
/**
|
|
49
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
|
|
50
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/player)
|
|
51
|
+
*/
|
|
52
|
+
export declare const Player: <Schema extends AnyZodObject, Props>(props: PlayerProps<Schema, Props> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
|
|
@@ -3,18 +3,18 @@ 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");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
10
|
+
const emitter_context_js_1 = require("./emitter-context.js");
|
|
11
|
+
const event_emitter_js_1 = require("./event-emitter.js");
|
|
12
|
+
const player_css_classname_js_1 = require("./player-css-classname.js");
|
|
13
|
+
const PlayerUI_js_1 = __importDefault(require("./PlayerUI.js"));
|
|
14
|
+
const SharedPlayerContext_js_1 = require("./SharedPlayerContext.js");
|
|
15
|
+
const validate_in_out_frame_js_1 = require("./utils/validate-in-out-frame.js");
|
|
16
|
+
const validate_initial_frame_js_1 = require("./utils/validate-initial-frame.js");
|
|
17
|
+
const validate_playbackrate_js_1 = require("./utils/validate-playbackrate.js");
|
|
18
18
|
const componentOrNullIfLazy = (props) => {
|
|
19
19
|
if ('component' in props) {
|
|
20
20
|
return props.component;
|
|
@@ -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, ...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, initiallyMuted = false, showPlaybackRateControl = 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)(() => {
|
|
@@ -42,16 +42,15 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
42
42
|
throw new TypeError(`'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
|
|
43
43
|
}
|
|
44
44
|
const component = remotion_1.Internals.useLazyComponent(componentProps);
|
|
45
|
-
(0,
|
|
45
|
+
(0, validate_initial_frame_js_1.validateInitialFrame)({ initialFrame, durationInFrames });
|
|
46
46
|
const [frame, setFrame] = (0, react_1.useState)(() => initialFrame !== null && initialFrame !== void 0 ? initialFrame : 0);
|
|
47
47
|
const [playing, setPlaying] = (0, react_1.useState)(false);
|
|
48
48
|
const [rootId] = (0, react_1.useState)('player-comp');
|
|
49
|
-
const [emitter] = (0, react_1.useState)(() => new
|
|
49
|
+
const [emitter] = (0, react_1.useState)(() => new event_emitter_js_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);
|
|
53
|
+
const [currentPlaybackRate, setCurrentPlaybackRate] = (0, react_1.useState)(playbackRate);
|
|
55
54
|
if (typeof compositionHeight !== 'number') {
|
|
56
55
|
throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
|
|
57
56
|
}
|
|
@@ -60,9 +59,14 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
60
59
|
}
|
|
61
60
|
remotion_1.Internals.validateDimension(compositionHeight, 'compositionHeight', 'of the <Player /> component');
|
|
62
61
|
remotion_1.Internals.validateDimension(compositionWidth, 'compositionWidth', 'of the <Player /> component');
|
|
63
|
-
remotion_1.Internals.validateDurationInFrames(
|
|
62
|
+
remotion_1.Internals.validateDurationInFrames({
|
|
63
|
+
durationInFrames,
|
|
64
|
+
component: 'of the <Player/> component',
|
|
65
|
+
allowFloats: false,
|
|
66
|
+
});
|
|
64
67
|
remotion_1.Internals.validateFps(fps, 'as a prop of the <Player/> component', false);
|
|
65
|
-
(
|
|
68
|
+
remotion_1.Internals.validateDefaultAndInputProps(inputProps, 'inputProps', null);
|
|
69
|
+
(0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
66
70
|
durationInFrames,
|
|
67
71
|
inFrame,
|
|
68
72
|
outFrame,
|
|
@@ -102,14 +106,13 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
102
106
|
numberOfSharedAudioTags < 0) {
|
|
103
107
|
throw new TypeError(`'numberOfSharedAudioTags' must be an integer but got '${numberOfSharedAudioTags}' instead`);
|
|
104
108
|
}
|
|
105
|
-
(0,
|
|
109
|
+
(0, validate_playbackrate_js_1.validatePlaybackRate)(currentPlaybackRate);
|
|
110
|
+
(0, react_1.useEffect)(() => {
|
|
111
|
+
emitter.dispatchRateChange(currentPlaybackRate);
|
|
112
|
+
}, [emitter, currentPlaybackRate]);
|
|
106
113
|
(0, react_1.useEffect)(() => {
|
|
107
|
-
|
|
108
|
-
}, [
|
|
109
|
-
const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
|
|
110
|
-
setMediaVolume(vol);
|
|
111
|
-
(0, volume_persistance_1.persistVolume)(vol);
|
|
112
|
-
}, []);
|
|
114
|
+
setCurrentPlaybackRate(playbackRate);
|
|
115
|
+
}, [playbackRate]);
|
|
113
116
|
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
114
117
|
const timelineContextValue = (0, react_1.useMemo)(() => {
|
|
115
118
|
return {
|
|
@@ -117,74 +120,20 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
117
120
|
playing,
|
|
118
121
|
rootId,
|
|
119
122
|
shouldRegisterSequences: false,
|
|
120
|
-
playbackRate,
|
|
123
|
+
playbackRate: currentPlaybackRate,
|
|
121
124
|
imperativePlaying,
|
|
122
|
-
setPlaybackRate: () => {
|
|
123
|
-
|
|
125
|
+
setPlaybackRate: (rate) => {
|
|
126
|
+
setCurrentPlaybackRate(rate);
|
|
124
127
|
},
|
|
125
128
|
audioAndVideoTags,
|
|
126
129
|
};
|
|
127
|
-
}, [frame,
|
|
130
|
+
}, [frame, currentPlaybackRate, playing, rootId]);
|
|
128
131
|
const setTimelineContextValue = (0, react_1.useMemo)(() => {
|
|
129
132
|
return {
|
|
130
133
|
setFrame,
|
|
131
134
|
setPlaying,
|
|
132
135
|
};
|
|
133
136
|
}, [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
137
|
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
189
138
|
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
190
139
|
}, [inputProps]);
|
|
@@ -192,12 +141,17 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
192
141
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
193
142
|
(0, react_1.useLayoutEffect)(() => {
|
|
194
143
|
// Inject CSS only on client, and also only after the Player has hydrated
|
|
195
|
-
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${
|
|
144
|
+
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_js_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
|
|
196
145
|
}, []);
|
|
197
146
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
147
|
+
const actualInputProps = (0, react_1.useMemo)(() => inputProps !== null && inputProps !== void 0 ? inputProps : {}, [inputProps]);
|
|
148
|
+
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: actualInputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, 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'
|
|
149
|
+
? clickToPlay
|
|
150
|
+
: Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: currentPlaybackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), 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, showPlaybackRateControl: showPlaybackRateControl }) }) }) }) }));
|
|
201
151
|
};
|
|
202
|
-
|
|
203
|
-
|
|
152
|
+
const forward = react_1.forwardRef;
|
|
153
|
+
/**
|
|
154
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
|
|
155
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/player)
|
|
156
|
+
*/
|
|
157
|
+
exports.Player = forward(PlayerFn);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { MouseEventHandler } from 'react';
|
|
1
|
+
import type { MouseEventHandler, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { usePlayer } from './use-player';
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
import type { usePlayer } from './use-player.js';
|
|
4
|
+
import type { Size } from './utils/use-element-size.js';
|
|
5
|
+
export type RenderPlayPauseButton = (props: {
|
|
6
|
+
playing: boolean;
|
|
7
|
+
}) => ReactNode;
|
|
8
|
+
export type RenderFullscreenButton = (props: {
|
|
9
|
+
isFullscreen: boolean;
|
|
10
|
+
}) => ReactNode;
|
|
6
11
|
declare global {
|
|
7
12
|
interface Document {
|
|
8
13
|
webkitFullscreenEnabled?: boolean;
|
|
@@ -29,5 +34,9 @@ export declare const Controls: React.FC<{
|
|
|
29
34
|
inFrame: number | null;
|
|
30
35
|
outFrame: number | null;
|
|
31
36
|
initiallyShowControls: number | boolean;
|
|
32
|
-
|
|
37
|
+
canvasSize: Size | null;
|
|
38
|
+
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
39
|
+
renderFullscreenButton: RenderFullscreenButton | null;
|
|
40
|
+
alwaysShowControls: boolean;
|
|
41
|
+
showPlaybackRateControl: boolean | number[];
|
|
33
42
|
}>;
|