@remotion/player 4.0.0-bitrate.18 → 4.0.0-copy.4

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 (89) hide show
  1. package/LICENSE.md +8 -8
  2. package/README.md +1 -1
  3. package/dist/MediaVolumeSlider.d.ts +0 -0
  4. package/dist/MediaVolumeSlider.js +3 -1
  5. package/dist/Player.d.ts +6 -9
  6. package/dist/Player.js +5 -68
  7. package/dist/PlayerControls.d.ts +9 -1
  8. package/dist/PlayerControls.js +4 -3
  9. package/dist/PlayerSeekBar.d.ts +0 -0
  10. package/dist/PlayerSeekBar.js +0 -0
  11. package/dist/PlayerUI.d.ts +4 -5
  12. package/dist/PlayerUI.js +15 -51
  13. package/dist/SharedPlayerContext.d.ts +14 -0
  14. package/dist/SharedPlayerContext.js +71 -0
  15. package/dist/Thumbnail.d.ts +23 -0
  16. package/dist/Thumbnail.js +41 -0
  17. package/dist/ThumbnailUI.d.ts +11 -0
  18. package/dist/ThumbnailUI.js +107 -0
  19. package/dist/calc-style.d.ts +7 -0
  20. package/dist/calc-style.js +22 -0
  21. package/dist/calculate-next-frame.d.ts +0 -0
  22. package/dist/calculate-next-frame.js +0 -0
  23. package/dist/calculate-scale.d.ts +25 -6
  24. package/dist/calculate-scale.js +53 -1
  25. package/dist/calculate-style.d.ts +19 -0
  26. package/dist/calculate-style.js +55 -0
  27. package/dist/emitter-context.d.ts +2 -1
  28. package/dist/emitter-context.js +2 -1
  29. package/dist/error-boundary.d.ts +0 -0
  30. package/dist/error-boundary.js +0 -0
  31. package/dist/event-emitter.d.ts +23 -9
  32. package/dist/event-emitter.js +25 -1
  33. package/dist/format-time.d.ts +0 -0
  34. package/dist/format-time.js +0 -0
  35. package/dist/icons.d.ts +1 -1
  36. package/dist/icons.js +4 -4
  37. package/dist/index.d.ts +7 -5
  38. package/dist/index.js +3 -1
  39. package/dist/outer-style.d.ts +7 -0
  40. package/dist/outer-style.js +22 -0
  41. package/dist/player-css-classname.d.ts +0 -0
  42. package/dist/player-css-classname.js +0 -0
  43. package/dist/player-methods.d.ts +6 -3
  44. package/dist/player-methods.js +0 -0
  45. package/dist/test/index.test.d.ts +0 -0
  46. package/dist/test/index.test.js +3 -2
  47. package/dist/test/test-utils.d.ts +0 -0
  48. package/dist/test/test-utils.js +0 -0
  49. package/dist/test/validate-in-out-frames.test.d.ts +0 -0
  50. package/dist/test/validate-in-out-frames.test.js +12 -11
  51. package/dist/test/validate-prop.test.d.ts +0 -0
  52. package/dist/test/validate-prop.test.js +24 -23
  53. package/dist/use-hover-state.d.ts +0 -0
  54. package/dist/use-hover-state.js +0 -0
  55. package/dist/use-playback.d.ts +0 -0
  56. package/dist/use-playback.js +0 -0
  57. package/dist/use-player.d.ts +0 -0
  58. package/dist/use-player.js +0 -0
  59. package/dist/use-thumbnail.d.ts +6 -0
  60. package/dist/use-thumbnail.js +18 -0
  61. package/dist/use-video-controls-resize.d.ts +0 -0
  62. package/dist/use-video-controls-resize.js +0 -0
  63. package/dist/utils/calculate-player-size.d.ts +0 -0
  64. package/dist/utils/calculate-player-size.js +0 -0
  65. package/dist/utils/cancellable-promise.d.ts +0 -0
  66. package/dist/utils/cancellable-promise.js +0 -0
  67. package/dist/utils/delay.d.ts +0 -0
  68. package/dist/utils/delay.js +0 -0
  69. package/dist/utils/is-node.d.ts +0 -0
  70. package/dist/utils/is-node.js +0 -0
  71. package/dist/utils/preview-size.d.ts +0 -0
  72. package/dist/utils/preview-size.js +0 -0
  73. package/dist/utils/props-if-has-props.d.ts +5 -0
  74. package/dist/utils/props-if-has-props.js +2 -0
  75. package/dist/utils/use-cancellable-promises.d.ts +0 -0
  76. package/dist/utils/use-cancellable-promises.js +0 -0
  77. package/dist/utils/use-click-prevention-on-double-click.d.ts +0 -0
  78. package/dist/utils/use-click-prevention-on-double-click.js +0 -0
  79. package/dist/utils/use-element-size.d.ts +0 -0
  80. package/dist/utils/use-element-size.js +0 -0
  81. package/dist/utils/validate-in-out-frame.d.ts +0 -0
  82. package/dist/utils/validate-in-out-frame.js +0 -0
  83. package/dist/utils/validate-initial-frame.d.ts +0 -0
  84. package/dist/utils/validate-initial-frame.js +0 -0
  85. package/dist/utils/validate-playbackrate.d.ts +0 -0
  86. package/dist/utils/validate-playbackrate.js +0 -0
  87. package/dist/volume-persistance.d.ts +0 -0
  88. package/dist/volume-persistance.js +0 -0
  89. package/package.json +10 -11
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 © 2022 [Remotion](https://www.remotion.dev/)
11
11
 
12
12
  ### Eligibility
13
13
 
14
14
  You are eligible to use Remotion for free if you are:
15
15
 
16
16
  - an individual
17
- - a for-profit 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).
File without changes
@@ -16,7 +16,9 @@ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
16
16
  const parentDivRef = (0, react_1.useRef)(null);
