@remotion/player 3.2.21 → 3.2.23-ensure-ffmpeg.123
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 +4 -1
- package/dist/MediaVolumeSlider.js +82 -55
- package/dist/Player.d.ts +7 -9
- package/dist/Player.js +6 -69
- package/dist/PlayerControls.d.ts +13 -1
- package/dist/PlayerControls.js +56 -13
- package/dist/PlayerSeekBar.d.ts +0 -0
- package/dist/PlayerSeekBar.js +0 -0
- package/dist/PlayerUI.d.ts +5 -5
- package/dist/PlayerUI.js +32 -71
- package/dist/SharedPlayerContext.d.ts +14 -0
- package/dist/SharedPlayerContext.js +71 -0
- package/dist/Thumbnail.d.ts +23 -0
- package/dist/Thumbnail.js +41 -0
- package/dist/ThumbnailUI.d.ts +11 -0
- package/dist/ThumbnailUI.js +107 -0
- package/dist/calculate-next-frame.d.ts +0 -0
- package/dist/calculate-next-frame.js +0 -0
- package/dist/calculate-scale.d.ts +25 -6
- package/dist/calculate-scale.js +53 -1
- package/dist/emitter-context.d.ts +2 -1
- package/dist/emitter-context.js +2 -1
- package/dist/error-boundary.d.ts +0 -0
- package/dist/error-boundary.js +0 -0
- package/dist/event-emitter.d.ts +28 -9
- package/dist/event-emitter.js +29 -1
- package/dist/format-time.d.ts +0 -0
- package/dist/format-time.js +0 -0
- package/dist/icons.d.ts +2 -1
- package/dist/icons.js +7 -7
- package/dist/index.d.ts +7 -5
- package/dist/index.js +3 -1
- package/dist/player-css-classname.d.ts +0 -1
- package/dist/player-css-classname.js +1 -2
- package/dist/player-methods.d.ts +6 -2
- package/dist/player-methods.js +0 -0
- package/dist/test/index.test.d.ts +0 -0
- package/dist/test/index.test.js +3 -2
- package/dist/test/test-utils.d.ts +0 -0
- package/dist/test/test-utils.js +0 -0
- package/dist/test/validate-in-out-frames.test.d.ts +0 -0
- package/dist/test/validate-in-out-frames.test.js +12 -11
- package/dist/test/validate-prop.test.d.ts +0 -0
- package/dist/test/validate-prop.test.js +24 -23
- package/dist/use-hover-state.d.ts +0 -0
- package/dist/use-hover-state.js +0 -0
- package/dist/use-playback.d.ts +0 -0
- package/dist/use-playback.js +3 -0
- package/dist/use-player.d.ts +0 -0
- package/dist/use-player.js +0 -0
- package/dist/use-thumbnail.d.ts +6 -0
- package/dist/use-thumbnail.js +18 -0
- package/dist/use-video-controls-resize.d.ts +7 -0
- package/dist/use-video-controls-resize.js +36 -0
- package/dist/utils/calculate-player-size.d.ts +0 -0
- package/dist/utils/calculate-player-size.js +0 -0
- package/dist/utils/cancellable-promise.d.ts +0 -0
- package/dist/utils/cancellable-promise.js +0 -0
- package/dist/utils/delay.d.ts +0 -0
- package/dist/utils/delay.js +0 -0
- package/dist/utils/is-node.d.ts +0 -0
- package/dist/utils/is-node.js +0 -0
- package/dist/utils/preview-size.d.ts +0 -0
- package/dist/utils/preview-size.js +0 -0
- package/dist/utils/props-if-has-props.d.ts +5 -0
- package/dist/utils/props-if-has-props.js +2 -0
- package/dist/utils/use-cancellable-promises.d.ts +0 -0
- package/dist/utils/use-cancellable-promises.js +0 -0
- package/dist/utils/use-click-prevention-on-double-click.d.ts +0 -0
- package/dist/utils/use-click-prevention-on-double-click.js +0 -0
- package/dist/utils/use-element-size.d.ts +0 -0
- package/dist/utils/use-element-size.js +0 -0
- package/dist/utils/validate-in-out-frame.d.ts +0 -0
- package/dist/utils/validate-in-out-frame.js +0 -0
- package/dist/utils/validate-initial-frame.d.ts +0 -0
- package/dist/utils/validate-initial-frame.js +0 -0
- package/dist/utils/validate-playbackrate.d.ts +0 -0
- package/dist/utils/validate-playbackrate.js +0 -0
- package/dist/volume-persistance.d.ts +0 -0
- package/dist/volume-persistance.js +0 -0
- package/package.json +11 -12
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 © 2022 [
|
|
10
|
+
Copyright © 2022 [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).
|
|
@@ -1,72 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaVolumeSlider = void 0;
|
|
3
|
+
exports.MediaVolumeSlider = exports.VOLUME_SLIDER_WIDTH = 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");
|
|
7
7
|
const icons_1 = require("./icons");
|
|
8
|
-
const player_css_classname_1 = require("./player-css-classname");
|
|
9
8
|
const use_hover_state_1 = require("./use-hover-state");
|
|
10
9
|
const BAR_HEIGHT = 5;
|
|
11
10
|
const KNOB_SIZE = 12;
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const sliderStyle = `
|
|
15
|
-
${scope} {
|
|
16
|
-
-webkit-appearance: none;
|
|
17
|
-
background-color: rgba(255, 255, 255, 0.5);
|
|
18
|
-
border-radius: ${BAR_HEIGHT / 2}px;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
height: ${BAR_HEIGHT}px;
|
|
21
|
-
margin-left: 5px;
|
|
22
|
-
width: ${VOLUME_SLIDER_WIDTH}px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
${scope}::-webkit-slider-thumb {
|
|
26
|
-
-webkit-appearance: none;
|
|
27
|
-
background-color: white;
|
|
28
|
-
border-radius: ${KNOB_SIZE / 2}px;
|
|
29
|
-
box-shadow: 0 0 2px black;
|
|
30
|
-
height: ${KNOB_SIZE}px;
|
|
31
|
-
width: ${KNOB_SIZE}px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
${scope}::-moz-range-thumb {
|
|
35
|
-
-webkit-appearance: none;
|
|
36
|
-
background-color: white;
|
|
37
|
-
border-radius: ${KNOB_SIZE / 2}px;
|
|
38
|
-
box-shadow: 0 0 2px black;
|
|
39
|
-
height: ${KNOB_SIZE}px;
|
|
40
|
-
width: ${KNOB_SIZE}px;
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
43
|
-
remotion_1.Internals.CSSUtils.injectCSS(sliderStyle);
|
|
44
|
-
const parentDivStyle = {
|
|
45
|
-
display: 'inline-flex',
|
|
46
|
-
background: 'none',
|
|
47
|
-
border: 'none',
|
|
48
|
-
padding: '6px',
|
|
49
|
-
justifyContent: 'center',
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
touchAction: 'none',
|
|
52
|
-
};
|
|
53
|
-
const volumeContainer = {
|
|
54
|
-
display: 'inline',
|
|
55
|
-
width: icons_1.ICON_SIZE,
|
|
56
|
-
height: icons_1.ICON_SIZE,
|
|
57
|
-
cursor: 'pointer',
|
|
58
|
-
appearance: 'none',
|
|
59
|
-
background: 'none',
|
|
60
|
-
border: 'none',
|
|
61
|
-
padding: 0,
|
|
62
|
-
};
|
|
63
|
-
const MediaVolumeSlider = () => {
|
|
11
|
+
exports.VOLUME_SLIDER_WIDTH = 100;
|
|
12
|
+
const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
64
13
|
const [mediaMuted, setMediaMuted] = remotion_1.Internals.useMediaMutedState();
|
|
65
14
|
const [mediaVolume, setMediaVolume] = remotion_1.Internals.useMediaVolumeState();
|
|
66
15
|
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
67
16
|
const parentDivRef = (0, react_1.useRef)(null);
|
|
68
17
|
const inputRef = (0, react_1.useRef)(null);
|
|
69
18
|
const hover = (0, use_hover_state_1.useHoverState)(parentDivRef);
|
|
19
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
20
|
+
const randomId = typeof react_1.useId === 'undefined' ? 'volume-slider' : (0, react_1.useId)();
|
|
21
|
+
const [randomClass] = (0, react_1.useState)(() => `__remotion-volume-slider-${(0, remotion_1.random)(randomId)}`.replace('.', ''));
|
|
70
22
|
const isMutedOrZero = mediaMuted || mediaVolume === 0;
|
|
71
23
|
const onVolumeChange = (e) => {
|
|
72
24
|
setMediaVolume(parseFloat(e.target.value));
|
|
@@ -88,6 +40,81 @@ const MediaVolumeSlider = () => {
|
|
|
88
40
|
}
|
|
89
41
|
setMediaMuted((mute) => !mute);
|
|
90
42
|
}, [mediaVolume, setMediaMuted, setMediaVolume]);
|
|
91
|
-
|
|
43
|
+
const parentDivStyle = (0, react_1.useMemo)(() => {
|
|
44
|
+
return {
|
|
45
|
+
display: 'inline-flex',
|
|
46
|
+
background: 'none',
|
|
47
|
+
border: 'none',
|
|
48
|
+
padding: '6px',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
touchAction: 'none',
|
|
52
|
+
...(displayVerticalVolumeSlider && { position: 'relative' }),
|
|
53
|
+
};
|
|
54
|
+
}, [displayVerticalVolumeSlider]);
|
|
55
|
+
const volumeContainer = (0, react_1.useMemo)(() => {
|
|
56
|
+
return {
|
|
57
|
+
display: 'inline',
|
|
58
|
+
width: icons_1.ICON_SIZE,
|
|
59
|
+
height: icons_1.ICON_SIZE,
|
|
60
|
+
cursor: 'pointer',
|
|
61
|
+
appearance: 'none',
|
|
62
|
+
background: 'none',
|
|
63
|
+
border: 'none',
|
|
64
|
+
padding: 0,
|
|
65
|
+
};
|
|
66
|
+
}, []);
|
|
67
|
+
const inputStyle = (0, react_1.useMemo)(() => {
|
|
68
|
+
const commonStyle = {
|
|
69
|
+
WebkitAppearance: 'none',
|
|
70
|
+
backgroundColor: 'rgba(255, 255, 255, 0.5)',
|
|
71
|
+
borderRadius: BAR_HEIGHT / 2,
|
|
72
|
+
cursor: 'pointer',
|
|
73
|
+
height: BAR_HEIGHT,
|
|
74
|
+
width: exports.VOLUME_SLIDER_WIDTH,
|
|
75
|
+
};
|
|
76
|
+
if (displayVerticalVolumeSlider) {
|
|
77
|
+
return {
|
|
78
|
+
...commonStyle,
|
|
79
|
+
transform: `rotate(-90deg)`,
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
bottom: icons_1.ICON_SIZE + exports.VOLUME_SLIDER_WIDTH / 2 + 5,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
...commonStyle,
|
|
86
|
+
marginLeft: 5,
|
|
87
|
+
};
|
|
88
|
+
}, [displayVerticalVolumeSlider]);
|
|
89
|
+
const sliderStyle = `
|
|
90
|
+
.${randomClass}::-webkit-slider-thumb {
|
|
91
|
+
-webkit-appearance: none;
|
|
92
|
+
background-color: white;
|
|
93
|
+
border-radius: ${KNOB_SIZE / 2}px;
|
|
94
|
+
box-shadow: 0 0 2px black;
|
|
95
|
+
height: ${KNOB_SIZE}px;
|
|
96
|
+
width: ${KNOB_SIZE}px;
|
|
97
|
+
}
|
|
98
|
+
.${randomClass} {
|
|
99
|
+
background-image: linear-gradient(
|
|
100
|
+
to right,
|
|
101
|
+
white ${mediaVolume * 100}%, rgba(255, 255, 255, 0) ${mediaVolume * 100}%
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.${randomClass}::-moz-range-thumb {
|
|
106
|
+
-webkit-appearance: none;
|
|
107
|
+
background-color: white;
|
|
108
|
+
border-radius: ${KNOB_SIZE / 2}px;
|
|
109
|
+
box-shadow: 0 0 2px black;
|
|
110
|
+
height: ${KNOB_SIZE}px;
|
|
111
|
+
width: ${KNOB_SIZE}px;
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: parentDivRef, style: parentDivStyle, children: [(0, jsx_runtime_1.jsx)("style", {
|
|
115
|
+
// eslint-disable-next-line react/no-danger
|
|
116
|
+
dangerouslySetInnerHTML: {
|
|
117
|
+
__html: sliderStyle,
|
|
118
|
+
} }), (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_1.VolumeOffIcon, {}) : (0, jsx_runtime_1.jsx)(icons_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] }));
|
|
92
119
|
};
|
|
93
120
|
exports.MediaVolumeSlider = MediaVolumeSlider;
|
package/dist/Player.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type { ComponentType
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { CompProps } from 'remotion';
|
|
4
4
|
import type { PlayerRef } from './player-methods';
|
|
5
|
+
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
|
|
5
6
|
import type { RenderLoading, RenderPoster } from './PlayerUI';
|
|
6
|
-
|
|
7
|
-
inputProps?: Props;
|
|
8
|
-
} : {
|
|
9
|
-
inputProps: Props;
|
|
10
|
-
};
|
|
7
|
+
import type { PropsIfHasProps } from './utils/props-if-has-props';
|
|
11
8
|
export declare type ErrorFallback = (info: {
|
|
12
9
|
error: Error;
|
|
13
10
|
}) => React.ReactNode;
|
|
@@ -38,11 +35,12 @@ export declare type PlayerProps<T> = {
|
|
|
38
35
|
showPosterWhenUnplayed?: boolean;
|
|
39
36
|
inFrame?: number | null;
|
|
40
37
|
outFrame?: number | null;
|
|
38
|
+
initiallyShowControls?: number | boolean;
|
|
39
|
+
renderPlayPauseButton?: RenderPlayPauseButton;
|
|
40
|
+
renderFullscreenButton?: RenderFullscreenButton;
|
|
41
41
|
} & PropsIfHasProps<T> & CompProps<T>;
|
|
42
42
|
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
|
|
43
|
-
export declare const PlayerFn: <T>({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls, loop, autoPlay, showVolumeControls, allowFullscreen, clickToPlay, doubleClickToFullscreen, spaceKeyToPlayOrPause, moveToBeginningWhenEnded, numberOfSharedAudioTags, errorFallback, playbackRate, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
|
|
44
43
|
declare module 'react' {
|
|
45
44
|
function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
46
45
|
}
|
|
47
|
-
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
|
|
48
|
-
export {};
|
|
46
|
+
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
package/dist/Player.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Player = exports.
|
|
6
|
+
exports.Player = exports.componentOrNullIfLazy = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const remotion_1 = require("remotion");
|
|
@@ -11,10 +11,10 @@ const emitter_context_1 = require("./emitter-context");
|
|
|
11
11
|
const event_emitter_1 = require("./event-emitter");
|
|
12
12
|
const player_css_classname_1 = require("./player-css-classname");
|
|
13
13
|
const PlayerUI_1 = __importDefault(require("./PlayerUI"));
|
|
14
|
+
const SharedPlayerContext_1 = require("./SharedPlayerContext");
|
|
14
15
|
const validate_in_out_frame_1 = require("./utils/validate-in-out-frame");
|
|
15
16
|
const validate_initial_frame_1 = require("./utils/validate-initial-frame");
|
|
16
17
|
const validate_playbackrate_1 = require("./utils/validate-playbackrate");
|
|
17
|
-
const volume_persistance_1 = require("./volume-persistance");
|
|
18
18
|
const componentOrNullIfLazy = (props) => {
|
|
19
19
|
if ('component' in props) {
|
|
20
20
|
return props.component;
|
|
@@ -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, ...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, ...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)(() => {
|
|
@@ -48,8 +48,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
48
48
|
const [rootId] = (0, react_1.useState)('player-comp');
|
|
49
49
|
const [emitter] = (0, react_1.useState)(() => new event_emitter_1.PlayerEmitter());
|
|
50
50
|
const rootRef = (0, react_1.useRef)(null);
|
|
51
|
-
const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
|
|
52
|
-
const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_1.getPreferredVolume)());
|
|
53
51
|
const audioAndVideoTags = (0, react_1.useRef)([]);
|
|
54
52
|
const imperativePlaying = (0, react_1.useRef)(false);
|
|
55
53
|
if (typeof compositionHeight !== 'number') {
|
|
@@ -106,11 +104,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
106
104
|
(0, react_1.useEffect)(() => {
|
|
107
105
|
emitter.dispatchRatechange(playbackRate);
|
|
108
106
|
}, [emitter, playbackRate]);
|
|
109
|
-
|
|
110
|
-
setMediaVolume(vol);
|
|
111
|
-
(0, volume_persistance_1.persistVolume)(vol);
|
|
112
|
-
}, []);
|
|
113
|
-
(0, react_1.useImperativeHandle)(ref, () => rootRef.current);
|
|
107
|
+
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
114
108
|
const timelineContextValue = (0, react_1.useMemo)(() => {
|
|
115
109
|
return {
|
|
116
110
|
frame,
|
|
@@ -131,60 +125,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
131
125
|
setPlaying,
|
|
132
126
|
};
|
|
133
127
|
}, [setFrame]);
|
|
134
|
-
const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
135
|
-
return {
|
|
136
|
-
mediaMuted,
|
|
137
|
-
mediaVolume,
|
|
138
|
-
};
|
|
139
|
-
}, [mediaMuted, mediaVolume]);
|
|
140
|
-
const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
141
|
-
return {
|
|
142
|
-
setMediaMuted,
|
|
143
|
-
setMediaVolume: setMediaVolumeAndPersist,
|
|
144
|
-
};
|
|
145
|
-
}, [setMediaVolumeAndPersist]);
|
|
146
|
-
const compositionManagerContext = (0, react_1.useMemo)(() => {
|
|
147
|
-
return {
|
|
148
|
-
compositions: [
|
|
149
|
-
{
|
|
150
|
-
component: component,
|
|
151
|
-
durationInFrames,
|
|
152
|
-
height: compositionHeight,
|
|
153
|
-
width: compositionWidth,
|
|
154
|
-
fps,
|
|
155
|
-
id: 'player-comp',
|
|
156
|
-
props: inputProps,
|
|
157
|
-
nonce: 777,
|
|
158
|
-
scale: 1,
|
|
159
|
-
folderName: null,
|
|
160
|
-
defaultProps: undefined,
|
|
161
|
-
parentFolderName: null,
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
folders: [],
|
|
165
|
-
registerFolder: () => undefined,
|
|
166
|
-
unregisterFolder: () => undefined,
|
|
167
|
-
currentComposition: 'player-comp',
|
|
168
|
-
registerComposition: () => undefined,
|
|
169
|
-
registerSequence: () => undefined,
|
|
170
|
-
sequences: [],
|
|
171
|
-
setCurrentComposition: () => undefined,
|
|
172
|
-
unregisterComposition: () => undefined,
|
|
173
|
-
unregisterSequence: () => undefined,
|
|
174
|
-
registerAsset: () => undefined,
|
|
175
|
-
unregisterAsset: () => undefined,
|
|
176
|
-
currentCompositionMetadata: null,
|
|
177
|
-
setCurrentCompositionMetadata: () => undefined,
|
|
178
|
-
assets: [],
|
|
179
|
-
};
|
|
180
|
-
}, [
|
|
181
|
-
component,
|
|
182
|
-
durationInFrames,
|
|
183
|
-
compositionHeight,
|
|
184
|
-
compositionWidth,
|
|
185
|
-
fps,
|
|
186
|
-
inputProps,
|
|
187
|
-
]);
|
|
188
128
|
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
189
129
|
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
190
130
|
}, [inputProps]);
|
|
@@ -195,9 +135,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
195
135
|
remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
|
|
196
136
|
}, []);
|
|
197
137
|
}
|
|
198
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
199
|
-
? clickToPlay
|
|
200
|
-
: Boolean(controls), showVolumeControls: Boolean(showVolumeControls), setMediaVolume: setMediaVolumeAndPersist, mediaVolume: mediaVolume, mediaMuted: mediaMuted, doubleClickToFullscreen: Boolean(doubleClickToFullscreen), setMediaMuted: setMediaMuted, spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null }) }) }) }) }) }) }) }) }));
|
|
138
|
+
return ((0, jsx_runtime_1.jsx)(SharedPlayerContext_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(emitter_context_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_1.default, { ref: rootRef, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: passedInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean' ? clickToPlay : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null }) }) }) }));
|
|
201
139
|
};
|
|
202
|
-
exports.
|
|
203
|
-
exports.Player = (0, react_1.forwardRef)(exports.PlayerFn);
|
|
140
|
+
exports.Player = (0, react_1.forwardRef)(PlayerFn);
|
package/dist/PlayerControls.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type { MouseEventHandler } from 'react';
|
|
1
|
+
import type { MouseEventHandler, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { usePlayer } from './use-player';
|
|
4
|
+
export declare type RenderPlayPauseButton = (props: {
|
|
5
|
+
playing: boolean;
|
|
6
|
+
}) => ReactNode;
|
|
7
|
+
export declare type RenderFullscreenButton = (props: {
|
|
8
|
+
isFullscreen: boolean;
|
|
9
|
+
}) => ReactNode;
|
|
10
|
+
export declare const X_SPACER = 10;
|
|
11
|
+
export declare const X_PADDING = 12;
|
|
4
12
|
declare global {
|
|
5
13
|
interface Document {
|
|
6
14
|
webkitFullscreenEnabled?: boolean;
|
|
@@ -26,4 +34,8 @@ export declare const Controls: React.FC<{
|
|
|
26
34
|
onSeekStart: () => void;
|
|
27
35
|
inFrame: number | null;
|
|
28
36
|
outFrame: number | null;
|
|
37
|
+
initiallyShowControls: number | boolean;
|
|
38
|
+
playerWidth: number;
|
|
39
|
+
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
40
|
+
renderFullscreenButton: RenderFullscreenButton | null;
|
|
29
41
|
}>;
|
package/dist/PlayerControls.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controls = void 0;
|
|
3
|
+
exports.Controls = exports.X_PADDING = exports.X_SPACER = 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");
|
|
@@ -8,6 +8,9 @@ const format_time_1 = require("./format-time");
|
|
|
8
8
|
const icons_1 = require("./icons");
|
|
9
9
|
const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
|
|
10
10
|
const PlayerSeekBar_1 = require("./PlayerSeekBar");
|
|
11
|
+
const use_video_controls_resize_1 = require("./use-video-controls-resize");
|
|
12
|
+
exports.X_SPACER = 10;
|
|
13
|
+
exports.X_PADDING = 12;
|
|
11
14
|
const containerStyle = {
|
|
12
15
|
boxSizing: 'border-box',
|
|
13
16
|
position: 'absolute',
|
|
@@ -17,8 +20,8 @@ const containerStyle = {
|
|
|
17
20
|
paddingBottom: 10,
|
|
18
21
|
background: 'linear-gradient(transparent, rgba(0, 0, 0, 0.4))',
|
|
19
22
|
display: 'flex',
|
|
20
|
-
paddingRight:
|
|
21
|
-
paddingLeft:
|
|
23
|
+
paddingRight: exports.X_PADDING,
|
|
24
|
+
paddingLeft: exports.X_PADDING,
|
|
22
25
|
flexDirection: 'column',
|
|
23
26
|
transition: 'opacity 0.3s',
|
|
24
27
|
};
|
|
@@ -57,23 +60,41 @@ const flex1 = {
|
|
|
57
60
|
flex: 1,
|
|
58
61
|
};
|
|
59
62
|
const fullscreen = {};
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
fontFamily: 'sans-serif',
|
|
63
|
-
fontSize: 14,
|
|
64
|
-
};
|
|
65
|
-
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, }) => {
|
|
63
|
+
const PlayPauseButton = ({ playing }) => playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {});
|
|
64
|
+
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, }) => {
|
|
66
65
|
const playButtonRef = (0, react_1.useRef)(null);
|
|
67
66
|
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
68
67
|
const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
|
|
68
|
+
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = (0, use_video_controls_resize_1.useVideoControlsResize)({ allowFullscreen, playerWidth });
|
|
69
|
+
const [shouldShowInitially, setInitiallyShowControls] = (0, react_1.useState)(() => {
|
|
70
|
+
if (typeof initiallyShowControls === 'boolean') {
|
|
71
|
+
return initiallyShowControls;
|
|
72
|
+
}
|
|
73
|
+
if (typeof initiallyShowControls === 'number') {
|
|
74
|
+
if (initiallyShowControls % 1 !== 0) {
|
|
75
|
+
throw new Error('initiallyShowControls must be an integer or a boolean');
|
|
76
|
+
}
|
|
77
|
+
if (Number.isNaN(initiallyShowControls)) {
|
|
78
|
+
throw new Error('initiallyShowControls must not be NaN');
|
|
79
|
+
}
|
|
80
|
+
if (!Number.isFinite(initiallyShowControls)) {
|
|
81
|
+
throw new Error('initiallyShowControls must be finite');
|
|
82
|
+
}
|
|
83
|
+
if (initiallyShowControls <= 0) {
|
|
84
|
+
throw new Error('initiallyShowControls must be a positive integer');
|
|
85
|
+
}
|
|
86
|
+
return initiallyShowControls;
|
|
87
|
+
}
|
|
88
|
+
throw new TypeError('initiallyShowControls must be a number or a boolean');
|
|
89
|
+
});
|
|
69
90
|
const containerCss = (0, react_1.useMemo)(() => {
|
|
70
91
|
// Hide if playing and mouse outside
|
|
71
|
-
const shouldShow = hovered || !player.playing;
|
|
92
|
+
const shouldShow = hovered || !player.playing || shouldShowInitially;
|
|
72
93
|
return {
|
|
73
94
|
...containerStyle,
|
|
74
95
|
opacity: Number(shouldShow),
|
|
75
96
|
};
|
|
76
|
-
}, [hovered, player.playing]);
|
|
97
|
+
}, [hovered, shouldShowInitially, player.playing]);
|
|
77
98
|
(0, react_1.useEffect)(() => {
|
|
78
99
|
if (playButtonRef.current && spaceKeyToPlayOrPause) {
|
|
79
100
|
// This switches focus to play button when player.playing flag changes
|
|
@@ -88,8 +109,30 @@ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVo
|
|
|
88
109
|
setSupportsFullscreen((_a = (typeof document !== 'undefined' &&
|
|
89
110
|
(document.fullscreenEnabled || document.webkitFullscreenEnabled))) !== null && _a !== void 0 ? _a : false);
|
|
90
111
|
}, []);
|
|
91
|
-
|
|
112
|
+
(0, react_1.useEffect)(() => {
|
|
113
|
+
if (shouldShowInitially === false) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const time = shouldShowInitially === true ? 2000 : shouldShowInitially;
|
|
117
|
+
const timeout = setTimeout(() => {
|
|
118
|
+
setInitiallyShowControls(false);
|
|
119
|
+
}, time);
|
|
120
|
+
return () => {
|
|
121
|
+
clearInterval(timeout);
|
|
122
|
+
};
|
|
123
|
+
}, [shouldShowInitially]);
|
|
124
|
+
const timeLabel = (0, react_1.useMemo)(() => {
|
|
125
|
+
return {
|
|
126
|
+
color: 'white',
|
|
127
|
+
fontFamily: 'sans-serif',
|
|
128
|
+
fontSize: 14,
|
|
129
|
+
maxWidth: maxTimeLabelWidth,
|
|
130
|
+
overflow: 'hidden',
|
|
131
|
+
textOverflow: 'ellipsis',
|
|
132
|
+
};
|
|
133
|
+
}, [maxTimeLabelWidth]);
|
|
134
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: buttonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: 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_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_1.formatTime)(frame / fps), " / ", (0, format_time_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), (0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: buttonStyle, onClick: isFullscreen
|
|
92
135
|
? onExitFullscreenButtonClick
|
|
93
|
-
: onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, {
|
|
136
|
+
: onFullscreenButtonClick, children: renderFullscreenButton === null ? ((0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { isFullscreen: isFullscreen })) : (renderFullscreenButton({ isFullscreen })) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_1.PlayerSeekBar, { onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, durationInFrames: durationInFrames, inFrame: inFrame, outFrame: outFrame })] }));
|
|
94
137
|
};
|
|
95
138
|
exports.Controls = Controls;
|
package/dist/PlayerSeekBar.d.ts
CHANGED
|
File without changes
|
package/dist/PlayerSeekBar.js
CHANGED
|
File without changes
|
package/dist/PlayerUI.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PlayerRef } from './player-methods';
|
|
3
|
+
import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
|
|
3
4
|
export declare type ErrorFallback = (info: {
|
|
4
5
|
error: Error;
|
|
5
6
|
}) => React.ReactNode;
|
|
6
7
|
export declare type RenderLoading = (canvas: {
|
|
7
8
|
height: number;
|
|
8
9
|
width: number;
|
|
9
|
-
}) => React.
|
|
10
|
+
}) => React.ReactNode;
|
|
10
11
|
export declare type RenderPoster = RenderLoading;
|
|
11
12
|
declare const _default: (props: {
|
|
12
13
|
controls: boolean;
|
|
@@ -15,14 +16,10 @@ declare const _default: (props: {
|
|
|
15
16
|
allowFullscreen: boolean;
|
|
16
17
|
inputProps: unknown;
|
|
17
18
|
showVolumeControls: boolean;
|
|
18
|
-
mediaMuted: boolean;
|
|
19
19
|
style?: React.CSSProperties | undefined;
|
|
20
20
|
clickToPlay: boolean;
|
|
21
21
|
doubleClickToFullscreen: boolean;
|
|
22
22
|
spaceKeyToPlayOrPause: boolean;
|
|
23
|
-
setMediaVolume: (v: number) => void;
|
|
24
|
-
setMediaMuted: (v: boolean) => void;
|
|
25
|
-
mediaVolume: number;
|
|
26
23
|
errorFallback: ErrorFallback;
|
|
27
24
|
playbackRate: number;
|
|
28
25
|
renderLoading: RenderLoading | undefined;
|
|
@@ -34,5 +31,8 @@ declare const _default: (props: {
|
|
|
34
31
|
showPosterWhenUnplayed: boolean;
|
|
35
32
|
inFrame: number | null;
|
|
36
33
|
outFrame: number | null;
|
|
34
|
+
initiallyShowControls: number | boolean;
|
|
35
|
+
renderPlayPauseButton: RenderPlayPauseButton | null;
|
|
36
|
+
renderFullscreen: RenderFullscreenButton | null;
|
|
37
37
|
} & React.RefAttributes<PlayerRef | null>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
38
38
|
export default _default;
|