@remotion/player 4.0.0-webhook.26 → 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/package.json
CHANGED
|
@@ -1,67 +1,81 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
2
|
+
"name": "@remotion/player",
|
|
3
|
+
"version": "4.1.0-alpha1",
|
|
4
|
+
"description": "Remotion Player",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"types": "dist/cjs/index.d.ts",
|
|
7
|
+
"module": "dist/esm/index.mjs",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/cjs/index.d.ts",
|
|
13
|
+
"module": "./dist/esm/index.mjs",
|
|
14
|
+
"import": "./dist/esm/index.mjs",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"url": "https://github.com/remotion-dev/remotion"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"author": "Jonny Burger <jonny@remotion.dev>",
|
|
29
|
+
"maintainers": [
|
|
30
|
+
"Jonny Burger <jonny@remotion.dev>",
|
|
31
|
+
"Shankhadeep Dey <shankhadeepdey99@gmail.com>"
|
|
32
|
+
],
|
|
33
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"remotion": "4.1.0-alpha1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": ">=16.8.0",
|
|
39
|
+
"react-dom": ">=16.8.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@jonny/eslint-config": "3.0.273",
|
|
43
|
+
"@rollup/plugin-typescript": "^8.2.0",
|
|
44
|
+
"@testing-library/react": "13.1.1",
|
|
45
|
+
"@types/node": "18.14.6",
|
|
46
|
+
"@types/react": "18.0.26",
|
|
47
|
+
"@types/react-dom": "18.0.10",
|
|
48
|
+
"@vitejs/plugin-react": "^2.0.0",
|
|
49
|
+
"csstype": "^3.1.1",
|
|
50
|
+
"eslint": "8.42.0",
|
|
51
|
+
"eslint-plugin-require-extensions": "^0.1.2",
|
|
52
|
+
"jsdom": "20.0.1",
|
|
53
|
+
"prettier": "^2.7.1",
|
|
54
|
+
"prettier-plugin-organize-imports": "^2.3.4",
|
|
55
|
+
"react": "^18.0.0",
|
|
56
|
+
"react-dom": "^18.0.0",
|
|
57
|
+
"rollup": "^2.70.1",
|
|
58
|
+
"rollup-plugin-banner2": "^1.2.2",
|
|
59
|
+
"typescript": "4.9.5",
|
|
60
|
+
"vitest": "0.31.1",
|
|
61
|
+
"webpack": "5.83.1",
|
|
62
|
+
"zod": "^3.21.4"
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"remotion",
|
|
66
|
+
"ffmpeg",
|
|
67
|
+
"video",
|
|
68
|
+
"react",
|
|
69
|
+
"player"
|
|
70
|
+
],
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"formatting": "prettier src --check",
|
|
76
|
+
"lint": "eslint src --ext ts,tsx",
|
|
77
|
+
"build": "node ensure-correct-version.js && rollup --config rollup.config.js && tsc -d",
|
|
78
|
+
"watch": "tsc -w",
|
|
79
|
+
"prerelease": "cp ../../README.md ."
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/Player.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ComponentType, MutableRefObject } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { CompProps } from 'remotion';
|
|
4
|
-
import type { PlayerRef } from './player-methods';
|
|
5
|
-
import type { RenderLoading, RenderPoster } from './PlayerUI';
|
|
6
|
-
declare type PropsIfHasProps<Props> = {} extends Props ? {
|
|
7
|
-
inputProps?: Props;
|
|
8
|
-
} : {
|
|
9
|
-
inputProps: Props;
|
|
10
|
-
};
|
|
11
|
-
export declare type ErrorFallback = (info: {
|
|
12
|
-
error: Error;
|
|
13
|
-
}) => React.ReactNode;
|
|
14
|
-
export declare type PlayerProps<T> = {
|
|
15
|
-
durationInFrames: number;
|
|
16
|
-
compositionWidth: number;
|
|
17
|
-
compositionHeight: number;
|
|
18
|
-
fps: number;
|
|
19
|
-
showVolumeControls?: boolean;
|
|
20
|
-
controls?: boolean;
|
|
21
|
-
errorFallback?: ErrorFallback;
|
|
22
|
-
style?: React.CSSProperties;
|
|
23
|
-
loop?: boolean;
|
|
24
|
-
autoPlay?: boolean;
|
|
25
|
-
allowFullscreen?: boolean;
|
|
26
|
-
clickToPlay?: boolean;
|
|
27
|
-
doubleClickToFullscreen?: boolean;
|
|
28
|
-
spaceKeyToPlayOrPause?: boolean;
|
|
29
|
-
numberOfSharedAudioTags?: number;
|
|
30
|
-
playbackRate?: number;
|
|
31
|
-
renderLoading?: RenderLoading;
|
|
32
|
-
moveToBeginningWhenEnded?: boolean;
|
|
33
|
-
className?: string;
|
|
34
|
-
initialFrame?: number;
|
|
35
|
-
renderPoster?: RenderPoster;
|
|
36
|
-
showPosterWhenPaused?: boolean;
|
|
37
|
-
showPosterWhenEnded?: boolean;
|
|
38
|
-
showPosterWhenUnplayed?: boolean;
|
|
39
|
-
inFrame?: number | null;
|
|
40
|
-
outFrame?: number | null;
|
|
41
|
-
initiallyShowControls?: number | boolean;
|
|
42
|
-
} & PropsIfHasProps<T> & CompProps<T>;
|
|
43
|
-
export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
|
|
44
|
-
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, initiallyShowControls, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
|
|
45
|
-
declare module 'react' {
|
|
46
|
-
function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
47
|
-
}
|
|
48
|
-
export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
|
|
49
|
-
export {};
|
package/dist/PlayerControls.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controls = exports.X_PADDING = exports.X_SPACER = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
|
-
const format_time_1 = require("./format-time");
|
|
8
|
-
const icons_1 = require("./icons");
|
|
9
|
-
const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
|
|
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;
|
|
14
|
-
const containerStyle = {
|
|
15
|
-
boxSizing: 'border-box',
|
|
16
|
-
position: 'absolute',
|
|
17
|
-
bottom: 0,
|
|
18
|
-
width: '100%',
|
|
19
|
-
paddingTop: 10,
|
|
20
|
-
paddingBottom: 10,
|
|
21
|
-
background: 'linear-gradient(transparent, rgba(0, 0, 0, 0.4))',
|
|
22
|
-
display: 'flex',
|
|
23
|
-
paddingRight: exports.X_PADDING,
|
|
24
|
-
paddingLeft: exports.X_PADDING,
|
|
25
|
-
flexDirection: 'column',
|
|
26
|
-
transition: 'opacity 0.3s',
|
|
27
|
-
};
|
|
28
|
-
const buttonStyle = {
|
|
29
|
-
appearance: 'none',
|
|
30
|
-
backgroundColor: 'transparent',
|
|
31
|
-
border: 'none',
|
|
32
|
-
cursor: 'pointer',
|
|
33
|
-
padding: 0,
|
|
34
|
-
display: 'inline',
|
|
35
|
-
marginBottom: 0,
|
|
36
|
-
marginTop: 0,
|
|
37
|
-
height: 25,
|
|
38
|
-
};
|
|
39
|
-
const controlsRow = {
|
|
40
|
-
display: 'flex',
|
|
41
|
-
flexDirection: 'row',
|
|
42
|
-
width: '100%',
|
|
43
|
-
alignItems: 'center',
|
|
44
|
-
justifyContent: 'center',
|
|
45
|
-
userSelect: 'none',
|
|
46
|
-
};
|
|
47
|
-
const leftPartStyle = {
|
|
48
|
-
display: 'flex',
|
|
49
|
-
flexDirection: 'row',
|
|
50
|
-
userSelect: 'none',
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
};
|
|
53
|
-
const xSpacer = {
|
|
54
|
-
width: 10,
|
|
55
|
-
};
|
|
56
|
-
const ySpacer = {
|
|
57
|
-
height: 8,
|
|
58
|
-
};
|
|
59
|
-
const flex1 = {
|
|
60
|
-
flex: 1,
|
|
61
|
-
};
|
|
62
|
-
const fullscreen = {};
|
|
63
|
-
const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, }) => {
|
|
64
|
-
const playButtonRef = (0, react_1.useRef)(null);
|
|
65
|
-
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
66
|
-
const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
|
|
67
|
-
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = (0, use_video_controls_resize_1.useVideoControlsResize)({ allowFullscreen, playerWidth });
|
|
68
|
-
const [shouldShowInitially, setInitiallyShowControls] = (0, react_1.useState)(() => {
|
|
69
|
-
if (typeof initiallyShowControls === 'boolean') {
|
|
70
|
-
return initiallyShowControls;
|
|
71
|
-
}
|
|
72
|
-
if (typeof initiallyShowControls === 'number') {
|
|
73
|
-
if (initiallyShowControls % 1 !== 0) {
|
|
74
|
-
throw new Error('initiallyShowControls must be an integer or a boolean');
|
|
75
|
-
}
|
|
76
|
-
if (Number.isNaN(initiallyShowControls)) {
|
|
77
|
-
throw new Error('initiallyShowControls must not be NaN');
|
|
78
|
-
}
|
|
79
|
-
if (!Number.isFinite(initiallyShowControls)) {
|
|
80
|
-
throw new Error('initiallyShowControls must be finite');
|
|
81
|
-
}
|
|
82
|
-
if (initiallyShowControls <= 0) {
|
|
83
|
-
throw new Error('initiallyShowControls must be a positive integer');
|
|
84
|
-
}
|
|
85
|
-
return initiallyShowControls;
|
|
86
|
-
}
|
|
87
|
-
throw new TypeError('initiallyShowControls must be a number or a boolean');
|
|
88
|
-
});
|
|
89
|
-
const containerCss = (0, react_1.useMemo)(() => {
|
|
90
|
-
// Hide if playing and mouse outside
|
|
91
|
-
const shouldShow = hovered || !player.playing || shouldShowInitially;
|
|
92
|
-
return {
|
|
93
|
-
...containerStyle,
|
|
94
|
-
opacity: Number(shouldShow),
|
|
95
|
-
};
|
|
96
|
-
}, [hovered, shouldShowInitially, player.playing]);
|
|
97
|
-
(0, react_1.useEffect)(() => {
|
|
98
|
-
if (playButtonRef.current && spaceKeyToPlayOrPause) {
|
|
99
|
-
// This switches focus to play button when player.playing flag changes
|
|
100
|
-
playButtonRef.current.focus({
|
|
101
|
-
preventScroll: true,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}, [player.playing, spaceKeyToPlayOrPause]);
|
|
105
|
-
(0, react_1.useEffect)(() => {
|
|
106
|
-
var _a;
|
|
107
|
-
// Must be handled client-side to avoid SSR hydration mismatch
|
|
108
|
-
setSupportsFullscreen((_a = (typeof document !== 'undefined' &&
|
|
109
|
-
(document.fullscreenEnabled || document.webkitFullscreenEnabled))) !== null && _a !== void 0 ? _a : false);
|
|
110
|
-
}, []);
|
|
111
|
-
(0, react_1.useEffect)(() => {
|
|
112
|
-
if (shouldShowInitially === false) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const time = shouldShowInitially === true ? 2000 : shouldShowInitially;
|
|
116
|
-
const timeout = setTimeout(() => {
|
|
117
|
-
setInitiallyShowControls(false);
|
|
118
|
-
}, time);
|
|
119
|
-
return () => {
|
|
120
|
-
clearInterval(timeout);
|
|
121
|
-
};
|
|
122
|
-
}, [shouldShowInitially]);
|
|
123
|
-
const timeLabel = (0, react_1.useMemo)(() => {
|
|
124
|
-
return {
|
|
125
|
-
color: 'white',
|
|
126
|
-
fontFamily: 'sans-serif',
|
|
127
|
-
fontSize: 14,
|
|
128
|
-
maxWidth: maxTimeLabelWidth,
|
|
129
|
-
overflow: 'hidden',
|
|
130
|
-
textOverflow: 'ellipsis',
|
|
131
|
-
};
|
|
132
|
-
}, [maxTimeLabelWidth]);
|
|
133
|
-
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: player.playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {}) }), 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
|
|
134
|
-
? onExitFullscreenButtonClick
|
|
135
|
-
: onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { minimized: !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 })] }));
|
|
136
|
-
};
|
|
137
|
-
exports.Controls = Controls;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { PreviewSize } from './utils/preview-size';
|
|
2
|
-
import type { Size } from './utils/use-element-size';
|
|
3
|
-
export declare const calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
|
|
4
|
-
previewSize: PreviewSize['size'];
|
|
5
|
-
compositionWidth: number;
|
|
6
|
-
compositionHeight: number;
|
|
7
|
-
canvasSize: Size;
|
|
8
|
-
}) => number;
|
|
9
|
-
export declare const calculateCanvasTransformation: ({ previewSize, compositionWidth, compositionHeight, canvasSize, }: {
|
|
10
|
-
previewSize: PreviewSize['size'];
|
|
11
|
-
compositionWidth: number;
|
|
12
|
-
compositionHeight: number;
|
|
13
|
-
canvasSize: Size;
|
|
14
|
-
}) => {
|
|
15
|
-
centerX: number;
|
|
16
|
-
centerY: number;
|
|
17
|
-
xCorrection: number;
|
|
18
|
-
yCorrection: number;
|
|
19
|
-
scale: number;
|
|
20
|
-
};
|
package/dist/calculate-scale.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateCanvasTransformation = exports.calculateScale = void 0;
|
|
4
|
-
const calculateScale = ({ canvasSize, compositionHeight, compositionWidth, previewSize, }) => {
|
|
5
|
-
const heightRatio = canvasSize.height / compositionHeight;
|
|
6
|
-
const widthRatio = canvasSize.width / compositionWidth;
|
|
7
|
-
const ratio = Math.min(heightRatio, widthRatio);
|
|
8
|
-
return previewSize === 'auto' ? ratio : Number(previewSize);
|
|
9
|
-
};
|
|
10
|
-
exports.calculateScale = calculateScale;
|
|
11
|
-
const calculateCanvasTransformation = ({ previewSize, compositionWidth, compositionHeight, canvasSize, }) => {
|
|
12
|
-
const scale = (0, exports.calculateScale)({
|
|
13
|
-
canvasSize,
|
|
14
|
-
compositionHeight,
|
|
15
|
-
compositionWidth,
|
|
16
|
-
previewSize,
|
|
17
|
-
});
|
|
18
|
-
const correction = 0 - (1 - scale) / 2;
|
|
19
|
-
const xCorrection = correction * compositionWidth;
|
|
20
|
-
const yCorrection = correction * compositionHeight;
|
|
21
|
-
const width = compositionWidth * scale;
|
|
22
|
-
const height = compositionHeight * scale;
|
|
23
|
-
const centerX = canvasSize.width / 2 - width / 2;
|
|
24
|
-
const centerY = canvasSize.height / 2 - height / 2;
|
|
25
|
-
return {
|
|
26
|
-
centerX,
|
|
27
|
-
centerY,
|
|
28
|
-
xCorrection,
|
|
29
|
-
yCorrection,
|
|
30
|
-
scale,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
exports.calculateCanvasTransformation = calculateCanvasTransformation;
|
package/dist/event-emitter.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
declare type SeekPayload = {
|
|
2
|
-
frame: number;
|
|
3
|
-
};
|
|
4
|
-
declare type ErrorPayload = {
|
|
5
|
-
error: Error;
|
|
6
|
-
};
|
|
7
|
-
declare type TimeUpdateEventPayload = {
|
|
8
|
-
frame: number;
|
|
9
|
-
};
|
|
10
|
-
declare type FrameUpdateEventPayload = {
|
|
11
|
-
frame: number;
|
|
12
|
-
};
|
|
13
|
-
declare type RateChangeEventPayload = {
|
|
14
|
-
playbackRate: number;
|
|
15
|
-
};
|
|
16
|
-
declare type FullscreenChangeEventPayload = {
|
|
17
|
-
isFullscreen: boolean;
|
|
18
|
-
};
|
|
19
|
-
declare type StateEventMap = {
|
|
20
|
-
seeked: SeekPayload;
|
|
21
|
-
pause: undefined;
|
|
22
|
-
play: undefined;
|
|
23
|
-
ratechange: RateChangeEventPayload;
|
|
24
|
-
ended: undefined;
|
|
25
|
-
error: ErrorPayload;
|
|
26
|
-
timeupdate: TimeUpdateEventPayload;
|
|
27
|
-
frameupdate: FrameUpdateEventPayload;
|
|
28
|
-
fullscreenchange: FullscreenChangeEventPayload;
|
|
29
|
-
};
|
|
30
|
-
export declare type EventTypes = keyof StateEventMap;
|
|
31
|
-
export declare type CallbackListener<T extends EventTypes> = (data: {
|
|
32
|
-
detail: StateEventMap[T];
|
|
33
|
-
}) => void;
|
|
34
|
-
declare type Listeners = {
|
|
35
|
-
[EventType in EventTypes]: CallbackListener<EventType>[];
|
|
36
|
-
};
|
|
37
|
-
export declare class PlayerEmitter {
|
|
38
|
-
listeners: Listeners;
|
|
39
|
-
addEventListener<Q extends EventTypes>(name: Q, callback: CallbackListener<Q>): void;
|
|
40
|
-
removeEventListener<Q extends EventTypes>(name: Q, callback: CallbackListener<Q>): void;
|
|
41
|
-
private dispatchEvent;
|
|
42
|
-
dispatchSeek(frame: number): void;
|
|
43
|
-
dispatchPause(): void;
|
|
44
|
-
dispatchPlay(): void;
|
|
45
|
-
dispatchEnded(): void;
|
|
46
|
-
dispatchRatechange(playbackRate: number): void;
|
|
47
|
-
dispatchError(error: Error): void;
|
|
48
|
-
dispatchTimeUpdate(event: TimeUpdateEventPayload): void;
|
|
49
|
-
dispatchFrameUpdate(event: FrameUpdateEventPayload): void;
|
|
50
|
-
dispatchFullscreenChangeUpdate(event: FullscreenChangeEventPayload): void;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
package/dist/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlayerInternals = exports.Player = void 0;
|
|
4
|
-
const calculate_scale_1 = require("./calculate-scale");
|
|
5
|
-
const emitter_context_1 = require("./emitter-context");
|
|
6
|
-
const event_emitter_1 = require("./event-emitter");
|
|
7
|
-
const use_hover_state_1 = require("./use-hover-state");
|
|
8
|
-
const use_playback_1 = require("./use-playback");
|
|
9
|
-
const use_player_1 = require("./use-player");
|
|
10
|
-
const use_element_size_1 = require("./utils/use-element-size");
|
|
11
|
-
var Player_1 = require("./Player");
|
|
12
|
-
Object.defineProperty(exports, "Player", { enumerable: true, get: function () { return Player_1.Player; } });
|
|
13
|
-
exports.PlayerInternals = {
|
|
14
|
-
PlayerEventEmitterContext: emitter_context_1.PlayerEventEmitterContext,
|
|
15
|
-
PlayerEmitter: event_emitter_1.PlayerEmitter,
|
|
16
|
-
usePlayer: use_player_1.usePlayer,
|
|
17
|
-
usePlayback: use_playback_1.usePlayback,
|
|
18
|
-
useElementSize: use_element_size_1.useElementSize,
|
|
19
|
-
calculateCanvasTransformation: calculate_scale_1.calculateCanvasTransformation,
|
|
20
|
-
useHoverState: use_hover_state_1.useHoverState,
|
|
21
|
-
updateAllElementsSizes: use_element_size_1.updateAllElementsSizes,
|
|
22
|
-
calculateScale: calculate_scale_1.calculateScale,
|
|
23
|
-
};
|
package/dist/test/index.test.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const use_player_1 = require("../use-player");
|
|
4
|
-
test('It should throw an error if not being used inside a RemotionRoot', () => {
|
|
5
|
-
expect(() => {
|
|
6
|
-
(0, use_player_1.usePlayer)();
|
|
7
|
-
}).toThrow();
|
|
8
|
-
});
|
|
@@ -1,130 +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 index_1 = require("../index");
|
|
6
|
-
const test_utils_1 = require("./test-utils");
|
|
7
|
-
test('no compositionWidth should give errors', () => {
|
|
8
|
-
try {
|
|
9
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player
|
|
10
|
-
// @ts-expect-error
|
|
11
|
-
, {
|
|
12
|
-
// @ts-expect-error
|
|
13
|
-
compositionWidth: null, errorFallback: () => 'something went wrong', compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
expect(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
test('no compositionHeight should give errors', () => {
|
|
20
|
-
try {
|
|
21
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 400, errorFallback: () => 'something went wrong',
|
|
22
|
-
// @ts-expect-error
|
|
23
|
-
compositionHeight: undefined, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
expect(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
test('No fps should give errors', () => {
|
|
30
|
-
try {
|
|
31
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
|
|
32
|
-
// @ts-expect-error
|
|
33
|
-
fps: null, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
34
|
-
}
|
|
35
|
-
catch (e) {
|
|
36
|
-
expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
|
|
40
|
-
// @ts-expect-error
|
|
41
|
-
fps: undefined, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
test('No durationInFrames should give errors', () => {
|
|
48
|
-
try {
|
|
49
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30,
|
|
50
|
-
// @ts-expect-error
|
|
51
|
-
durationInFrames: undefined, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
expect(e.message).toMatch(/durationInFrames` must be a number, but is undefined/);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
test('Invalid playbackRate should give error', () => {
|
|
58
|
-
try {
|
|
59
|
-
(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 }));
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
expect(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
test('playbackRate of 0 should not be possible', () => {
|
|
66
|
-
try {
|
|
67
|
-
(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 }));
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
expect(e.message).toMatch(/A playback rate of 0 is not supported./);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
test('playbackRate of wrong type should not be possible', () => {
|
|
74
|
-
try {
|
|
75
|
-
(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,
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
playbackRate: 'hi' }));
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
expect(e.message).toMatch(/A playback rate of 0 is not supported./);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
test('playbackRate of undefined should be okay', () => {
|
|
84
|
-
(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 }));
|
|
85
|
-
expect(true).toBe(true);
|
|
86
|
-
});
|
|
87
|
-
test('passing in <Composition /> instance should not be possible', () => {
|
|
88
|
-
expect(() => {
|
|
89
|
-
(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: {
|
|
90
|
-
id: 'HelloWorld',
|
|
91
|
-
width: 500,
|
|
92
|
-
height: 400,
|
|
93
|
-
fps: 30,
|
|
94
|
-
durationInFrames: 500,
|
|
95
|
-
component: test_utils_1.HelloWorld,
|
|
96
|
-
} }));
|
|
97
|
-
}).toThrow(/'component' must not be the 'Composition' component\. Pass your own React/);
|
|
98
|
-
});
|
|
99
|
-
test('passing in <Composition /> instance should not be possible', () => {
|
|
100
|
-
expect(() => {
|
|
101
|
-
(0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500,
|
|
102
|
-
// @ts-expect-error
|
|
103
|
-
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: {
|
|
104
|
-
id: 'HelloWorld',
|
|
105
|
-
width: 500,
|
|
106
|
-
height: 400,
|
|
107
|
-
fps: 30,
|
|
108
|
-
durationInFrames: 500,
|
|
109
|
-
component: test_utils_1.HelloWorld,
|
|
110
|
-
} }));
|
|
111
|
-
}).toThrow(/'component' should not be an instance of <Composition\/>\. Pass the React component dir/);
|
|
112
|
-
});
|
|
113
|
-
test.each([
|
|
114
|
-
['controls'],
|
|
115
|
-
['loop'],
|
|
116
|
-
['autoPlay'],
|
|
117
|
-
['showVolumeControls'],
|
|
118
|
-
['allowFullscreen'],
|
|
119
|
-
['clickToPlay'],
|
|
120
|
-
['doubleClickToFullscreen'],
|
|
121
|
-
])('No durationInFrames should give errors %s', (a) => {
|
|
122
|
-
const props = {};
|
|
123
|
-
props[a] = 'hey';
|
|
124
|
-
try {
|
|
125
|
-
(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 }));
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
expect(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
|
|
129
|
-
}
|
|
130
|
-
});
|