17
17
  const inputRef = (0, react_1.useRef)(null);
18
18
  const hover = (0, use_hover_state_1.useHoverState)(parentDivRef);
19
- const [randomClass] = (0, react_1.useState)(() => `slider-${(0, remotion_1.random)(null)}`.replace('.', ''));
19
+ // eslint-disable-next-line react-hooks/rules-of-hooks
20
+ const randomId = typeof react_1.useId === 'undefined' ? 'volume-slider' : (0, react_1.useId)();
21
+ const [randomClass] = (0, react_1.useState)(() => `__remotion-volume-slider-${(0, remotion_1.random)(randomId)}`.replace('.', ''));
20
22
  const isMutedOrZero = mediaMuted || mediaVolume === 0;
21
23
  const onVolumeChange = (e) => {
22
24
  setMediaVolume(parseFloat(e.target.value));
package/dist/Player.d.ts CHANGED
@@ -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
4
  import type { PlayerRef } from './player-methods';
5
+ import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
5
6
  import type { RenderLoading, RenderPoster } from './PlayerUI';
6
- declare type PropsIfHasProps<Props> = {} extends Props ? {
7
- inputProps?: Props;
8
- } : {
9
- inputProps: Props;
10
- };
7
+ import type { PropsIfHasProps } from './utils/props-if-has-props';
11
8
  export declare type ErrorFallback = (info: {
12
9
  error: Error;
13
10
  }) => React.ReactNode;
@@ -39,11 +36,11 @@ export declare type PlayerProps<T> = {
39
36
  inFrame?: number | null;
40
37
  outFrame?: number | null;
41
38
  initiallyShowControls?: number | boolean;
39
+ renderPlayPauseButton?: RenderPlayPauseButton;
40
+ renderFullscreenButton?: RenderFullscreenButton;
42
41
  } & PropsIfHasProps<T> & CompProps<T>;
43
42
  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
43
  declare module 'react' {
46
44
  function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
47
45
  }
48
- export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement | null;
49
- export {};
46
+ export declare const Player: <T>(props: PlayerProps<T> & React.RefAttributes<PlayerRef>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
package/dist/Player.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Player = exports.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");
@@ -11,10 +11,10 @@ const emitter_context_1 = require("./emitter-context");
11
11
  const event_emitter_1 = require("./event-emitter");
12
12
  const player_css_classname_1 = require("./player-css-classname");
13
13
  const PlayerUI_1 = __importDefault(require("./PlayerUI"));
14
+ const SharedPlayerContext_1 = require("./SharedPlayerContext");
14
15
  const validate_in_out_frame_1 = require("./utils/validate-in-out-frame");
15
16
  const validate_initial_frame_1 = require("./utils/validate-initial-frame");
16
17
  const validate_playbackrate_1 = require("./utils/validate-playbackrate");
17
- const volume_persistance_1 = require("./volume-persistance");
18
18
  const componentOrNullIfLazy = (props) => {
19
19
  if ('component' in props) {
20
20
  return props.component;
@@ -22,7 +22,7 @@ const componentOrNullIfLazy = (props) => {
22
22
  return null;
23
23
  };
24
24
  exports.componentOrNullIfLazy = componentOrNullIfLazy;
25
- const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, ...componentProps }, ref) => {
25
+ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, ...componentProps }, ref) => {
26
26
  if (typeof window !== 'undefined') {
27
27
  // eslint-disable-next-line react-hooks/rules-of-hooks
28
28
  (0, react_1.useLayoutEffect)(() => {
@@ -48,8 +48,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
48
48
  const [rootId] = (0, react_1.useState)('player-comp');
49
49
  const [emitter] = (0, react_1.useState)(() => new event_emitter_1.PlayerEmitter());
50
50
  const rootRef = (0, react_1.useRef)(null);
51
- const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
52
- const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_1.getPreferredVolume)());
53
51
  const audioAndVideoTags = (0, react_1.useRef)([]);
54
52
  const imperativePlaying = (0, react_1.useRef)(false);
55
53
  if (typeof compositionHeight !== 'number') {
@@ -106,10 +104,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
106
104
  (0, react_1.useEffect)(() => {
107
105
  emitter.dispatchRatechange(playbackRate);
108
106
  }, [emitter, playbackRate]);
109
- const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
110
- setMediaVolume(vol);
111
- (0, volume_persistance_1.persistVolume)(vol);
112
- }, []);
113
107
  (0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
114
108
  const timelineContextValue = (0, react_1.useMemo)(() => {
115
109
  return {
@@ -131,60 +125,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
131
125
  setPlaying,
132
126
  };
133
127
  }, [setFrame]);
134
- const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
135
- return {
136
- mediaMuted,
137
- mediaVolume,
138
- };
139
- }, [mediaMuted, mediaVolume]);
140
- const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
141
- return {
142
- setMediaMuted,
143
- setMediaVolume: setMediaVolumeAndPersist,
144
- };
145
- }, [setMediaVolumeAndPersist]);
146
- const compositionManagerContext = (0, react_1.useMemo)(() => {
147
- return {
148
- compositions: [
149
- {
150
- component: component,
151
- durationInFrames,
152
- height: compositionHeight,
153
- width: compositionWidth,
154
- fps,
155
- id: 'player-comp',
156
- props: inputProps,
157
- nonce: 777,
158
- scale: 1,
159
- folderName: null,
160
- defaultProps: undefined,
161
- parentFolderName: null,
162
- },
163
- ],
164
- folders: [],
165
- registerFolder: () => undefined,
166
- unregisterFolder: () => undefined,
167
- currentComposition: 'player-comp',
168
- registerComposition: () => undefined,
169
- registerSequence: () => undefined,
170
- sequences: [],
171
- setCurrentComposition: () => undefined,
172
- unregisterComposition: () => undefined,
173
- unregisterSequence: () => undefined,
174
- registerAsset: () => undefined,
175
- unregisterAsset: () => undefined,
176
- currentCompositionMetadata: null,
177
- setCurrentCompositionMetadata: () => undefined,
178
- assets: [],
179
- };
180
- }, [
181
- component,
182
- durationInFrames,
183
- compositionHeight,
184
- compositionWidth,
185
- fps,
186
- inputProps,
187
- ]);
188
128
  const passedInputProps = (0, react_1.useMemo)(() => {
189
129
  return inputProps !== null && inputProps !== void 0 ? inputProps : {};
190
130
  }, [inputProps]);
