@remotion/player 4.0.0-alpha.4 → 4.0.0-alpha4

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.
Files changed (208) hide show
  1. package/LICENSE.md +8 -8
  2. package/README.md +1 -1
  3. package/dist/cjs/MediaVolumeSlider.d.ts +5 -0
  4. package/dist/cjs/MediaVolumeSlider.js +143 -0
  5. package/dist/{Player.d.ts → cjs/Player.d.ts} +21 -13
  6. package/dist/{Player.js → cjs/Player.js} +42 -78
  7. package/dist/{PlayerControls.d.ts → cjs/PlayerControls.d.ts} +17 -2
  8. package/dist/cjs/PlayerControls.js +153 -0
  9. package/dist/{PlayerSeekBar.d.ts → cjs/PlayerSeekBar.d.ts} +4 -0
  10. package/dist/{PlayerSeekBar.js → cjs/PlayerSeekBar.js} +41 -17
  11. package/dist/cjs/PlayerUI.d.ts +39 -0
  12. package/dist/{PlayerUI.js → cjs/PlayerUI.js} +105 -87
  13. package/dist/cjs/SharedPlayerContext.d.ts +15 -0
  14. package/dist/cjs/SharedPlayerContext.js +72 -0
  15. package/dist/cjs/Thumbnail.d.ts +24 -0
  16. package/dist/cjs/Thumbnail.js +46 -0
  17. package/dist/cjs/ThumbnailUI.d.ts +11 -0
  18. package/dist/cjs/ThumbnailUI.js +107 -0
  19. package/dist/{calculate-next-frame.d.ts → cjs/calculate-next-frame.d.ts} +0 -0
  20. package/dist/{calculate-next-frame.js → cjs/calculate-next-frame.js} +0 -0
  21. package/dist/cjs/calculate-scale.d.ts +39 -0
  22. package/dist/cjs/calculate-scale.js +85 -0
  23. package/dist/cjs/emitter-context.d.ts +4 -0
  24. package/dist/{emitter-context.js → cjs/emitter-context.js} +2 -1
  25. package/dist/{error-boundary.d.ts → cjs/error-boundary.d.ts} +0 -0
  26. package/dist/{error-boundary.js → cjs/error-boundary.js} +0 -0
  27. package/dist/cjs/event-emitter.d.ts +76 -0
  28. package/dist/{event-emitter.js → cjs/event-emitter.js} +46 -2
  29. package/dist/{format-time.d.ts → cjs/format-time.d.ts} +0 -0
  30. package/dist/{format-time.js → cjs/format-time.js} +0 -0
  31. package/dist/{icons.d.ts → cjs/icons.d.ts} +2 -1
  32. package/dist/{icons.js → cjs/icons.js} +7 -7
  33. package/dist/{index.d.ts → cjs/index.d.ts} +22 -12
  34. package/dist/cjs/index.js +25 -0
  35. package/dist/cjs/is-backgrounded.d.ts +2 -0
  36. package/dist/cjs/is-backgrounded.js +24 -0
  37. package/dist/{player-css-classname.d.ts → cjs/player-css-classname.d.ts} +0 -1
  38. package/dist/cjs/player-css-classname.js +4 -0
  39. package/dist/{player-methods.d.ts → cjs/player-methods.d.ts} +8 -4
  40. package/dist/{player-methods.js → cjs/player-methods.js} +0 -0
  41. package/dist/{test → cjs/test}/index.test.d.ts +0 -0
  42. package/dist/cjs/test/index.test.js +9 -0
  43. package/dist/{test → cjs/test}/test-utils.d.ts +0 -0
  44. package/dist/{test → cjs/test}/test-utils.js +0 -0
  45. package/dist/{test/validate-prop.test.d.ts → cjs/test/validate-in-out-frames.test.d.ts} +0 -0
  46. package/dist/cjs/test/validate-in-out-frames.test.js +56 -0
  47. package/dist/cjs/test/validate-prop.test.d.ts +1 -0
  48. package/dist/cjs/test/validate-prop.test.js +131 -0
  49. package/dist/{use-hover-state.d.ts → cjs/use-hover-state.d.ts} +0 -0
  50. package/dist/{use-hover-state.js → cjs/use-hover-state.js} +0 -0
  51. package/dist/{use-playback.d.ts → cjs/use-playback.d.ts} +0 -0
  52. package/dist/{use-playback.js → cjs/use-playback.js} +49 -9
  53. package/dist/{use-player.d.ts → cjs/use-player.d.ts} +3 -1
  54. package/dist/{use-player.js → cjs/use-player.js} +15 -8
  55. package/dist/cjs/use-thumbnail.d.ts +6 -0
  56. package/dist/cjs/use-thumbnail.js +18 -0
  57. package/dist/cjs/use-video-controls-resize.d.ts +11 -0
  58. package/dist/cjs/use-video-controls-resize.js +39 -0
  59. package/dist/{utils → cjs/utils}/calculate-player-size.d.ts +1 -1
  60. package/dist/{utils → cjs/utils}/calculate-player-size.js +9 -10
  61. package/dist/{utils → cjs/utils}/cancellable-promise.d.ts +0 -0
  62. package/dist/{utils → cjs/utils}/cancellable-promise.js +0 -0
  63. package/dist/{utils → cjs/utils}/delay.d.ts +0 -0
  64. package/dist/{utils → cjs/utils}/delay.js +0 -0
  65. package/dist/{utils → cjs/utils}/is-node.d.ts +0 -0
  66. package/dist/{utils → cjs/utils}/is-node.js +0 -0
  67. package/dist/cjs/utils/preview-size.d.ts +8 -0
  68. package/dist/{utils → cjs/utils}/preview-size.js +0 -0
  69. package/dist/cjs/utils/props-if-has-props.d.ts +5 -0
  70. package/dist/cjs/utils/props-if-has-props.js +2 -0
  71. package/dist/{utils → cjs/utils}/use-cancellable-promises.d.ts +1 -1
  72. package/dist/{utils → cjs/utils}/use-cancellable-promises.js +0 -0
  73. package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.d.ts +0 -0
  74. package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.js +5 -5
  75. package/dist/{utils → cjs/utils}/use-element-size.d.ts +1 -0
  76. package/dist/{utils → cjs/utils}/use-element-size.js +24 -12
  77. package/dist/cjs/utils/validate-in-out-frame.d.ts +6 -0
  78. package/dist/cjs/utils/validate-in-out-frame.js +54 -0
  79. package/dist/cjs/utils/validate-initial-frame.d.ts +4 -0
  80. package/dist/cjs/utils/validate-initial-frame.js +27 -0
  81. package/dist/{utils → cjs/utils}/validate-playbackrate.d.ts +0 -0
  82. package/dist/{utils → cjs/utils}/validate-playbackrate.js +0 -0
  83. package/dist/{volume-persistance.d.ts → cjs/volume-persistance.d.ts} +0 -0
  84. package/dist/{volume-persistance.js → cjs/volume-persistance.js} +0 -0
  85. package/dist/esm/MediaVolumeSlider.d.ts +5 -0
  86. package/dist/esm/Player.d.ts +49 -0
  87. package/dist/esm/PlayerControls.d.ts +40 -0
  88. package/dist/esm/PlayerSeekBar.d.ts +8 -0
  89. package/dist/esm/PlayerUI.d.ts +39 -0
  90. package/dist/esm/SharedPlayerContext.d.ts +15 -0
  91. package/dist/esm/Thumbnail.d.ts +24 -0
  92. package/dist/esm/ThumbnailUI.d.ts +11 -0
  93. package/dist/esm/calculate-next-frame.d.ts +14 -0
  94. package/dist/esm/calculate-scale.d.ts +39 -0
  95. package/dist/esm/emitter-context.d.ts +4 -0
  96. package/dist/esm/error-boundary.d.ts +19 -0
  97. package/dist/esm/event-emitter.d.ts +76 -0
  98. package/dist/esm/format-time.d.ts +1 -0
  99. package/dist/esm/icons.d.ts +10 -0
  100. package/dist/esm/index.d.ts +61 -0
  101. package/dist/esm/index.mjs +1928 -0
  102. package/dist/esm/is-backgrounded.d.ts +2 -0
  103. package/dist/esm/player-css-classname.d.ts +1 -0
  104. package/dist/esm/player-methods.d.ts +24 -0
  105. package/dist/esm/test/index.test.d.ts +1 -0
  106. package/dist/esm/test/test-utils.d.ts +6 -0
  107. package/dist/esm/test/validate-in-out-frames.test.d.ts +1 -0
  108. package/dist/esm/test/validate-prop.test.d.ts +1 -0
  109. package/dist/esm/use-hover-state.d.ts +1 -0
  110. package/dist/esm/use-playback.d.ts +7 -0
  111. package/dist/esm/use-player.d.ts +19 -0
  112. package/dist/esm/use-thumbnail.d.ts +6 -0
  113. package/dist/esm/use-video-controls-resize.d.ts +11 -0
  114. package/dist/esm/utils/calculate-player-size.d.ts +9 -0
  115. package/dist/esm/utils/cancellable-promise.d.ts +5 -0
  116. package/dist/esm/utils/delay.d.ts +1 -0
  117. package/dist/esm/utils/is-node.d.ts +1 -0
  118. package/dist/esm/utils/preview-size.d.ts +8 -0
  119. package/dist/esm/utils/props-if-has-props.d.ts +5 -0
  120. package/dist/esm/utils/use-cancellable-promises.d.ts +7 -0
  121. package/dist/esm/utils/use-click-prevention-on-double-click.d.ts +3 -0
  122. package/dist/esm/utils/use-element-size.d.ts +16 -0
  123. package/dist/esm/utils/validate-in-out-frame.d.ts +6 -0
  124. package/dist/esm/utils/validate-initial-frame.d.ts +4 -0
  125. package/dist/esm/utils/validate-playbackrate.d.ts +1 -0
  126. package/dist/esm/volume-persistance.d.ts +2 -0
  127. package/dist/tsconfig-esm.tsbuildinfo +1 -0
  128. package/dist/tsconfig.tsbuildinfo +1 -0
  129. package/package.json +77 -66
  130. package/dist/MediaVolumeSlider.d.ts +0 -2
  131. package/dist/MediaVolumeSlider.d.ts.map +0 -1
  132. package/dist/MediaVolumeSlider.js +0 -93
  133. package/dist/MediaVolumeSlider.js.map +0 -1
  134. package/dist/Player.d.ts.map +0 -1
  135. package/dist/Player.js.map +0 -1
  136. package/dist/PlayerControls.d.ts.map +0 -1
  137. package/dist/PlayerControls.js +0 -95
  138. package/dist/PlayerControls.js.map +0 -1
  139. package/dist/PlayerSeekBar.d.ts.map +0 -1
  140. package/dist/PlayerSeekBar.js.map +0 -1
  141. package/dist/PlayerUI.d.ts +0 -31
  142. package/dist/PlayerUI.d.ts.map +0 -1
  143. package/dist/PlayerUI.js.map +0 -1
  144. package/dist/calculate-next-frame.d.ts.map +0 -1
  145. package/dist/calculate-next-frame.js.map +0 -1
  146. package/dist/calculate-scale.d.ts +0 -14
  147. package/dist/calculate-scale.d.ts.map +0 -1
  148. package/dist/calculate-scale.js +0 -24
  149. package/dist/calculate-scale.js.map +0 -1
  150. package/dist/emitter-context.d.ts +0 -3
  151. package/dist/emitter-context.d.ts.map +0 -1
  152. package/dist/emitter-context.js.map +0 -1
  153. package/dist/error-boundary.d.ts.map +0 -1
  154. package/dist/error-boundary.js.map +0 -1
  155. package/dist/event-emitter.d.ts +0 -42
  156. package/dist/event-emitter.d.ts.map +0 -1
  157. package/dist/event-emitter.js.map +0 -1
  158. package/dist/format-time.d.ts.map +0 -1
  159. package/dist/format-time.js.map +0 -1
  160. package/dist/icons.d.ts.map +0 -1
  161. package/dist/icons.js.map +0 -1
  162. package/dist/index.d.ts.map +0 -1
  163. package/dist/index.js +0 -22
  164. package/dist/index.js.map +0 -1
  165. package/dist/player-css-classname.d.ts.map +0 -1
  166. package/dist/player-css-classname.js +0 -5
  167. package/dist/player-css-classname.js.map +0 -1
  168. package/dist/player-methods.d.ts.map +0 -1
  169. package/dist/player-methods.js.map +0 -1
  170. package/dist/test/index.test.d.ts.map +0 -1
  171. package/dist/test/index.test.js +0 -8
  172. package/dist/test/index.test.js.map +0 -1
  173. package/dist/test/test-utils.d.ts.map +0 -1
  174. package/dist/test/test-utils.js.map +0 -1
  175. package/dist/test/validate-prop.test.d.ts.map +0 -1
  176. package/dist/test/validate-prop.test.js +0 -130
  177. package/dist/test/validate-prop.test.js.map +0 -1
  178. package/dist/use-hover-state.d.ts.map +0 -1
  179. package/dist/use-hover-state.js.map +0 -1
  180. package/dist/use-playback.d.ts.map +0 -1
  181. package/dist/use-playback.js.map +0 -1
  182. package/dist/use-player.d.ts.map +0 -1
  183. package/dist/use-player.js.map +0 -1
  184. package/dist/utils/browser-supports-fullscreen.d.ts +0 -12
  185. package/dist/utils/browser-supports-fullscreen.d.ts.map +0 -1
  186. package/dist/utils/browser-supports-fullscreen.js +0 -6
  187. package/dist/utils/browser-supports-fullscreen.js.map +0 -1
  188. package/dist/utils/calculate-player-size.d.ts.map +0 -1
  189. package/dist/utils/calculate-player-size.js.map +0 -1
  190. package/dist/utils/cancellable-promise.d.ts.map +0 -1
  191. package/dist/utils/cancellable-promise.js.map +0 -1
  192. package/dist/utils/delay.d.ts.map +0 -1
  193. package/dist/utils/delay.js.map +0 -1
  194. package/dist/utils/is-node.d.ts.map +0 -1
  195. package/dist/utils/is-node.js.map +0 -1
  196. package/dist/utils/preview-size.d.ts +0 -1
  197. package/dist/utils/preview-size.d.ts.map +0 -1
  198. package/dist/utils/preview-size.js.map +0 -1
  199. package/dist/utils/use-cancellable-promises.d.ts.map +0 -1
  200. package/dist/utils/use-cancellable-promises.js.map +0 -1
  201. package/dist/utils/use-click-prevention-on-double-click.d.ts.map +0 -1
  202. package/dist/utils/use-click-prevention-on-double-click.js.map +0 -1
  203. package/dist/utils/use-element-size.d.ts.map +0 -1
  204. package/dist/utils/use-element-size.js.map +0 -1
  205. package/dist/utils/validate-playbackrate.d.ts.map +0 -1
  206. package/dist/utils/validate-playbackrate.js.map +0 -1
  207. package/dist/volume-persistance.d.ts.map +0 -1
  208. package/dist/volume-persistance.js.map +0 -1
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 organisations 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.
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 [Jonny Burger](https://jonny.io)
10
+ Copyright © 2023 [Remotion](https://www.remotion.dev/)
11
11
 
12
12
  ### Eligibility
13
13
 
14
14
  You are eligible to use Remotion for free if you are:
15
15
 
16
16
  - an individual
17
- - a for-profit organisation with up to 3 employees
18
- - a non-profit or not-for-profit organisation
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 and 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.
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 noninfringement. 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.
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/api).
86
+ For a complete reference of the available props, refer to [@remotion/player API](https://www.remotion.dev/docs/player/player).
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const VOLUME_SLIDER_WIDTH = 100;
3
+ export declare const MediaVolumeSlider: React.FC<{
4
+ displayVerticalVolumeSlider: Boolean;
5
+ }>;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.MediaVolumeSlider = exports.VOLUME_SLIDER_WIDTH = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ const remotion_1 = require("remotion");
30
+ const icons_js_1 = require("./icons.js");
31
+ const use_hover_state_js_1 = require("./use-hover-state.js");
32
+ const BAR_HEIGHT = 5;
33
+ const KNOB_SIZE = 12;
34
+ exports.VOLUME_SLIDER_WIDTH = 100;
35
+ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
36
+ const [mediaMuted, setMediaMuted] = remotion_1.Internals.useMediaMutedState();
37
+ const [mediaVolume, setMediaVolume] = remotion_1.Internals.useMediaVolumeState();
38
+ const [focused, setFocused] = (0, react_1.useState)(false);
39
+ const parentDivRef = (0, react_1.useRef)(null);
40
+ const inputRef = (0, react_1.useRef)(null);
41
+ const hover = (0, use_hover_state_js_1.useHoverState)(parentDivRef);
42
+ // Need to import it from React to fix React 17 ESM support.
43
+ const randomId =
44
+ // eslint-disable-next-line react-hooks/rules-of-hooks
45
+ typeof react_1.default.useId === 'undefined' ? 'volume-slider' : react_1.default.useId();
46
+ const [randomClass] = (0, react_1.useState)(() => `__remotion-volume-slider-${(0, remotion_1.random)(randomId)}`.replace('.', ''));
47
+ const isMutedOrZero = mediaMuted || mediaVolume === 0;
48
+ const onVolumeChange = (e) => {
49
+ setMediaVolume(parseFloat(e.target.value));
50
+ };
51
+ const onBlur = () => {
52
+ setTimeout(() => {
53
+ // We need a small delay to check which element was focused next,
54
+ // and if it wasn't the volume slider, we hide it
55
+ if (document.activeElement !== inputRef.current) {
56
+ setFocused(false);
57
+ }
58
+ }, 10);
59
+ };
60
+ const onClick = (0, react_1.useCallback)(() => {
61
+ if (mediaVolume === 0) {
62
+ setMediaVolume(1);
63
+ setMediaMuted(false);
64
+ return;
65
+ }
66
+ setMediaMuted((mute) => !mute);
67
+ }, [mediaVolume, setMediaMuted, setMediaVolume]);
68
+ const parentDivStyle = (0, react_1.useMemo)(() => {
69
+ return {
70
+ display: 'inline-flex',
71
+ background: 'none',
72
+ border: 'none',
73
+ padding: 6,
74
+ justifyContent: 'center',
75
+ alignItems: 'center',
76
+ touchAction: 'none',
77
+ ...(displayVerticalVolumeSlider && { position: 'relative' }),
78
+ };
79
+ }, [displayVerticalVolumeSlider]);
80
+ const volumeContainer = (0, react_1.useMemo)(() => {
81
+ return {
82
+ display: 'inline',
83
+ width: icons_js_1.ICON_SIZE,
84
+ height: icons_js_1.ICON_SIZE,
85
+ cursor: 'pointer',
86
+ appearance: 'none',
87
+ background: 'none',
88
+ border: 'none',
89
+ padding: 0,
90
+ };
91
+ }, []);
92
+ const inputStyle = (0, react_1.useMemo)(() => {
93
+ const commonStyle = {
94
+ WebkitAppearance: 'none',
95
+ backgroundColor: 'rgba(255, 255, 255, 0.5)',
96
+ borderRadius: BAR_HEIGHT / 2,
97
+ cursor: 'pointer',
98
+ height: BAR_HEIGHT,
99
+ width: exports.VOLUME_SLIDER_WIDTH,
100
+ backgroundImage: `linear-gradient(
101
+ to right,
102
+ white ${mediaVolume * 100}%, rgba(255, 255, 255, 0) ${mediaVolume * 100}%
103
+ )`,
104
+ };
105
+ if (displayVerticalVolumeSlider) {
106
+ return {
107
+ ...commonStyle,
108
+ transform: `rotate(-90deg)`,
109
+ position: 'absolute',
110
+ bottom: icons_js_1.ICON_SIZE + exports.VOLUME_SLIDER_WIDTH / 2 + 5,
111
+ };
112
+ }
113
+ return {
114
+ ...commonStyle,
115
+ marginLeft: 5,
116
+ };
117
+ }, [displayVerticalVolumeSlider, mediaVolume]);
118
+ const sliderStyle = `
119
+ .${randomClass}::-webkit-slider-thumb {
120
+ -webkit-appearance: none;
121
+ background-color: white;
122
+ border-radius: ${KNOB_SIZE / 2}px;
123
+ box-shadow: 0 0 2px black;
124
+ height: ${KNOB_SIZE}px;
125
+ width: ${KNOB_SIZE}px;
126
+ }
127
+
128
+ .${randomClass}::-moz-range-thumb {
129
+ -webkit-appearance: none;
130
+ background-color: white;
131
+ border-radius: ${KNOB_SIZE / 2}px;
132
+ box-shadow: 0 0 2px black;
133
+ height: ${KNOB_SIZE}px;
134
+ width: ${KNOB_SIZE}px;
135
+ }
136
+ `;
137
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: parentDivRef, style: parentDivStyle, children: [(0, jsx_runtime_1.jsx)("style", {
138
+ // eslint-disable-next-line react/no-danger
139
+ dangerouslySetInnerHTML: {
140
+ __html: sliderStyle,
141
+ } }), (0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(icons_js_1.VolumeOffIcon, {}) : (0, jsx_runtime_1.jsx)(icons_js_1.VolumeOnIcon, {}) }), (focused || hover) && !mediaMuted ? ((0, jsx_runtime_1.jsx)("input", { ref: inputRef, "aria-label": "Change volume", className: randomClass, max: 1, min: 0, onBlur: () => setFocused(false), onChange: onVolumeChange, step: 0.01, type: "range", value: mediaVolume, style: inputStyle })) : null] }));
142
+ };
143
+ exports.MediaVolumeSlider = MediaVolumeSlider;
@@ -1,13 +1,10 @@
1
- import type { ComponentType, MutableRefObject } from 'react';
1
+ import type { ComponentType } from 'react';
2
2
  import React from 'react';
