@remotion/player 3.3.38 → 3.3.39
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/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/MediaVolumeSlider.d.ts +0 -5
- package/dist/MediaVolumeSlider.js +0 -118
- package/dist/Player.d.ts +0 -43
- package/dist/Player.js +0 -141
- package/dist/PlayerControls.d.ts +0 -41
- package/dist/PlayerControls.js +0 -138
- package/dist/PlayerSeekBar.d.ts +0 -8
- package/dist/PlayerSeekBar.js +0 -146
- package/dist/PlayerUI.d.ts +0 -38
- package/dist/PlayerUI.js +0 -308
- package/dist/SharedPlayerContext.d.ts +0 -14
- package/dist/SharedPlayerContext.js +0 -72
- package/dist/Thumbnail.d.ts +0 -20
- package/dist/Thumbnail.js +0 -42
- package/dist/ThumbnailUI.d.ts +0 -11
- package/dist/ThumbnailUI.js +0 -107
- package/dist/calculate-next-frame.d.ts +0 -14
- package/dist/calculate-next-frame.js +0 -28
- package/dist/calculate-scale.d.ts +0 -39
- package/dist/calculate-scale.js +0 -85
- package/dist/emitter-context.d.ts +0 -4
- package/dist/emitter-context.js +0 -9
- package/dist/error-boundary.d.ts +0 -19
- package/dist/error-boundary.js +0 -39
- package/dist/event-emitter.d.ts +0 -66
- package/dist/event-emitter.js +0 -87
- package/dist/format-time.d.ts +0 -1
- package/dist/format-time.js +0 -9
- package/dist/icons.d.ts +0 -10
- package/dist/icons.js +0 -50
- package/dist/index.d.ts +0 -61
- package/dist/index.js +0 -25
- package/dist/player-css-classname.d.ts +0 -1
- package/dist/player-css-classname.js +0 -4
- package/dist/player-methods.d.ts +0 -24
- package/dist/player-methods.js +0 -2
- package/dist/test/index.test.d.ts +0 -1
- package/dist/test/index.test.js +0 -9
- package/dist/test/test-utils.d.ts +0 -6
- package/dist/test/test-utils.js +0 -32
- package/dist/test/validate-in-out-frames.test.d.ts +0 -1
- package/dist/test/validate-in-out-frames.test.js +0 -56
- package/dist/test/validate-prop.test.d.ts +0 -1
- package/dist/test/validate-prop.test.js +0 -131
- package/dist/use-hover-state.d.ts +0 -1
- package/dist/use-hover-state.js +0 -27
- package/dist/use-playback.d.ts +0 -7
- package/dist/use-playback.js +0 -92
- package/dist/use-player.d.ts +0 -19
- package/dist/use-player.js +0 -132
- package/dist/use-thumbnail.d.ts +0 -6
- package/dist/use-thumbnail.js +0 -18
- package/dist/use-video-controls-resize.d.ts +0 -7
- package/dist/use-video-controls-resize.js +0 -36
- package/dist/utils/calculate-player-size.d.ts +0 -9
- package/dist/utils/calculate-player-size.js +0 -29
- package/dist/utils/cancellable-promise.d.ts +0 -5
- package/dist/utils/cancellable-promise.js +0 -26
- package/dist/utils/delay.d.ts +0 -1
- package/dist/utils/delay.js +0 -6
- package/dist/utils/is-node.d.ts +0 -1
- package/dist/utils/is-node.js +0 -4
- package/dist/utils/preview-size.d.ts +0 -8
- package/dist/utils/preview-size.js +0 -2
- package/dist/utils/props-if-has-props.d.ts +0 -5
- package/dist/utils/props-if-has-props.js +0 -2
- package/dist/utils/use-cancellable-promises.d.ts +0 -7
- package/dist/utils/use-cancellable-promises.js +0 -21
- package/dist/utils/use-click-prevention-on-double-click.d.ts +0 -3
- package/dist/utils/use-click-prevention-on-double-click.js +0 -45
- package/dist/utils/use-element-size.d.ts +0 -15
- package/dist/utils/use-element-size.js +0 -98
- package/dist/utils/validate-in-out-frame.d.ts +0 -6
- package/dist/utils/validate-in-out-frame.js +0 -54
- package/dist/utils/validate-initial-frame.d.ts +0 -4
- package/dist/utils/validate-initial-frame.js +0 -27
- package/dist/utils/validate-playbackrate.d.ts +0 -1
- package/dist/utils/validate-playbackrate.js +0 -18
- package/dist/volume-persistance.d.ts +0 -2
- package/dist/volume-persistance.js +0 -19
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const validate_in_out_frame_1 = require("../utils/validate-in-out-frame");
|
|
5
|
-
(0, vitest_1.test)('Validate in out frames', () => {
|
|
6
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
7
|
-
durationInFrames: 200,
|
|
8
|
-
inFrame: 201,
|
|
9
|
-
outFrame: undefined,
|
|
10
|
-
})).toThrow(/inFrame must be less than \(durationInFrames - 1\)/);
|
|
11
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
12
|
-
durationInFrames: 200,
|
|
13
|
-
inFrame: 199,
|
|
14
|
-
outFrame: 201,
|
|
15
|
-
})).toThrow(/outFrame must be less than \(durationInFrames - 1\)/);
|
|
16
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
17
|
-
durationInFrames: 200,
|
|
18
|
-
inFrame: -10,
|
|
19
|
-
outFrame: null,
|
|
20
|
-
})).toThrow(/inFrame must be greater than 0, but is -10/);
|
|
21
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
22
|
-
durationInFrames: 200,
|
|
23
|
-
inFrame: null,
|
|
24
|
-
outFrame: -10,
|
|
25
|
-
})).toThrow(/outFrame must be greater than 0, but is -10/);
|
|
26
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
27
|
-
durationInFrames: 200,
|
|
28
|
-
inFrame: 1.5,
|
|
29
|
-
outFrame: null,
|
|
30
|
-
})).toThrow(/"inFrame" must be an integer, but is 1.5/);
|
|
31
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
32
|
-
durationInFrames: 200,
|
|
33
|
-
inFrame: 20,
|
|
34
|
-
outFrame: 20,
|
|
35
|
-
})).toThrow(/outFrame must be greater than inFrame, but is 20/);
|
|
36
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
37
|
-
durationInFrames: 200,
|
|
38
|
-
inFrame: 21,
|
|
39
|
-
outFrame: 20,
|
|
40
|
-
})).toThrow(/outFrame must be greater than inFrame, but is 20 <= 21/);
|
|
41
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
42
|
-
durationInFrames: 200,
|
|
43
|
-
inFrame: null,
|
|
44
|
-
outFrame: 20,
|
|
45
|
-
})).not.toThrow();
|
|
46
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
47
|
-
durationInFrames: 200,
|
|
48
|
-
inFrame: null,
|
|
49
|
-
outFrame: null,
|
|
50
|
-
})).not.toThrow();
|
|
51
|
-
(0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
|
|
52
|
-
durationInFrames: 200,
|
|
53
|
-
inFrame: 10,
|
|
54
|
-
outFrame: 20,
|
|
55
|
-
})).not.toThrow();
|
|
56
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const remotion_1 = require("remotion");
|
|
5
|
-
const vitest_1 = require("vitest");
|
|
6
|
-
const index_1 = require("../index");
|
|
7
|
-
const test_utils_1 = require("./test-utils");
|
|
8
|
-
(0, vitest_1.test)('no compositionWidth should give errors', () => {
|
|
9
|
-
try {
|
|
10
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player
|
|
11
|
-
// @ts-expect-error
|
|
12
|
-
, {
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
compositionWidth: null, errorFallback: () => 'something went wrong', compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
(0, vitest_1.expect)(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
(0, vitest_1.test)('no compositionHeight should give errors', () => {
|
|
21
|
-
try {
|
|
22
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 400, errorFallback: () => 'something went wrong',
|
|
23
|
-
// @ts-expect-error
|
|
24
|
-
compositionHeight: undefined, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
(0, vitest_1.expect)(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
(0, vitest_1.test)('No fps should give errors', () => {
|
|
31
|
-
try {
|
|
32
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
|
|
33
|
-
// @ts-expect-error
|
|
34
|
-
fps: null, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
(0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
fps: undefined, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
(0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
(0, vitest_1.test)('No durationInFrames should give errors', () => {
|
|
49
|
-
try {
|
|
50
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30,
|
|
51
|
-
// @ts-expect-error
|
|
52
|
-
durationInFrames: undefined, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
(0, vitest_1.expect)(e.message).toMatch(/durationInFrames` must be a number, but is undefined/);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
(0, vitest_1.test)('Invalid playbackRate should give error', () => {
|
|
59
|
-
try {
|
|
60
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: -5 }));
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
(0, vitest_1.expect)(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
(0, vitest_1.test)('playbackRate of 0 should not be possible', () => {
|
|
67
|
-
try {
|
|
68
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: 0 }));
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
(0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
(0, vitest_1.test)('playbackRate of wrong type should not be possible', () => {
|
|
75
|
-
try {
|
|
76
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true,
|
|
77
|
-
// @ts-expect-error
|
|
78
|
-
playbackRate: 'hi' }));
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
(0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
(0, vitest_1.test)('playbackRate of undefined should be okay', () => {
|
|
85
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
86
|
-
(0, vitest_1.expect)(true).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
(0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
|
|
89
|
-
(0, vitest_1.expect)(() => {
|
|
90
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: remotion_1.Composition, controls: true, showVolumeControls: true, inputProps: {
|
|
91
|
-
id: 'HelloWorld',
|
|
92
|
-
width: 500,
|
|
93
|
-
height: 400,
|
|
94
|
-
fps: 30,
|
|
95
|
-
durationInFrames: 500,
|
|
96
|
-
component: test_utils_1.HelloWorld,
|
|
97
|
-
} }));
|
|
98
|
-
}).toThrow(/'component' must not be the 'Composition' component\. Pass your own React/);
|
|
99
|
-
});
|
|
100
|
-
(0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
|
|
101
|
-
(0, vitest_1.expect)(() => {
|
|
102
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500,
|
|
103
|
-
// @ts-expect-error
|
|
104
|
-
component: (0, jsx_runtime_1.jsx)(remotion_1.Composition, { durationInFrames: 30, fps: 30, height: 10, width: 10, id: "hello", component: test_utils_1.HelloWorld }), controls: true, showVolumeControls: true, inputProps: {
|
|
105
|
-
id: 'HelloWorld',
|
|
106
|
-
width: 500,
|
|
107
|
-
height: 400,
|
|
108
|
-
fps: 30,
|
|
109
|
-
durationInFrames: 500,
|
|
110
|
-
component: test_utils_1.HelloWorld,
|
|
111
|
-
} }));
|
|
112
|
-
}).toThrow(/'component' should not be an instance of <Composition\/>\. Pass the React component dir/);
|
|
113
|
-
});
|
|
114
|
-
vitest_1.test.each([
|
|
115
|
-
['controls'],
|
|
116
|
-
['loop'],
|
|
117
|
-
['autoPlay'],
|
|
118
|
-
['showVolumeControls'],
|
|
119
|
-
['allowFullscreen'],
|
|
120
|
-
['clickToPlay'],
|
|
121
|
-
['doubleClickToFullscreen'],
|
|
122
|
-
])('No durationInFrames should give errors %s', (a) => {
|
|
123
|
-
const props = {};
|
|
124
|
-
props[a] = 'hey';
|
|
125
|
-
try {
|
|
126
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30, durationInFrames: 100, component: test_utils_1.HelloWorld, ...props }));
|
|
127
|
-
}
|
|
128
|
-
catch (e) {
|
|
129
|
-
(0, vitest_1.expect)(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useHoverState: (ref: React.RefObject<HTMLDivElement>) => boolean;
|
package/dist/use-hover-state.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useHoverState = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useHoverState = (ref) => {
|
|
6
|
-
const [hovered, stetHovered] = (0, react_1.useState)(false);
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
8
|
-
const { current } = ref;
|
|
9
|
-
if (!current) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const onHover = () => {
|
|
13
|
-
stetHovered(true);
|
|
14
|
-
};
|
|
15
|
-
const onLeave = () => {
|
|
16
|
-
stetHovered(false);
|
|
17
|
-
};
|
|
18
|
-
current.addEventListener('mouseenter', onHover);
|
|
19
|
-
current.addEventListener('mouseleave', onLeave);
|
|
20
|
-
return () => {
|
|
21
|
-
current.removeEventListener('mouseenter', onHover);
|
|
22
|
-
current.removeEventListener('mouseenter', onLeave);
|
|
23
|
-
};
|
|
24
|
-
}, [ref]);
|
|
25
|
-
return hovered;
|
|
26
|
-
};
|
|
27
|
-
exports.useHoverState = useHoverState;
|
package/dist/use-playback.d.ts
DELETED
package/dist/use-playback.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePlayback = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const remotion_1 = require("remotion");
|
|
6
|
-
const calculate_next_frame_1 = require("./calculate-next-frame");
|
|
7
|
-
const use_player_1 = require("./use-player");
|
|
8
|
-
const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }) => {
|
|
9
|
-
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
10
|
-
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
11
|
-
const { playing, pause, emitter } = (0, use_player_1.usePlayer)();
|
|
12
|
-
const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
|
|
13
|
-
const frameRef = (0, react_1.useRef)(frame);
|
|
14
|
-
frameRef.current = frame;
|
|
15
|
-
const lastTimeUpdateEvent = (0, react_1.useRef)(null);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
17
|
-
if (!config) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (!playing) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
let hasBeenStopped = false;
|
|
24
|
-
let reqAnimFrameCall = null;
|
|
25
|
-
const startedTime = performance.now();
|
|
26
|
-
let framesAdvanced = 0;
|
|
27
|
-
const stop = () => {
|
|
28
|
-
hasBeenStopped = true;
|
|
29
|
-
if (reqAnimFrameCall !== null) {
|
|
30
|
-
cancelAnimationFrame(reqAnimFrameCall);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const callback = () => {
|
|
34
|
-
const time = performance.now() - startedTime;
|
|
35
|
-
const actualLastFrame = outFrame !== null && outFrame !== void 0 ? outFrame : config.durationInFrames - 1;
|
|
36
|
-
const actualFirstFrame = inFrame !== null && inFrame !== void 0 ? inFrame : 0;
|
|
37
|
-
const { nextFrame, framesToAdvance, hasEnded } = (0, calculate_next_frame_1.calculateNextFrame)({
|
|
38
|
-
time,
|
|
39
|
-
currentFrame: frameRef.current,
|
|
40
|
-
playbackSpeed: playbackRate,
|
|
41
|
-
fps: config.fps,
|
|
42
|
-
actualFirstFrame,
|
|
43
|
-
actualLastFrame,
|
|
44
|
-
framesAdvanced,
|
|
45
|
-
shouldLoop: loop,
|
|
46
|
-
});
|
|
47
|
-
framesAdvanced += framesToAdvance;
|
|
48
|
-
if (nextFrame !== frameRef.current &&
|
|
49
|
-
(!hasEnded || moveToBeginningWhenEnded)) {
|
|
50
|
-
setFrame(nextFrame);
|
|
51
|
-
}
|
|
52
|
-
if (hasEnded) {
|
|
53
|
-
stop();
|
|
54
|
-
pause();
|
|
55
|
-
emitter.dispatchEnded();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!hasBeenStopped) {
|
|
59
|
-
reqAnimFrameCall = requestAnimationFrame(callback);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
reqAnimFrameCall = requestAnimationFrame(callback);
|
|
63
|
-
return () => {
|
|
64
|
-
stop();
|
|
65
|
-
};
|
|
66
|
-
}, [
|
|
67
|
-
config,
|
|
68
|
-
loop,
|
|
69
|
-
pause,
|
|
70
|
-
playing,
|
|
71
|
-
setFrame,
|
|
72
|
-
emitter,
|
|
73
|
-
playbackRate,
|
|
74
|
-
inFrame,
|
|
75
|
-
outFrame,
|
|
76
|
-
moveToBeginningWhenEnded,
|
|
77
|
-
]);
|
|
78
|
-
(0, react_1.useEffect)(() => {
|
|
79
|
-
const interval = setInterval(() => {
|
|
80
|
-
if (lastTimeUpdateEvent.current === frameRef.current) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
emitter.dispatchTimeUpdate({ frame: frameRef.current });
|
|
84
|
-
lastTimeUpdateEvent.current = frameRef.current;
|
|
85
|
-
}, 250);
|
|
86
|
-
return () => clearInterval(interval);
|
|
87
|
-
}, [emitter]);
|
|
88
|
-
(0, react_1.useEffect)(() => {
|
|
89
|
-
emitter.dispatchFrameUpdate({ frame });
|
|
90
|
-
}, [emitter, frame]);
|
|
91
|
-
};
|
|
92
|
-
exports.usePlayback = usePlayback;
|
package/dist/use-player.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { SyntheticEvent } from 'react';
|
|
2
|
-
import type { PlayerEmitter } from './event-emitter';
|
|
3
|
-
declare type UsePlayerMethods = {
|
|
4
|
-
frameBack: (frames: number) => void;
|
|
5
|
-
frameForward: (frames: number) => void;
|
|
6
|
-
isLastFrame: boolean;
|
|
7
|
-
isFirstFrame: boolean;
|
|
8
|
-
emitter: PlayerEmitter;
|
|
9
|
-
playing: boolean;
|
|
10
|
-
play: (e?: SyntheticEvent) => void;
|
|
11
|
-
pause: () => void;
|
|
12
|
-
pauseAndReturnToPlayStart: () => void;
|
|
13
|
-
seek: (newFrame: number) => void;
|
|
14
|
-
getCurrentFrame: () => number;
|
|
15
|
-
isPlaying: () => boolean;
|
|
16
|
-
hasPlayed: boolean;
|
|
17
|
-
};
|
|
18
|
-
export declare const usePlayer: () => UsePlayerMethods;
|
|
19
|
-
export {};
|
package/dist/use-player.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePlayer = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const remotion_1 = require("remotion");
|
|
6
|
-
const emitter_context_1 = require("./emitter-context");
|
|
7
|
-
const usePlayer = () => {
|
|
8
|
-
var _a;
|
|
9
|
-
const [playing, setPlaying, imperativePlaying] = remotion_1.Internals.Timeline.usePlayingState();
|
|
10
|
-
const [hasPlayed, setHasPlayed] = (0, react_1.useState)(false);
|
|
11
|
-
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
12
|
-
const playStart = (0, react_1.useRef)(frame);
|
|
13
|
-
const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
|
|
14
|
-
const setTimelinePosition = remotion_1.Internals.Timeline.useTimelineSetFrame();
|
|
15
|
-
const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
|
|
16
|
-
const { audioAndVideoTags } = (0, react_1.useContext)(remotion_1.Internals.Timeline.TimelineContext);
|
|
17
|
-
const frameRef = (0, react_1.useRef)();
|
|
18
|
-
frameRef.current = frame;
|
|
19
|
-
const video = remotion_1.Internals.useVideo();
|
|
20
|
-
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
21
|
-
const emitter = (0, react_1.useContext)(emitter_context_1.PlayerEventEmitterContext);
|
|
22
|
-
const lastFrame = ((_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
|
|
23
|
-
const isLastFrame = frame === lastFrame;
|
|
24
|
-
const isFirstFrame = frame === 0;
|
|
25
|
-
if (!emitter) {
|
|
26
|
-
throw new TypeError('Expected Player event emitter context');
|
|
27
|
-
}
|
|
28
|
-
const seek = (0, react_1.useCallback)((newFrame) => {
|
|
29
|
-
setTimelinePosition(newFrame);
|
|
30
|
-
emitter.dispatchSeek(newFrame);
|
|
31
|
-
}, [emitter, setTimelinePosition]);
|
|
32
|
-
const play = (0, react_1.useCallback)((e) => {
|
|
33
|
-
if (imperativePlaying.current) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
setHasPlayed(true);
|
|
37
|
-
if (isLastFrame) {
|
|
38
|
-
seek(0);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Play silent audio tags to warm them up for autoplay
|
|
42
|
-
*/
|
|
43
|
-
if (audioContext && audioContext.numberOfAudioTags > 0 && e) {
|
|
44
|
-
audioContext.playAllAudios();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Play audios and videos directly here so they can benefit from
|
|
48
|
-
* being triggered by a click
|
|
49
|
-
*/
|
|
50
|
-
audioAndVideoTags.current.forEach((a) => a.play());
|
|
51
|
-
imperativePlaying.current = true;
|
|
52
|
-
setPlaying(true);
|
|
53
|
-
playStart.current = frameRef.current;
|
|
54
|
-
emitter.dispatchPlay();
|
|
55
|
-
}, [
|
|
56
|
-
imperativePlaying,
|
|
57
|
-
isLastFrame,
|
|
58
|
-
audioContext,
|
|
59
|
-
setPlaying,
|
|
60
|
-
emitter,
|
|
61
|
-
seek,
|
|
62
|
-
audioAndVideoTags,
|
|
63
|
-
]);
|
|
64
|
-
const pause = (0, react_1.useCallback)(() => {
|
|
65
|
-
if (imperativePlaying.current) {
|
|
66
|
-
imperativePlaying.current = false;
|
|
67
|
-
setPlaying(false);
|
|
68
|
-
emitter.dispatchPause();
|
|
69
|
-
}
|
|
70
|
-
}, [emitter, imperativePlaying, setPlaying]);
|
|
71
|
-
const pauseAndReturnToPlayStart = (0, react_1.useCallback)(() => {
|
|
72
|
-
if (imperativePlaying.current) {
|
|
73
|
-
imperativePlaying.current = false;
|
|
74
|
-
setTimelinePosition(playStart.current);
|
|
75
|
-
setPlaying(false);
|
|
76
|
-
emitter.dispatchPause();
|
|
77
|
-
}
|
|
78
|
-
}, [emitter, imperativePlaying, setPlaying, setTimelinePosition]);
|
|
79
|
-
const hasVideo = Boolean(video);
|
|
80
|
-
const frameBack = (0, react_1.useCallback)((frames) => {
|
|
81
|
-
if (!hasVideo) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
if (imperativePlaying.current) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
setFrame((f) => {
|
|
88
|
-
return Math.max(0, f - frames);
|
|
89
|
-
});
|
|
90
|
-
}, [hasVideo, imperativePlaying, setFrame]);
|
|
91
|
-
const frameForward = (0, react_1.useCallback)((frames) => {
|
|
92
|
-
if (!hasVideo) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
if (imperativePlaying.current) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
setFrame((f) => Math.min(lastFrame, f + frames));
|
|
99
|
-
}, [hasVideo, imperativePlaying, lastFrame, setFrame]);
|
|
100
|
-
const returnValue = (0, react_1.useMemo)(() => {
|
|
101
|
-
return {
|
|
102
|
-
frameBack,
|
|
103
|
-
frameForward,
|
|
104
|
-
isLastFrame,
|
|
105
|
-
emitter,
|
|
106
|
-
playing,
|
|
107
|
-
play,
|
|
108
|
-
pause,
|
|
109
|
-
seek,
|
|
110
|
-
isFirstFrame,
|
|
111
|
-
getCurrentFrame: () => frameRef.current,
|
|
112
|
-
isPlaying: () => imperativePlaying.current,
|
|
113
|
-
pauseAndReturnToPlayStart,
|
|
114
|
-
hasPlayed,
|
|
115
|
-
};
|
|
116
|
-
}, [
|
|
117
|
-
frameBack,
|
|
118
|
-
frameForward,
|
|
119
|
-
isLastFrame,
|
|
120
|
-
emitter,
|
|
121
|
-
playing,
|
|
122
|
-
play,
|
|
123
|
-
pause,
|
|
124
|
-
seek,
|
|
125
|
-
isFirstFrame,
|
|
126
|
-
pauseAndReturnToPlayStart,
|
|
127
|
-
imperativePlaying,
|
|
128
|
-
hasPlayed,
|
|
129
|
-
]);
|
|
130
|
-
return returnValue;
|
|
131
|
-
};
|
|
132
|
-
exports.usePlayer = usePlayer;
|
package/dist/use-thumbnail.d.ts
DELETED
package/dist/use-thumbnail.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useThumbnail = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const emitter_context_1 = require("./emitter-context");
|
|
6
|
-
const useThumbnail = () => {
|
|
7
|
-
const emitter = (0, react_1.useContext)(emitter_context_1.ThumbnailEmitterContext);
|
|
8
|
-
if (!emitter) {
|
|
9
|
-
throw new TypeError('Expected Player event emitter context');
|
|
10
|
-
}
|
|
11
|
-
const returnValue = (0, react_1.useMemo)(() => {
|
|
12
|
-
return {
|
|
13
|
-
emitter,
|
|
14
|
-
};
|
|
15
|
-
}, [emitter]);
|
|
16
|
-
return returnValue;
|
|
17
|
-
};
|
|
18
|
-
exports.useThumbnail = useThumbnail;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useVideoControlsResize = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const icons_1 = require("./icons");
|
|
6
|
-
const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
|
|
7
|
-
const PlayerControls_1 = require("./PlayerControls");
|
|
8
|
-
const useVideoControlsResize = ({ allowFullscreen: allowFullScreen, playerWidth, }) => {
|
|
9
|
-
const resizeInfo = (0, react_1.useMemo)(() => {
|
|
10
|
-
const playPauseIconSize = icons_1.ICON_SIZE;
|
|
11
|
-
const volumeIconSize = icons_1.ICON_SIZE;
|
|
12
|
-
const _fullscreenIconSize = allowFullScreen ? icons_1.fullscreenIconSize : 0;
|
|
13
|
-
const elementsSize = volumeIconSize +
|
|
14
|
-
playPauseIconSize +
|
|
15
|
-
_fullscreenIconSize +
|
|
16
|
-
PlayerControls_1.X_PADDING * 2 +
|
|
17
|
-
PlayerControls_1.X_SPACER * 2;
|
|
18
|
-
const maxTimeLabelWidth = playerWidth - elementsSize;
|
|
19
|
-
const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
|
|
20
|
-
const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH;
|
|
21
|
-
// If max label width is lower than the volume width
|
|
22
|
-
// then it means we need to take it's width as the max label width
|
|
23
|
-
// otherwise we took the available width when volume open
|
|
24
|
-
const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen < MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH
|
|
25
|
-
? maxTimeLabelWidthWithoutNegativeValue
|
|
26
|
-
: availableTimeLabelWidthIfVolumeOpen;
|
|
27
|
-
const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize + MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH;
|
|
28
|
-
const displayVerticalVolumeSlider = playerWidth < minWidthForHorizontalDisplay;
|
|
29
|
-
return {
|
|
30
|
-
maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue,
|
|
31
|
-
displayVerticalVolumeSlider,
|
|
32
|
-
};
|
|
33
|
-
}, [allowFullScreen, playerWidth]);
|
|
34
|
-
return resizeInfo;
|
|
35
|
-
};
|
|
36
|
-
exports.useVideoControlsResize = useVideoControlsResize;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { StandardLonghandProperties } from 'csstype';
|
|
2
|
-
import type { Size } from './use-element-size';
|
|
3
|
-
export declare const calculatePlayerSize: ({ currentSize, width, height, compositionWidth, compositionHeight, }: {
|
|
4
|
-
currentSize: Size | null;
|
|
5
|
-
width: StandardLonghandProperties['width'] | undefined;
|
|
6
|
-
height: StandardLonghandProperties['height'] | undefined;
|
|
7
|
-
compositionWidth: number;
|
|
8
|
-
compositionHeight: number;
|
|
9
|
-
}) => React.CSSProperties;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculatePlayerSize = void 0;
|
|
4
|
-
const calculatePlayerSize = ({ currentSize, width, height, compositionWidth, compositionHeight, }) => {
|
|
5
|
-
const aspectRatio = compositionWidth / compositionHeight;
|
|
6
|
-
if (!currentSize) {
|
|
7
|
-
return {
|
|
8
|
-
width: compositionWidth,
|
|
9
|
-
height: compositionHeight,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
// If has width specified, but no height, specify a default height that satisfies the aspect ratio.
|
|
13
|
-
if (width !== undefined && height === undefined) {
|
|
14
|
-
return {
|
|
15
|
-
height: currentSize.width / aspectRatio,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
// Opposite: If has height specified, evaluate the height and specify a default width.
|
|
19
|
-
if (height !== undefined && width === undefined) {
|
|
20
|
-
return {
|
|
21
|
-
width: currentSize.height * aspectRatio,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
width: compositionWidth,
|
|
26
|
-
height: compositionHeight,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
exports.calculatePlayerSize = calculatePlayerSize;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cancellablePromise = void 0;
|
|
4
|
-
const cancellablePromise = (promise) => {
|
|
5
|
-
let isCanceled = false;
|
|
6
|
-
const wrappedPromise = new Promise((resolve, reject) => {
|
|
7
|
-
promise
|
|
8
|
-
.then((value) => {
|
|
9
|
-
if (isCanceled) {
|
|
10
|
-
reject({ isCanceled, value });
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
resolve(value);
|
|
14
|
-
})
|
|
15
|
-
.catch((error) => {
|
|
16
|
-
reject({ isCanceled, error });
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
promise: wrappedPromise,
|
|
21
|
-
cancel: () => {
|
|
22
|
-
isCanceled = true;
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
exports.cancellablePromise = cancellablePromise;
|
package/dist/utils/delay.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const delay: (n: number) => Promise<unknown>;
|
package/dist/utils/delay.js
DELETED
package/dist/utils/is-node.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const IS_NODE: boolean;
|
package/dist/utils/is-node.js
DELETED