@@ -195,9 +135,6 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
195
135
  remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
196
136
  }, []);
197
137
  }
198
- return ((0, jsx_runtime_1.jsx)(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)(remotion_1.Internals.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.DurationsContextProvider, { 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'
199
- ? clickToPlay
200
- : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), setMediaVolume: setMediaVolumeAndPersist, mediaVolume: mediaVolume, mediaMuted: mediaMuted, doubleClickToFullscreen: Boolean(doubleClickToFullscreen), setMediaMuted: setMediaMuted, spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true }) }) }) }) }) }) }) }) }) }) }));
138
+ return ((0, jsx_runtime_1.jsx)(SharedPlayerContext_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(emitter_context_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_1.default, { ref: rootRef, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: passedInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean' ? clickToPlay : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null }) }) }) }));
201
139
  };
202
- exports.PlayerFn = PlayerFn;
203
- exports.Player = (0, react_1.forwardRef)(exports.PlayerFn);
140
+ exports.Player = (0, react_1.forwardRef)(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
3
  import type { usePlayer } from './use-player';
4
+ export declare type RenderPlayPauseButton = (props: {
5
+ playing: boolean;
6
+ }) => ReactNode;
7
+ export declare type RenderFullscreenButton = (props: {
8
+ isFullscreen: boolean;
9
+ }) => ReactNode;
4
10
  export declare const X_SPACER = 10;
5
11
  export declare const X_PADDING = 12;
6
12
  declare global {
@@ -30,4 +36,6 @@ export declare const Controls: React.FC<{
30
36
  outFrame: number | null;
31
37
  initiallyShowControls: number | boolean;
32
38
  playerWidth: number;
39
+ renderPlayPauseButton: RenderPlayPauseButton | null;
40
+ renderFullscreenButton: RenderFullscreenButton | null;
33
41
  }>;
@@ -60,7 +60,8 @@ const flex1 = {
60
60
  flex: 1,
61
61
  };
62
62
  const fullscreen = {};
63
- const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, }) => {
63
+ const PlayPauseButton = ({ playing }) => playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {});
64
+ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, }) => {
64
65
  const playButtonRef = (0, react_1.useRef)(null);
65
66
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
66
67
  const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
@@ -130,8 +131,8 @@ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVo
130
131
  textOverflow: 'ellipsis',
131
132
  };
132
133
  }, [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
+ return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: buttonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: renderPlayPauseButton === null ? ((0, jsx_runtime_1.jsx)(PlayPauseButton, { playing: player.playing })) : (renderPlayPauseButton({ playing: player.playing })) }), showVolumeControls ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsx)(MediaVolumeSlider_1.MediaVolumeSlider, { displayVerticalVolumeSlider: displayVerticalVolumeSlider })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_1.formatTime)(frame / fps), " / ", (0, format_time_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), (0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: buttonStyle, onClick: isFullscreen
134
135
  ? 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
+ : onFullscreenButtonClick, children: renderFullscreenButton === null ? ((0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { isFullscreen: isFullscreen })) : (renderFullscreenButton({ isFullscreen })) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_1.PlayerSeekBar, { onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, durationInFrames: durationInFrames, inFrame: inFrame, outFrame: outFrame })] }));
136
137
  };