3
3
  import type { CompProps } from 'remotion';
4
- import type { PlayerRef } from './player-methods';
5
- import type { RenderLoading } from './PlayerUI';
6
- declare type PropsIfHasProps<Props> = {} extends Props ? {
7
- inputProps?: Props;
8
- } : {
9
- inputProps: Props;
10
- };
4
+ import type { PlayerRef } from './player-methods.js';
5
+ import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls.js';
6
+ import type { RenderLoading, RenderPoster } from './PlayerUI.js';
7
+ import type { PropsIfHasProps } from './utils/props-if-has-props.js';
11
8
  export declare type ErrorFallback = (info: {
12
9
  error: Error;
13
10
  }) => React.ReactNode;
@@ -31,11 +28,22 @@ export declare type PlayerProps<T> = {
31
28
  renderLoading?: RenderLoading;
32
29
  moveToBeginningWhenEnded?: boolean;
33
30
  className?: string;
31
+ initialFrame?: number;
32
+ renderPoster?: RenderPoster;
33
+ showPosterWhenPaused?: boolean;
34
+ showPosterWhenEnded?: boolean;
35
+ showPosterWhenUnplayed?: boolean;
36
+ inFrame?: number | null;
37
+ outFrame?: number | null;
38
+ initiallyShowControls?: number | boolean;
39
+ renderPlayPauseButton?: RenderPlayPauseButton;
40
+ renderFullscreenButton?: RenderFullscreenButton;
41
+ alwaysShowControls?: boolean;
42
+ initiallyMuted?: boolean;
34
43
  } & PropsIfHasProps<T> & CompProps<T>;
35
44
  export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
36
- 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, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
37
- declare module 'react' {
38
- function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
39
- }
45
+ /**
46
+ * @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
47
+ * @see [Documentation](https://www.remotion.dev/docs/player/player)
48
+ */
40
49
  export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
41
- export {};
@@ -3,17 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Player = exports.PlayerFn = exports.componentOrNullIfLazy = void 0;
6
+ exports.Player = exports.componentOrNullIfLazy = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = require("react");
9
9
  const remotion_1 = require("remotion");
10
- const emitter_context_1 = require("./emitter-context");
11
- const event_emitter_1 = require("./event-emitter");
12
- const player_css_classname_1 = require("./player-css-classname");
13
- const PlayerUI_1 = __importDefault(require("./PlayerUI"));
14
- const validate_playbackrate_1 = require("./utils/validate-playbackrate");
15
- const volume_persistance_1 = require("./volume-persistance");
16
- remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
10
+ const emitter_context_js_1 = require("./emitter-context.js");
11
+ const event_emitter_js_1 = require("./event-emitter.js");
12
+ const player_css_classname_js_1 = require("./player-css-classname.js");
13
+ const PlayerUI_js_1 = __importDefault(require("./PlayerUI.js"));
14
+ const SharedPlayerContext_js_1 = require("./SharedPlayerContext.js");
15
+ const validate_in_out_frame_js_1 = require("./utils/validate-in-out-frame.js");
16
+ const validate_initial_frame_js_1 = require("./utils/validate-initial-frame.js");
17
+ const validate_playbackrate_js_1 = require("./utils/validate-playbackrate.js");
17
18
  const componentOrNullIfLazy = (props) => {
18
19
  if ('component' in props) {
19
20
  return props.component;
@@ -21,7 +22,7 @@ const componentOrNullIfLazy = (props) => {
21
22
  return null;
22
23
  };
23
24
  exports.componentOrNullIfLazy = componentOrNullIfLazy;
24
- 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, ...componentProps }, ref) => {
25
+ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, alwaysShowControls = false, initiallyMuted = false, ...componentProps }, ref) => {
25
26
  if (typeof window !== 'undefined') {
26
27
  // eslint-disable-next-line react-hooks/rules-of-hooks
27
28
  (0, react_1.useLayoutEffect)(() => {
@@ -41,13 +42,12 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
41
42
  throw new TypeError(`'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
42
43
  }
43
44
  const component = remotion_1.Internals.useLazyComponent(componentProps);
44
- const [frame, setFrame] = (0, react_1.useState)(0);
45
+ (0, validate_initial_frame_js_1.validateInitialFrame)({ initialFrame, durationInFrames });
46
+ const [frame, setFrame] = (0, react_1.useState)(() => initialFrame !== null && initialFrame !== void 0 ? initialFrame : 0);
45
47
  const [playing, setPlaying] = (0, react_1.useState)(false);
46
48
  const [rootId] = (0, react_1.useState)('player-comp');
47
- const [emitter] = (0, react_1.useState)(() => new event_emitter_1.PlayerEmitter());
49
+ const [emitter] = (0, react_1.useState)(() => new event_emitter_js_1.PlayerEmitter());
48
50
  const rootRef = (0, react_1.useRef)(null);
49
- const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
50
- const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_1.getPreferredVolume)());
51
51
  const audioAndVideoTags = (0, react_1.useRef)([]);
52
52
  const imperativePlaying = (0, react_1.useRef)(false);
53
53
  if (typeof compositionHeight !== 'number') {
@@ -58,8 +58,17 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
58
58
  }
59
59
  remotion_1.Internals.validateDimension(compositionHeight, 'compositionHeight', 'of the <Player /> component');
60
60
  remotion_1.Internals.validateDimension(compositionWidth, 'compositionWidth', 'of the <Player /> component');
61
- remotion_1.Internals.validateDurationInFrames(durationInFrames, 'of the <Player/> component');
61
+ remotion_1.Internals.validateDurationInFrames({
62
+ durationInFrames,
63
+ component: 'of the <Player/> component',
64
+ allowFloats: false,
65
+ });
62
66
  remotion_1.Internals.validateFps(fps, 'as a prop of the <Player/> component', false);
67
+ (0, validate_in_out_frame_js_1.validateInOutFrames)({
68
+ durationInFrames,
69
+ inFrame,
70
+ outFrame,
71
+ });
63
72
  if (typeof controls !== 'boolean' && typeof controls !== 'undefined') {
64
73
  throw new TypeError(`'controls' must be a boolean or undefined but got '${typeof controls}' instead`);
65
74
  }
@@ -95,15 +104,11 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
95
104
  numberOfSharedAudioTags < 0) {
96
105
  throw new TypeError(`'numberOfSharedAudioTags' must be an integer but got '${numberOfSharedAudioTags}' instead`);
97
106
  }
98
- (0, validate_playbackrate_1.validatePlaybackRate)(playbackRate);
107
+ (0, validate_playbackrate_js_1.validatePlaybackRate)(playbackRate);
99
108
  (0, react_1.useEffect)(() => {
100
- emitter.dispatchRatechange(playbackRate);
109
+ emitter.dispatchRateChange(playbackRate);
101
110
  }, [emitter, playbackRate]);
102
- const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
103
- setMediaVolume(vol);
104
- (0, volume_persistance_1.persistVolume)(vol);
105
- }, []);
106
- (0, react_1.useImperativeHandle)(ref, () => rootRef.current);
111
+ (0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
107
112
  const timelineContextValue = (0, react_1.useMemo)(() => {
108
113
  return {
109
114
  frame,
@@ -124,64 +129,23 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
124
129
  setPlaying,
125
130
  };
126
131
  }, [setFrame]);
127
- const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
128
- return {
129
- mediaMuted,
130
- mediaVolume,
131
- };
132
- }, [mediaMuted, mediaVolume]);
133
- const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
134
- return {
135
- setMediaMuted,
136
- setMediaVolume: setMediaVolumeAndPersist,
137
- };
138
- }, [setMediaVolumeAndPersist]);
139
- const compositionManagerContext = (0, react_1.useMemo)(() => {
140
- return {
141
- compositions: [
142
- {
143
- component: component,
144
- durationInFrames,
145
- height: compositionHeight,
146
- width: compositionWidth,
147
- fps,
148
- id: 'player-comp',
149
- props: inputProps,
150
- nonce: 777,
151
- scale: 1,
152
- folderName: null,
153
- defaultProps: undefined,
154
- parentFolderName: null,
155
- },
156
- ],
157
- folders: [],
158
- registerFolder: () => undefined,
159
- unregisterFolder: () => undefined,
160
- currentComposition: 'player-comp',
161
- registerComposition: () => undefined,
162
- registerSequence: () => undefined,
163
- sequences: [],
164
- setCurrentComposition: () => undefined,
165
- unregisterComposition: () => undefined,
166
- unregisterSequence: () => undefined,
167
- registerAsset: () => undefined,
168
- unregisterAsset: () => undefined,
169
- assets: [],
170
- };
171
- }, [
172
- component,
173
- durationInFrames,
174
- compositionHeight,
175
- compositionWidth,
176
- fps,
177
- inputProps,
178
- ]);
179
132
  const passedInputProps = (0, react_1.useMemo)(() => {
180
133
  return inputProps !== null && inputProps !== void 0 ? inputProps : {};
181
134
  }, [inputProps]);
182
- return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SharedAudioContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, 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'
183
- ? clickToPlay
184
- : 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 }) }) }) }) }) }) }) }) }));
135
+ if (typeof window !== 'undefined') {
136
+ // eslint-disable-next-line react-hooks/rules-of-hooks
137
+ (0, react_1.useLayoutEffect)(() => {
138
+ // Inject CSS only on client, and also only after the Player has hydrated
139
+ remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_js_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
140
+ }, []);
141
+ }
142
+ return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(emitter_context_js_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_js_1.default, { ref: rootRef, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: passedInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
143
+ ? clickToPlay
144
+ : 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, alwaysShowControls: alwaysShowControls }) }) }) }) }));
185
145
  };
186
- exports.PlayerFn = PlayerFn;
187
- exports.Player = (0, react_1.forwardRef)(exports.PlayerFn);
146
+ const forward = react_1.forwardRef;
147
+ /**
148
+ * @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a Remotion video.
149
+ * @see [Documentation](https://www.remotion.dev/docs/player/player)
150
+ */
151
+ exports.Player = forward(PlayerFn);
@@ -1,6 +1,12 @@
1
- import type { MouseEventHandler } from 'react';
1
+ import type { MouseEventHandler, ReactNode } from 'react';
2
2
  import React from 'react';
3
- import type { usePlayer } from './use-player';
3
+ import type { usePlayer } from './use-player.js';
4
+ export declare type RenderPlayPauseButton = (props: {
5
+ playing: boolean;
6
+ }) => ReactNode;
7
+ export declare type RenderFullscreenButton = (props: {
8
+ isFullscreen: boolean;
9
+ }) => ReactNode;
4
10
  declare global {
5
11
  interface Document {
6
12
  webkitFullscreenEnabled?: boolean;
@@ -22,4 +28,13 @@ export declare const Controls: React.FC<{
22
28
  allowFullscreen: boolean;
23
29
  onExitFullscreenButtonClick: MouseEventHandler<HTMLButtonElement>;
24
30
  spaceKeyToPlayOrPause: boolean;
31
+ onSeekEnd: () => void;
32
+ onSeekStart: () => void;
33
+ inFrame: number | null;
34
+ outFrame: number | null;
35
+ initiallyShowControls: number | boolean;
36
+ playerWidth: number;
37
+ renderPlayPauseButton: RenderPlayPauseButton | null;
38
+ renderFullscreenButton: RenderFullscreenButton | null;
39
+ alwaysShowControls: boolean;
25
40
  }>;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Controls = 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_js_1 = require("./format-time.js");
8
+ const icons_js_1 = require("./icons.js");
9
+ const MediaVolumeSlider_js_1 = require("./MediaVolumeSlider.js");
10
+ const PlayerSeekBar_js_1 = require("./PlayerSeekBar.js");
11
+ const use_video_controls_resize_js_1 = require("./use-video-controls-resize.js");
12
+ const gradientSteps = [
13
+ 0, 0.013, 0.049, 0.104, 0.175, 0.259, 0.352, 0.45, 0.55, 0.648, 0.741, 0.825,
14
+ 0.896, 0.951, 0.987,
15
+ ];
16
+ const gradientOpacities = [
17
+ 0, 8.1, 15.5, 22.5, 29, 35.3, 41.2, 47.1, 52.9, 58.8, 64.7, 71, 77.5, 84.5,
18
+ 91.9,
19
+ ];
20
+ const globalGradientOpacity = 1 / 0.7;
21
+ const containerStyle = {
22
+ boxSizing: 'border-box',
23
+ position: 'absolute',
24
+ bottom: 0,
25
+ width: '100%',
26
+ paddingTop: 40,
27
+ paddingBottom: 10,
28
+ backgroundImage: `linear-gradient(to bottom,${gradientSteps
29
+ .map((g, i) => {
30
+ return `hsla(0, 0%, 0%, ${g}) ${gradientOpacities[i] * globalGradientOpacity}%`;
31
+ })
32
+ .join(', ')}, hsl(0, 0%, 0%) 100%)`,
33
+ backgroundSize: 'auto 145px',
34
+ display: 'flex',
35
+ paddingRight: use_video_controls_resize_js_1.X_PADDING,
36
+ paddingLeft: use_video_controls_resize_js_1.X_PADDING,
37
+ flexDirection: 'column',
38
+ transition: 'opacity 0.3s',
39
+ };
40
+ const buttonStyle = {
41
+ appearance: 'none',
42
+ backgroundColor: 'transparent',
43
+ border: 'none',
44
+ cursor: 'pointer',
45
+ paddingLeft: 0,
46
+ paddingRight: 0,
47
+ paddingTop: 6,
48
+ paddingBottom: 6,
49
+ height: 37,
50
+ display: 'inline',
51
+ marginBottom: 0,
52
+ marginTop: 0,
53
+ };
54
+ const controlsRow = {
55
+ display: 'flex',
56
+ flexDirection: 'row',
57
+ width: '100%',
58
+ alignItems: 'center',
59
+ justifyContent: 'center',
60
+ userSelect: 'none',
61
+ };
62
+ const leftPartStyle = {
63
+ display: 'flex',
64
+ flexDirection: 'row',
65
+ userSelect: 'none',
66
+ alignItems: 'center',
67
+ };
68
+ const xSpacer = {
69
+ width: 10,
70
+ };
71
+ const ySpacer = {
72
+ height: 8,
73
+ };
74
+ const flex1 = {
75
+ flex: 1,
76
+ };
77
+ const fullscreen = {};
78
+ const PlayPauseButton = ({ playing }) => playing ? (0, jsx_runtime_1.jsx)(icons_js_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_js_1.PlayIcon, {});
79
+ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, alwaysShowControls, }) => {
80
+ const playButtonRef = (0, react_1.useRef)(null);
81
+ const frame = remotion_1.Internals.Timeline.useTimelinePosition();
82
+ const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
83
+ const { maxTimeLabelWidth, displayVerticalVolumeSlider } = (0, use_video_controls_resize_js_1.useVideoControlsResize)({ allowFullscreen, playerWidth });
84
+ const [shouldShowInitially, setInitiallyShowControls] = (0, react_1.useState)(() => {
85
+ if (typeof initiallyShowControls === 'boolean') {
86
+ return initiallyShowControls;
87
+ }
88
+ if (typeof initiallyShowControls === 'number') {
89
+ if (initiallyShowControls % 1 !== 0) {
90
+ throw new Error('initiallyShowControls must be an integer or a boolean');
91
+ }
92
+ if (Number.isNaN(initiallyShowControls)) {
93
+ throw new Error('initiallyShowControls must not be NaN');
94
+ }
95
+ if (!Number.isFinite(initiallyShowControls)) {
96
+ throw new Error('initiallyShowControls must be finite');
97
+ }
98
+ if (initiallyShowControls <= 0) {
99
+ throw new Error('initiallyShowControls must be a positive integer');
100
+ }
101
+ return initiallyShowControls;
102
+ }
103
+ throw new TypeError('initiallyShowControls must be a number or a boolean');
104
+ });
105
+ const containerCss = (0, react_1.useMemo)(() => {
106
+ // Hide if playing and mouse outside
107
+ const shouldShow = hovered || !player.playing || shouldShowInitially || alwaysShowControls;
108
+ return {
109
+ ...containerStyle,
110
+ opacity: Number(shouldShow),
111
+ };
112
+ }, [hovered, shouldShowInitially, player.playing, alwaysShowControls]);
113
+ (0, react_1.useEffect)(() => {
114
+ if (playButtonRef.current && spaceKeyToPlayOrPause) {
115
+ // This switches focus to play button when player.playing flag changes
116
+ playButtonRef.current.focus({
117
+ preventScroll: true,
118
+ });
119
+ }
120
+ }, [player.playing, spaceKeyToPlayOrPause]);
121
+ (0, react_1.useEffect)(() => {
122
+ var _a;
123
+ // Must be handled client-side to avoid SSR hydration mismatch
124
+ setSupportsFullscreen((_a = (typeof document !== 'undefined' &&
125
+ (document.fullscreenEnabled || document.webkitFullscreenEnabled))) !== null && _a !== void 0 ? _a : false);
126
+ }, []);
127
+ (0, react_1.useEffect)(() => {
128
+ if (shouldShowInitially === false) {
129
+ return;
130
+ }
131
+ const time = shouldShowInitially === true ? 2000 : shouldShowInitially;
132
+ const timeout = setTimeout(() => {
133
+ setInitiallyShowControls(false);
134
+ }, time);
135
+ return () => {
136
+ clearInterval(timeout);
137
+ };
138
+ }, [shouldShowInitially]);
139
+ const timeLabel = (0, react_1.useMemo)(() => {
140
+ return {
141
+ color: 'white',
142
+ fontFamily: 'sans-serif',
143
+ fontSize: 14,
144
+ maxWidth: maxTimeLabelWidth === null ? undefined : maxTimeLabelWidth,
145
+ overflow: 'hidden',
146
+ textOverflow: 'ellipsis',
147
+ };
148
+ }, [maxTimeLabelWidth]);
149
+ 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_js_1.MediaVolumeSlider, { displayVerticalVolumeSlider: displayVerticalVolumeSlider })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_js_1.formatTime)(frame / fps), " / ", (0, format_time_js_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), (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
150
+ ? onExitFullscreenButtonClick
151
+ : onFullscreenButtonClick, children: renderFullscreenButton === null ? ((0, jsx_runtime_1.jsx)(icons_js_1.FullscreenIcon, { isFullscreen: isFullscreen })) : (renderFullscreenButton({ isFullscreen })) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_js_1.PlayerSeekBar, { onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, durationInFrames: durationInFrames, inFrame: inFrame, outFrame: outFrame })] }));
152
+ };
153
+ exports.Controls = Controls;
@@ -1,4 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  export declare const PlayerSeekBar: React.FC<{
3
3
  durationInFrames: number;
4
+ onSeekStart: () => void;
5
+ onSeekEnd: () => void;
6
+ inFrame: number | null;
7
+ outFrame: number | null;
4
8
  }>;