137
138
  exports.Controls = Controls;
File without changes
File without changes
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import type { PlayerRef } from './player-methods';
3
+ import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
3
4
  export declare type ErrorFallback = (info: {
4
5
  error: Error;
5
6
  }) => React.ReactNode;
6
7
  export declare type RenderLoading = (canvas: {
7
8
  height: number;
8
9
  width: number;
9
- }) => React.ReactChild;
10
+ }) => React.ReactNode;
10
11
  export declare type RenderPoster = RenderLoading;
11
12
  declare const _default: (props: {
12
13
  controls: boolean;
@@ -15,14 +16,10 @@ declare const _default: (props: {
15
16
  allowFullscreen: boolean;
16
17
  inputProps: unknown;
17
18
  showVolumeControls: boolean;
18
- mediaMuted: boolean;
19
19
  style?: React.CSSProperties | undefined;
20
20
  clickToPlay: boolean;
21
21
  doubleClickToFullscreen: boolean;
22
22
  spaceKeyToPlayOrPause: boolean;
23
- setMediaVolume: (v: number) => void;
24
- setMediaMuted: (v: boolean) => void;
25
- mediaVolume: number;
26
23
  errorFallback: ErrorFallback;
27
24
  playbackRate: number;
28
25
  renderLoading: RenderLoading | undefined;
@@ -35,5 +32,7 @@ declare const _default: (props: {
35
32
  inFrame: number | null;
36
33
  outFrame: number | null;
37
34
  initiallyShowControls: number | boolean;
35
+ renderPlayPauseButton: RenderPlayPauseButton | null;
36
+ renderFullscreen: RenderFullscreenButton | null;
38
37
  } & React.RefAttributes<PlayerRef | null>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
39
38
  export default _default;
package/dist/PlayerUI.js CHANGED
@@ -33,7 +33,6 @@ const PlayerControls_1 = require("./PlayerControls");
33
33
  const use_hover_state_1 = require("./use-hover-state");
34
34
  const use_playback_1 = require("./use-playback");
35
35
  const use_player_1 = require("./use-player");
36
- const calculate_player_size_1 = require("./utils/calculate-player-size");
37
36
  const is_node_1 = require("./utils/is-node");
38
37
  const use_click_prevention_on_double_click_1 = require("./utils/use-click-prevention-on-double-click");
39
38
  const use_element_size_1 = require("./utils/use-element-size");
@@ -42,7 +41,7 @@ if (reactVersion === '0') {
42
41
  throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
43
42
  }
44
43
  const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
45
- const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, mediaVolume, mediaMuted, doubleClickToFullscreen, setMediaMuted, setMediaVolume, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, inFrame, outFrame, initiallyShowControls, }, ref) => {
44
+ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, doubleClickToFullscreen, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, inFrame, outFrame, initiallyShowControls, renderFullscreen: renderFullscreenButton, renderPlayPauseButton, }, ref) => {
46
45
  var _a, _b, _c, _d, _e;
47
46
  const config = remotion_1.Internals.useUnsafeVideoConfig();
48
47
  const video = remotion_1.Internals.useVideo();
@@ -159,6 +158,8 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
159
158
  });
160
159
  }, [canvasSize, config]);
161
160
  const scale = (_b = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _b !== void 0 ? _b : 1;
161
+ const { setMediaVolume, setMediaMuted } = (0, react_1.useContext)(remotion_1.Internals.SetMediaVolumeContext);
162
+ const { mediaMuted, mediaVolume } = (0, react_1.useContext)(remotion_1.Internals.MediaVolumeContext);
162
163
  (0, react_1.useImperativeHandle)(ref, () => {
163
164
  const methods = {
164
165
  play: player.play,
@@ -227,52 +228,13 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
227
228
  ]);
228
229
  const VideoComponent = video ? video.component : null;
229
230
  const outerStyle = (0, react_1.useMemo)(() => {
230
- if (!config) {
231
- return {};
232
- }
233
- return {
234
- position: 'relative',
235
- overflow: 'hidden',
236
- ...(0, calculate_player_size_1.calculatePlayerSize)({
237
- compositionHeight: config.height,
238
- compositionWidth: config.width,
239
- currentSize: canvasSize,
240
- height: style === null || style === void 0 ? void 0 : style.height,
241
- width: style === null || style === void 0 ? void 0 : style.width,
242
- }),
243
- ...style,
244
- };
231
+ return (0, calculate_scale_1.calculateOuterStyle)({ canvasSize, config, style });
245
232
  }, [canvasSize, config, style]);
246
233
  const outer = (0, react_1.useMemo)(() => {
247
- if (!layout || !config) {
248
- return {};
249
- }
250
- const { centerX, centerY } = layout;
251
- return {
252
- width: config.width * scale,
253
- height: config.height * scale,
254
- display: 'flex',
255
- flexDirection: 'column',
256
- position: 'absolute',
257
- left: centerX,
258
- top: centerY,
259
- overflow: 'hidden',
260
- };
234
+ return (0, calculate_scale_1.calculateOuter)({ config, layout, scale });
261
235
  }, [config, layout, scale]);
262
236
  const containerStyle = (0, react_1.useMemo)(() => {
263
- if (!config || !canvasSize || !layout) {
264
- return {};
265
- }
266
- return {
267
- position: 'absolute',
268
- width: config.width,
269
- height: config.height,
270
- display: 'flex',
271
- transform: `scale(${scale})`,
272
- marginLeft: layout.xCorrection,
273
- marginTop: layout.yCorrection,
274
- overflow: 'hidden',
275
- };
237
+ return (0, calculate_scale_1.calculateContainerStyle)({ canvasSize, config, layout, scale });
276
238
  }, [canvasSize, config, layout, scale]);
277
239
  const onError = (0, react_1.useCallback)((error) => {
278
240
  player.pause();
@@ -311,6 +273,14 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
311
273
  setShouldAutoPlay(false);
312
274
  }
313
275
  }, [shouldAutoplay, player]);
276
+ const loadingMarkup = (0, react_1.useMemo)(() => {
277
+ return renderLoading
278
+ ? renderLoading({
279
+ height: outerStyle.height,
280
+ width: outerStyle.width,
281
+ })
282
+ : null;
283
+ }, [outerStyle.height, outerStyle.width, renderLoading]);
314
284
  if (!config) {
315
285
  return null;
316
286
  }
@@ -329,16 +299,10 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
329
299
  showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
330
300
  showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
331
301
  ].some(Boolean);
332
- const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...((_d = inputProps) !== null && _d !== void 0 ? _d : {}) }) })) : null }) }), shouldShowPoster ? ((0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? ((0, jsx_runtime_1.jsx)(PlayerControls_1.Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, inFrame: inFrame, outFrame: outFrame, initiallyShowControls: initiallyShowControls, playerWidth: (_e = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _e !== void 0 ? _e : 0 })) : null] }));
302
+ const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...((_d = inputProps) !== null && _d !== void 0 ? _d : {}) }) })) : null }) }), shouldShowPoster ? ((0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? ((0, jsx_runtime_1.jsx)(PlayerControls_1.Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, inFrame: inFrame, outFrame: outFrame, initiallyShowControls: initiallyShowControls, playerWidth: (_e = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _e !== void 0 ? _e : 0, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton })) : null] }));
333
303
  if (is_node_1.IS_NODE && !doesReactVersionSupportSuspense) {
334
304
  return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
335
305
  }
336
- const loadingMarkup = renderLoading
337
- ? renderLoading({
338
- height: outerStyle.height,
339
- width: outerStyle.width,
340
- })
341
- : null;
342
306
  return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }) }));
343
307
  };
344
308
  exports.default = (0, react_1.forwardRef)(PlayerUI);
@@ -0,0 +1,14 @@
1
+ import type { ComponentType, LazyExoticComponent } from 'react';
2
+ import React from 'react';
3
+ import type { TimelineContextValue } from 'remotion';
4
+ export declare const SharedPlayerContexts: React.FC<{
5
+ children: React.ReactNode;
6
+ timelineContext: TimelineContextValue;
7
+ inputProps?: unknown;
8
+ fps: number;
9
+ compositionWidth: number;
10
+ compositionHeight: number;
11
+ durationInFrames: number;
12
+ component: LazyExoticComponent<ComponentType<unknown>>;
13
+ numberOfSharedAudioTags: number;
14
+ }>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SharedPlayerContexts = 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 volume_persistance_1 = require("./volume-persistance");
8
+ const SharedPlayerContexts = ({ children, timelineContext, inputProps, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, }) => {
9
+ const compositionManagerContext = (0, react_1.useMemo)(() => {
10
+ return {
11
+ compositions: [
12
+ {
13
+ component: component,
14
+ durationInFrames,
15
+ height: compositionHeight,
16
+ width: compositionWidth,
17
+ fps,
18
+ id: 'player-comp',
19
+ props: inputProps,
20
+ nonce: 777,
21
+ scale: 1,
22
+ folderName: null,
23
+ defaultProps: undefined,
24
+ parentFolderName: null,
25
+ },
26
+ ],
27
+ folders: [],
28
+ registerFolder: () => undefined,
29
+ unregisterFolder: () => undefined,
30
+ currentComposition: 'player-comp',
31
+ registerComposition: () => undefined,
32
+ registerSequence: () => undefined,
33
+ sequences: [],
34
+ setCurrentComposition: () => undefined,
35
+ unregisterComposition: () => undefined,
36
+ unregisterSequence: () => undefined,
37
+ registerAsset: () => undefined,
38
+ unregisterAsset: () => undefined,
39
+ currentCompositionMetadata: null,
40
+ setCurrentCompositionMetadata: () => undefined,
41
+ assets: [],
42
+ };
43
+ }, [
44
+ component,
45
+ durationInFrames,
46
+ compositionHeight,
47
+ compositionWidth,
48
+ fps,
49
+ inputProps,
50
+ ]);
51
+ const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
52
+ const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_1.getPreferredVolume)());
53
+ const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
54
+ return {
55
+ mediaMuted,
56
+ mediaVolume,
57
+ };
58
+ }, [mediaMuted, mediaVolume]);
59
+ const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
60
+ setMediaVolume(vol);
61
+ (0, volume_persistance_1.persistVolume)(vol);
62
+ }, []);
63
+ const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
64
+ return {
65
+ setMediaMuted,
66
+ setMediaVolume: setMediaVolumeAndPersist,
67
+ };
68
+ }, [setMediaVolumeAndPersist]);
69
+ return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: timelineContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.DurationsContextProvider, { 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: children }) }) }) }) }) }) }) }));
70
+ };
71
+ exports.SharedPlayerContexts = SharedPlayerContexts;
@@ -0,0 +1,23 @@
1
+ import type { CSSProperties, MutableRefObject } from 'react';
2
+ import type { CompProps } from 'remotion';
3
+ import type { ThumbnailMethods } from './player-methods';
4
+ import type { ErrorFallback, RenderLoading } from './PlayerUI';
5
+ import type { PropsIfHasProps } from './utils/props-if-has-props';
6
+ declare type ThumbnailProps<T> = PropsIfHasProps<T> & CompProps<T> & {
7
+ frameToDisplay: number;
8
+ style?: CSSProperties;
9
+ durationInFrames: number;
10
+ compositionWidth: number;
11
+ compositionHeight: number;
12
+ inputProps?: unknown;
13
+ fps: number;
14
+ errorFallback?: ErrorFallback;
15
+ renderLoading?: RenderLoading;
16
+ className?: string;
17
+ };
18
+ export declare const ThumbnailFn: <T>({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback, renderLoading, ...componentProps }: ThumbnailProps<T>, ref: MutableRefObject<ThumbnailMethods>) => JSX.Element;
19
+ declare module 'react' {
20
+ function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
21
+ }
22
+ export declare const Thumbnail: <T>(props: ThumbnailProps<T> & import("react").RefAttributes<ThumbnailMethods>) => React.ReactElement | null;
23
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Thumbnail = exports.ThumbnailFn = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
9
+ const remotion_1 = require("remotion");
10
+ const emitter_context_1 = require("./emitter-context");
11
+ const event_emitter_1 = require("./event-emitter");
12
+ const SharedPlayerContext_1 = require("./SharedPlayerContext");
13
+ const ThumbnailUI_1 = __importDefault(require("./ThumbnailUI"));
14
+ const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback = () => '⚠️', renderLoading, ...componentProps }, ref) => {
15
+ const [thumbnailId] = (0, react_1.useState)(() => String((0, remotion_1.random)(null)));
16
+ const rootRef = (0, react_1.useRef)(null);
17
+ const timelineState = (0, react_1.useMemo)(() => {
18
+ return {
19
+ playing: false,
20
+ frame: frameToDisplay,
21
+ rootId: thumbnailId,
22
+ imperativePlaying: {
23
+ current: false,
24
+ },
25
+ playbackRate: 1,
26
+ setPlaybackRate: () => {
27
+ throw new Error('thumbnail');
28
+ },
29
+ audioAndVideoTags: { current: [] },
30
+ };
31
+ }, [frameToDisplay, thumbnailId]);
32
+ (0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
33
+ const Component = remotion_1.Internals.useLazyComponent(componentProps);
34
+ const [emitter] = (0, react_1.useState)(() => new event_emitter_1.ThumbnailEmitter());
35
+ const passedInputProps = (0, react_1.useMemo)(() => {
36
+ return inputProps !== null && inputProps !== void 0 ? inputProps : {};
37
+ }, [inputProps]);
38
+ return ((0, jsx_runtime_1.jsx)(SharedPlayerContext_1.SharedPlayerContexts, { timelineContext: timelineState, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: 0, children: (0, jsx_runtime_1.jsx)(emitter_context_1.ThumbnailEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(ThumbnailUI_1.default, { className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style }) }) }));
39
+ };
40
+ exports.ThumbnailFn = ThumbnailFn;
41
+ exports.Thumbnail = (0, react_1.forwardRef)(exports.ThumbnailFn);
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { ThumbnailMethods } from './player-methods';
3
+ import type { ErrorFallback, RenderLoading } from './PlayerUI';
4
+ declare const _default: (props: {
5
+ inputProps: unknown;
6
+ style?: React.CSSProperties | undefined;
7
+ errorFallback: ErrorFallback;
8
+ renderLoading: RenderLoading | undefined;
9
+ className: string | undefined;
10
+ } & React.RefAttributes<ThumbnailMethods | null>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
11
+ export default _default;