@remotion/player 4.0.0-prefetch.10 → 4.0.0-prefetch.12

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 (72) hide show
  1. package/LICENSE.md +7 -7
  2. package/dist/MediaVolumeSlider.d.ts +4 -1
  3. package/dist/MediaVolumeSlider.js +82 -55
  4. package/dist/Player.d.ts +5 -1
  5. package/dist/Player.js +5 -5
  6. package/dist/PlayerControls.d.ts +13 -1
  7. package/dist/PlayerControls.js +56 -13
  8. package/dist/PlayerSeekBar.d.ts +0 -0
  9. package/dist/PlayerSeekBar.js +0 -0
  10. package/dist/PlayerUI.d.ts +4 -0
  11. package/dist/PlayerUI.js +23 -26
  12. package/dist/calculate-next-frame.d.ts +0 -0
  13. package/dist/calculate-next-frame.js +0 -0
  14. package/dist/calculate-scale.d.ts +0 -0
  15. package/dist/calculate-scale.js +0 -0
  16. package/dist/emitter-context.d.ts +0 -0
  17. package/dist/emitter-context.js +0 -0
  18. package/dist/error-boundary.d.ts +0 -0
  19. package/dist/error-boundary.js +0 -0
  20. package/dist/event-emitter.d.ts +5 -0
  21. package/dist/event-emitter.js +4 -0
  22. package/dist/format-time.d.ts +0 -0
  23. package/dist/format-time.js +0 -0
  24. package/dist/icons.d.ts +2 -1
  25. package/dist/icons.js +7 -7
  26. package/dist/index.d.ts +3 -2
  27. package/dist/index.js +0 -0
  28. package/dist/player-css-classname.d.ts +0 -1
  29. package/dist/player-css-classname.js +1 -2
  30. package/dist/player-methods.d.ts +1 -0
  31. package/dist/player-methods.js +0 -0
  32. package/dist/test/index.test.d.ts +0 -0
  33. package/dist/test/index.test.js +3 -2
  34. package/dist/test/test-utils.d.ts +0 -0
  35. package/dist/test/test-utils.js +0 -0
  36. package/dist/test/validate-in-out-frames.test.d.ts +0 -0
  37. package/dist/test/validate-in-out-frames.test.js +12 -11
  38. package/dist/test/validate-prop.test.d.ts +0 -0
  39. package/dist/test/validate-prop.test.js +24 -23
  40. package/dist/use-hover-state.d.ts +0 -0
  41. package/dist/use-hover-state.js +0 -0
  42. package/dist/use-playback.d.ts +0 -0
  43. package/dist/use-playback.js +3 -0
  44. package/dist/use-player.d.ts +0 -0
  45. package/dist/use-player.js +0 -0
  46. package/dist/use-video-controls-resize.d.ts +7 -0
  47. package/dist/use-video-controls-resize.js +36 -0
  48. package/dist/utils/calculate-player-size.d.ts +0 -0
  49. package/dist/utils/calculate-player-size.js +0 -0
  50. package/dist/utils/cancellable-promise.d.ts +0 -0
  51. package/dist/utils/cancellable-promise.js +0 -0
  52. package/dist/utils/delay.d.ts +0 -0
  53. package/dist/utils/delay.js +0 -0
  54. package/dist/utils/is-node.d.ts +0 -0
  55. package/dist/utils/is-node.js +0 -0
  56. package/dist/utils/preview-size.d.ts +0 -0
  57. package/dist/utils/preview-size.js +0 -0
  58. package/dist/utils/use-cancellable-promises.d.ts +0 -0
  59. package/dist/utils/use-cancellable-promises.js +0 -0
  60. package/dist/utils/use-click-prevention-on-double-click.d.ts +0 -0
  61. package/dist/utils/use-click-prevention-on-double-click.js +0 -0
  62. package/dist/utils/use-element-size.d.ts +0 -0
  63. package/dist/utils/use-element-size.js +0 -0
  64. package/dist/utils/validate-in-out-frame.d.ts +0 -0
  65. package/dist/utils/validate-in-out-frame.js +0 -0
  66. package/dist/utils/validate-initial-frame.d.ts +0 -0
  67. package/dist/utils/validate-initial-frame.js +0 -0
  68. package/dist/utils/validate-playbackrate.d.ts +0 -0
  69. package/dist/utils/validate-playbackrate.js +0 -0
  70. package/dist/volume-persistance.d.ts +0 -0
  71. package/dist/volume-persistance.js +0 -0
  72. package/package.json +9 -10
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
 
@@ -1,2 +1,5 @@
1
1
  import React from 'react';
2
- export declare const MediaVolumeSlider: React.FC;
2
+ export declare const VOLUME_SLIDER_WIDTH = 100;
3
+ export declare const MediaVolumeSlider: React.FC<{
4
+ displayVerticalVolumeSlider: Boolean;
5
+ }>;
@@ -1,72 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MediaVolumeSlider = void 0;
3
+ exports.MediaVolumeSlider = exports.VOLUME_SLIDER_WIDTH = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
7
  const icons_1 = require("./icons");
8
- const player_css_classname_1 = require("./player-css-classname");
9
8
  const use_hover_state_1 = require("./use-hover-state");
10
9
  const BAR_HEIGHT = 5;
11
10
  const KNOB_SIZE = 12;
12
- const VOLUME_SLIDER_WIDTH = 100;
13
- const scope = `.${player_css_classname_1.VOLUME_SLIDER_INPUT_CSS_CLASSNAME}`;
14
- const sliderStyle = `
15
- ${scope} {
16
- -webkit-appearance: none;
17
- background-color: rgba(255, 255, 255, 0.5);
18
- border-radius: ${BAR_HEIGHT / 2}px;
19
- cursor: pointer;
20
- height: ${BAR_HEIGHT}px;
21
- margin-left: 5px;
22
- width: ${VOLUME_SLIDER_WIDTH}px;
23
- }
24
-
25
- ${scope}::-webkit-slider-thumb {
26
- -webkit-appearance: none;
27
- background-color: white;
28
- border-radius: ${KNOB_SIZE / 2}px;
29
- box-shadow: 0 0 2px black;
30
- height: ${KNOB_SIZE}px;
31
- width: ${KNOB_SIZE}px;
32
- }
33
-
34
- ${scope}::-moz-range-thumb {
35
- -webkit-appearance: none;
36
- background-color: white;
37
- border-radius: ${KNOB_SIZE / 2}px;
38
- box-shadow: 0 0 2px black;
39
- height: ${KNOB_SIZE}px;
40
- width: ${KNOB_SIZE}px;
41
- }
42
- `;
43
- remotion_1.Internals.CSSUtils.injectCSS(sliderStyle);
44
- const parentDivStyle = {
45
- display: 'inline-flex',
46
- background: 'none',
47
- border: 'none',
48
- padding: '6px',
49
- justifyContent: 'center',
50
- alignItems: 'center',
51
- touchAction: 'none',
52
- };
53
- const volumeContainer = {
54
- display: 'inline',
55
- width: icons_1.ICON_SIZE,
56
- height: icons_1.ICON_SIZE,
57
- cursor: 'pointer',
58
- appearance: 'none',
59
- background: 'none',
60
- border: 'none',
61
- padding: 0,
62
- };
63
- const MediaVolumeSlider = () => {
11
+ exports.VOLUME_SLIDER_WIDTH = 100;
12
+ const MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
64
13
  const [mediaMuted, setMediaMuted] = remotion_1.Internals.useMediaMutedState();
65
14
  const [mediaVolume, setMediaVolume] = remotion_1.Internals.useMediaVolumeState();
66
15
  const [focused, setFocused] = (0, react_1.useState)(false);
67
16
  const parentDivRef = (0, react_1.useRef)(null);
68
17
  const inputRef = (0, react_1.useRef)(null);
69
18
  const hover = (0, use_hover_state_1.useHoverState)(parentDivRef);
19
+ // eslint-disable-next-line react-hooks/rules-of-hooks
20
+ const randomId = typeof react_1.useId === 'undefined' ? 'volume-slider' : (0, react_1.useId)();
21
+ const [randomClass] = (0, react_1.useState)(() => `__remotion-volume-slider-${(0, remotion_1.random)(randomId)}`.replace('.', ''));
70
22
  const isMutedOrZero = mediaMuted || mediaVolume === 0;
71
23
  const onVolumeChange = (e) => {
72
24
  setMediaVolume(parseFloat(e.target.value));
@@ -88,6 +40,81 @@ const MediaVolumeSlider = () => {
88
40
  }
89
41
  setMediaMuted((mute) => !mute);
90
42
  }, [mediaVolume, setMediaMuted, setMediaVolume]);
91
- return ((0, jsx_runtime_1.jsxs)("div", { ref: parentDivRef, style: parentDivStyle, children: [(0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(icons_1.VolumeOffIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.VolumeOnIcon, {}) }), (focused || hover) && !mediaMuted ? ((0, jsx_runtime_1.jsx)("input", { ref: inputRef, "aria-label": "Change volume", className: player_css_classname_1.VOLUME_SLIDER_INPUT_CSS_CLASSNAME, max: 1, min: 0, onBlur: () => setFocused(false), onChange: onVolumeChange, step: 0.01, type: "range", value: mediaVolume })) : null] }));
43
+ const parentDivStyle = (0, react_1.useMemo)(() => {
44
+ return {
45
+ display: 'inline-flex',
46
+ background: 'none',
47
+ border: 'none',
48
+ padding: '6px',
49
+ justifyContent: 'center',
50
+ alignItems: 'center',
51
+ touchAction: 'none',
52
+ ...(displayVerticalVolumeSlider && { position: 'relative' }),
53
+ };
54
+ }, [displayVerticalVolumeSlider]);
55
+ const volumeContainer = (0, react_1.useMemo)(() => {
56
+ return {
57
+ display: 'inline',
58
+ width: icons_1.ICON_SIZE,
59
+ height: icons_1.ICON_SIZE,
60
+ cursor: 'pointer',
61
+ appearance: 'none',
62
+ background: 'none',
63
+ border: 'none',
64
+ padding: 0,
65
+ };
66
+ }, []);
67
+ const inputStyle = (0, react_1.useMemo)(() => {
68
+ const commonStyle = {
69
+ WebkitAppearance: 'none',
70
+ backgroundColor: 'rgba(255, 255, 255, 0.5)',
71
+ borderRadius: BAR_HEIGHT / 2,
72
+ cursor: 'pointer',
73
+ height: BAR_HEIGHT,
74
+ width: exports.VOLUME_SLIDER_WIDTH,
75
+ };
76
+ if (displayVerticalVolumeSlider) {
77
+ return {
78
+ ...commonStyle,
79
+ transform: `rotate(-90deg)`,
80
+ position: 'absolute',
81
+ bottom: icons_1.ICON_SIZE + exports.VOLUME_SLIDER_WIDTH / 2 + 5,
82
+ };
83
+ }
84
+ return {
85
+ ...commonStyle,
86
+ marginLeft: 5,
87
+ };
88
+ }, [displayVerticalVolumeSlider]);
89
+ const sliderStyle = `
90
+ .${randomClass}::-webkit-slider-thumb {
91
+ -webkit-appearance: none;
92
+ background-color: white;
93
+ border-radius: ${KNOB_SIZE / 2}px;
94
+ box-shadow: 0 0 2px black;
95
+ height: ${KNOB_SIZE}px;
96
+ width: ${KNOB_SIZE}px;
97
+ }
98
+ .${randomClass} {
99
+ background-image: linear-gradient(
100
+ to right,
101
+ white ${mediaVolume * 100}%, rgba(255, 255, 255, 0) ${mediaVolume * 100}%
102
+ );
103
+ }
104
+
105
+ .${randomClass}::-moz-range-thumb {
106
+ -webkit-appearance: none;
107
+ background-color: white;
108
+ border-radius: ${KNOB_SIZE / 2}px;
109
+ box-shadow: 0 0 2px black;
110
+ height: ${KNOB_SIZE}px;
111
+ width: ${KNOB_SIZE}px;
112
+ }
113
+ `;
114
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: parentDivRef, style: parentDivStyle, children: [(0, jsx_runtime_1.jsx)("style", {
115
+ // eslint-disable-next-line react/no-danger
116
+ dangerouslySetInnerHTML: {
117
+ __html: sliderStyle,
118
+ } }), (0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(icons_1.VolumeOffIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.VolumeOnIcon, {}) }), (focused || hover) && !mediaMuted ? ((0, jsx_runtime_1.jsx)("input", { ref: inputRef, "aria-label": "Change volume", className: randomClass, max: 1, min: 0, onBlur: () => setFocused(false), onChange: onVolumeChange, step: 0.01, type: "range", value: mediaVolume, style: inputStyle })) : null] }));
92
119
  };
93
120
  exports.MediaVolumeSlider = MediaVolumeSlider;
package/dist/Player.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { ComponentType, MutableRefObject } from 'react';
2
2
  import React from 'react';
3
3
  import type { CompProps } from 'remotion';
4
4
  import type { PlayerRef } from './player-methods';
5
+ import type { RenderFullscreenButton, RenderPlayPauseButton } from './PlayerControls';
5
6
  import type { RenderLoading, RenderPoster } from './PlayerUI';
6
7
  declare type PropsIfHasProps<Props> = {} extends Props ? {
7
8
  inputProps?: Props;
@@ -38,9 +39,12 @@ export declare type PlayerProps<T> = {
38
39
  showPosterWhenUnplayed?: boolean;
39
40
  inFrame?: number | null;
40
41
  outFrame?: number | null;
42
+ initiallyShowControls?: number | boolean;
43
+ renderPlayPauseButton?: RenderPlayPauseButton;
44
+ renderFullscreenButton?: RenderFullscreenButton;
41
45
  } & PropsIfHasProps<T> & CompProps<T>;
42
46
  export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
43
- export declare const PlayerFn: <T>({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls, loop, autoPlay, showVolumeControls, allowFullscreen, clickToPlay, doubleClickToFullscreen, spaceKeyToPlayOrPause, moveToBeginningWhenEnded, numberOfSharedAudioTags, errorFallback, playbackRate, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
47
+ 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, renderFullscreenButton, renderPlayPauseButton, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
44
48
  declare module 'react' {
45
49
  function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
46
50
  }
package/dist/Player.js CHANGED
@@ -22,7 +22,7 @@ const componentOrNullIfLazy = (props) => {
22
22
  return null;
23
23
  };
24
24
  exports.componentOrNullIfLazy = componentOrNullIfLazy;
25
- const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, ...componentProps }, ref) => {
25
+ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, ...componentProps }, ref) => {
26
26
  if (typeof window !== 'undefined') {
27
27
  // eslint-disable-next-line react-hooks/rules-of-hooks
28
28
  (0, react_1.useLayoutEffect)(() => {
@@ -110,7 +110,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
110
110
  setMediaVolume(vol);
111
111
  (0, volume_persistance_1.persistVolume)(vol);
112
112
  }, []);
113
- (0, react_1.useImperativeHandle)(ref, () => rootRef.current);
113
+ (0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
114
114
  const timelineContextValue = (0, react_1.useMemo)(() => {
115
115
  return {
116
116
  frame,
@@ -195,9 +195,9 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
195
195
  remotion_1.Internals.CSSUtils.injectCSS(remotion_1.Internals.CSSUtils.makeDefaultCSS(`.${player_css_classname_1.PLAYER_CSS_CLASSNAME}`, '#fff'));
196
196
  }, []);
197
197
  }
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)(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 }) }) }) }) }) }) }) }) }));
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, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null }) }) }) }) }) }) }) }) }) }) }));
201
201
  };
202
202
  exports.PlayerFn = PlayerFn;
203
203
  exports.Player = (0, react_1.forwardRef)(exports.PlayerFn);
@@ -1,6 +1,14 @@
1
- import type { MouseEventHandler } from 'react';
1
+ import type { MouseEventHandler, ReactNode } from 'react';
2
2
  import React from 'react';
3
3
  import type { usePlayer } from './use-player';
4
+ export declare type RenderPlayPauseButton = (props: {
5
+ playing: boolean;
6
+ }) => ReactNode;
7
+ export declare type RenderFullscreenButton = (props: {
8
+ isFullscreen: boolean;
9
+ }) => ReactNode;
10
+ export declare const X_SPACER = 10;
11
+ export declare const X_PADDING = 12;
4
12
  declare global {
5
13
  interface Document {
6
14
  webkitFullscreenEnabled?: boolean;
@@ -26,4 +34,8 @@ export declare const Controls: React.FC<{
26
34
  onSeekStart: () => void;
27
35
  inFrame: number | null;
28
36
  outFrame: number | null;
37
+ initiallyShowControls: number | boolean;
38
+ playerWidth: number;
39
+ renderPlayPauseButton: RenderPlayPauseButton | null;
40
+ renderFullscreenButton: RenderFullscreenButton | null;
29
41
  }>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Controls = void 0;
3
+ exports.Controls = exports.X_PADDING = exports.X_SPACER = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
@@ -8,6 +8,9 @@ const format_time_1 = require("./format-time");
8
8
  const icons_1 = require("./icons");
9
9
  const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
10
10
  const PlayerSeekBar_1 = require("./PlayerSeekBar");
11
+ const use_video_controls_resize_1 = require("./use-video-controls-resize");
12
+ exports.X_SPACER = 10;
13
+ exports.X_PADDING = 12;
11
14
  const containerStyle = {
12
15
  boxSizing: 'border-box',
13
16
  position: 'absolute',
@@ -17,8 +20,8 @@ const containerStyle = {
17
20
  paddingBottom: 10,
18
21
  background: 'linear-gradient(transparent, rgba(0, 0, 0, 0.4))',
19
22
  display: 'flex',
20
- paddingRight: 12,
21
- paddingLeft: 12,
23
+ paddingRight: exports.X_PADDING,
24
+ paddingLeft: exports.X_PADDING,
22
25
  flexDirection: 'column',
23
26
  transition: 'opacity 0.3s',
24
27
  };
@@ -57,23 +60,41 @@ const flex1 = {
57
60
  flex: 1,
58
61
  };
59
62
  const fullscreen = {};
60
- const timeLabel = {
61
- color: 'white',
62
- fontFamily: 'sans-serif',
63
- fontSize: 14,
64
- };
65
- const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, }) => {
63
+ const PlayPauseButton = ({ playing }) => playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {});
64
+ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, onSeekEnd, onSeekStart, inFrame, outFrame, initiallyShowControls, playerWidth, renderPlayPauseButton, renderFullscreenButton, }) => {
66
65
  const playButtonRef = (0, react_1.useRef)(null);
67
66
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
68
67
  const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
68
+ const { maxTimeLabelWidth, displayVerticalVolumeSlider } = (0, use_video_controls_resize_1.useVideoControlsResize)({ allowFullscreen, playerWidth });
69
+ const [shouldShowInitially, setInitiallyShowControls] = (0, react_1.useState)(() => {
70
+ if (typeof initiallyShowControls === 'boolean') {
71
+ return initiallyShowControls;
72
+ }
73
+ if (typeof initiallyShowControls === 'number') {
74
+ if (initiallyShowControls % 1 !== 0) {
75
+ throw new Error('initiallyShowControls must be an integer or a boolean');
76
+ }
77
+ if (Number.isNaN(initiallyShowControls)) {
78
+ throw new Error('initiallyShowControls must not be NaN');
79
+ }
80
+ if (!Number.isFinite(initiallyShowControls)) {
81
+ throw new Error('initiallyShowControls must be finite');
82
+ }
83
+ if (initiallyShowControls <= 0) {
84
+ throw new Error('initiallyShowControls must be a positive integer');
85
+ }
86
+ return initiallyShowControls;
87
+ }
88
+ throw new TypeError('initiallyShowControls must be a number or a boolean');
89
+ });
69
90
  const containerCss = (0, react_1.useMemo)(() => {
70
91
  // Hide if playing and mouse outside
71
- const shouldShow = hovered || !player.playing;
92
+ const shouldShow = hovered || !player.playing || shouldShowInitially;
72
93
  return {
73
94
  ...containerStyle,
74
95
  opacity: Number(shouldShow),
75
96
  };
76
- }, [hovered, player.playing]);
97
+ }, [hovered, shouldShowInitially, player.playing]);
77
98
  (0, react_1.useEffect)(() => {
78
99
  if (playButtonRef.current && spaceKeyToPlayOrPause) {
79
100
  // This switches focus to play button when player.playing flag changes
@@ -88,8 +109,30 @@ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVo
88
109
  setSupportsFullscreen((_a = (typeof document !== 'undefined' &&
89
110
  (document.fullscreenEnabled || document.webkitFullscreenEnabled))) !== null && _a !== void 0 ? _a : false);
90
111
  }, []);
91
- 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, {})] })) : 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
112
+ (0, react_1.useEffect)(() => {
113
+ if (shouldShowInitially === false) {
114
+ return;
115
+ }
116
+ const time = shouldShowInitially === true ? 2000 : shouldShowInitially;
117
+ const timeout = setTimeout(() => {
118
+ setInitiallyShowControls(false);
119
+ }, time);
120
+ return () => {
121
+ clearInterval(timeout);
122
+ };
123
+ }, [shouldShowInitially]);
124
+ const timeLabel = (0, react_1.useMemo)(() => {
125
+ return {
126
+ color: 'white',
127
+ fontFamily: 'sans-serif',
128
+ fontSize: 14,
129
+ maxWidth: maxTimeLabelWidth,
130
+ overflow: 'hidden',
131
+ textOverflow: 'ellipsis',
132
+ };
133
+ }, [maxTimeLabelWidth]);
134
+ return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: buttonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: renderPlayPauseButton === null ? ((0, jsx_runtime_1.jsx)(PlayPauseButton, { playing: player.playing })) : (renderPlayPauseButton({ playing: player.playing })) }), showVolumeControls ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsx)(MediaVolumeSlider_1.MediaVolumeSlider, { displayVerticalVolumeSlider: displayVerticalVolumeSlider })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_1.formatTime)(frame / fps), " / ", (0, format_time_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), (0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: buttonStyle, onClick: isFullscreen
92
135
  ? onExitFullscreenButtonClick
93
- : onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { 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 })] }));
94
137
  };
95
138
  exports.Controls = Controls;
File without changes
File without changes
@@ -1,5 +1,6 @@
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;
@@ -34,5 +35,8 @@ declare const _default: (props: {
34
35
  showPosterWhenUnplayed: boolean;
35
36
  inFrame: number | null;
36
37
  outFrame: number | null;
38
+ initiallyShowControls: number | boolean;
39
+ renderPlayPauseButton: RenderPlayPauseButton | null;
40
+ renderFullscreen: RenderFullscreenButton | null;
37
41
  } & React.RefAttributes<PlayerRef | null>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
38
42
  export default _default;
package/dist/PlayerUI.js CHANGED
@@ -42,8 +42,8 @@ if (reactVersion === '0') {
42
42
  throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
43
43
  }
44
44
  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, }, ref) => {
46
- var _a, _b, _c;
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, renderFullscreen: renderFullscreenButton, renderPlayPauseButton, }, ref) => {
46
+ var _a, _b, _c, _d, _e;
47
47
  const config = remotion_1.Internals.useUnsafeVideoConfig();
48
48
  const video = remotion_1.Internals.useVideo();
49
49
  const container = (0, react_1.useRef)(null);
@@ -147,6 +147,18 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
147
147
  };
148
148
  }, [player.emitter]);
149
149
  const durationInFrames = (_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1;
150
+ const layout = (0, react_1.useMemo)(() => {
151
+ if (!config || !canvasSize) {
152
+ return null;
153
+ }
154
+ return (0, calculate_scale_1.calculateCanvasTransformation)({
155
+ canvasSize,
156
+ compositionHeight: config.height,
157
+ compositionWidth: config.width,
158
+ previewSize: 'auto',
159
+ });
160
+ }, [canvasSize, config]);
161
+ const scale = (_b = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _b !== void 0 ? _b : 1;
150
162
  (0, react_1.useImperativeHandle)(ref, () => {
151
163
  const methods = {
152
164
  play: player.play,
@@ -196,6 +208,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
196
208
  unmute: () => {
197
209
  setMediaMuted(false);
198
210
  },
211
+ getScale: () => scale,
199
212
  };
200
213
  return Object.assign(player.emitter, methods);
201
214
  }, [
@@ -210,6 +223,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
210
223
  setMediaMuted,
211
224
  setMediaVolume,
212
225
  toggle,
226
+ scale,
213
227
  ]);
214
228
  const VideoComponent = video ? video.component : null;
215
229
  const outerStyle = (0, react_1.useMemo)(() => {
@@ -229,22 +243,11 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
229
243
  ...style,
230
244
  };
231
245
  }, [canvasSize, config, style]);
232
- const layout = (0, react_1.useMemo)(() => {
233
- if (!config || !canvasSize) {
234
- return null;
235
- }
236
- return (0, calculate_scale_1.calculateCanvasTransformation)({
237
- canvasSize,
238
- compositionHeight: config.height,
239
- compositionWidth: config.width,
240
- previewSize: 'auto',
241
- });
242
- }, [canvasSize, config]);
243
246
  const outer = (0, react_1.useMemo)(() => {
244
247
  if (!layout || !config) {
245
248
  return {};
246
249
  }
247
- const { centerX, centerY, scale } = layout;
250
+ const { centerX, centerY } = layout;
248
251
  return {
249
252
  width: config.width * scale,
250
253
  height: config.height * scale,
@@ -255,28 +258,22 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
255
258
  top: centerY,
256
259
  overflow: 'hidden',
257
260
  };
258
- }, [config, layout]);
261
+ }, [config, layout, scale]);
259
262
  const containerStyle = (0, react_1.useMemo)(() => {
260
- if (!config || !canvasSize) {
263
+ if (!config || !canvasSize || !layout) {
261
264
  return {};
262
265
  }
263
- const { scale, xCorrection, yCorrection } = (0, calculate_scale_1.calculateCanvasTransformation)({
264
- canvasSize,
265
- compositionHeight: config.height,
266
- compositionWidth: config.width,
267
- previewSize: 'auto',
268
- });
269
266
  return {
270
267
  position: 'absolute',
271
268
  width: config.width,
272
269
  height: config.height,
273
270
  display: 'flex',
274
271
  transform: `scale(${scale})`,
275
- marginLeft: xCorrection,
276
- marginTop: yCorrection,
272
+ marginLeft: layout.xCorrection,
273
+ marginTop: layout.yCorrection,
277
274
  overflow: 'hidden',
278
275
  };
279
- }, [canvasSize, config]);
276
+ }, [canvasSize, config, layout, scale]);
280
277
  const onError = (0, react_1.useCallback)((error) => {
281
278
  player.pause();
282
279
  // Pay attention to `this context`
@@ -332,7 +329,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
332
329
  showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
333
330
  showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
334
331
  ].some(Boolean);
335
- 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, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...((_c = inputProps) !== null && _c !== void 0 ? _c : {}) }) })) : 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 })) : null] }));
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, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton })) : null] }));
336
333
  if (is_node_1.IS_NODE && !doesReactVersionSupportSuspense) {
337
334
  return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
338
335
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -7,6 +7,9 @@ declare type ErrorPayload = {
7
7
  declare type TimeUpdateEventPayload = {
8
8
  frame: number;
9
9
  };
10
+ declare type FrameUpdateEventPayload = {
11
+ frame: number;
12
+ };
10
13
  declare type RateChangeEventPayload = {
11
14
  playbackRate: number;
12
15
  };
@@ -21,6 +24,7 @@ declare type StateEventMap = {
21
24
  ended: undefined;
22
25
  error: ErrorPayload;
23
26
  timeupdate: TimeUpdateEventPayload;
27
+ frameupdate: FrameUpdateEventPayload;
24
28
  fullscreenchange: FullscreenChangeEventPayload;
25
29
  };
26
30
  export declare type EventTypes = keyof StateEventMap;
@@ -42,6 +46,7 @@ export declare class PlayerEmitter {
42
46
  dispatchRatechange(playbackRate: number): void;
43
47
  dispatchError(error: Error): void;
44
48
  dispatchTimeUpdate(event: TimeUpdateEventPayload): void;
49
+ dispatchFrameUpdate(event: FrameUpdateEventPayload): void;
45
50
  dispatchFullscreenChangeUpdate(event: FullscreenChangeEventPayload): void;
46
51
  }
47
52
  export {};
@@ -11,6 +11,7 @@ class PlayerEmitter {
11
11
  ratechange: [],
12
12
  seeked: [],
13
13
  timeupdate: [],
14
+ frameupdate: [],
14
15
  fullscreenchange: [],
15
16
  };
16
17
  }
@@ -52,6 +53,9 @@ class PlayerEmitter {
52
53
  dispatchTimeUpdate(event) {
53
54
  this.dispatchEvent('timeupdate', event);
54
55
  }
56
+ dispatchFrameUpdate(event) {
57
+ this.dispatchEvent('frameupdate', event);
58
+ }
55
59
  dispatchFullscreenChangeUpdate(event) {
56
60
  this.dispatchEvent('fullscreenchange', event);
57
61
  }
File without changes
File without changes
package/dist/icons.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  export declare const ICON_SIZE = 25;
3
+ export declare const fullscreenIconSize = 16;
3
4
  export declare const PlayIcon: React.FC;
4
5
  export declare const PauseIcon: React.FC;
5
6
  export declare const FullscreenIcon: React.FC<{
6
- minimized: boolean;
7
+ isFullscreen: boolean;
7
8
  }>;
8
9
  export declare const VolumeOffIcon: React.FC;
9
10
  export declare const VolumeOnIcon: React.FC;
package/dist/icons.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VolumeOnIcon = exports.VolumeOffIcon = exports.FullscreenIcon = exports.PauseIcon = exports.PlayIcon = exports.ICON_SIZE = void 0;
3
+ exports.VolumeOnIcon = exports.VolumeOffIcon = exports.FullscreenIcon = exports.PauseIcon = exports.PlayIcon = exports.fullscreenIconSize = exports.ICON_SIZE = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  exports.ICON_SIZE = 25;
6
- const fullscreenIconSize = 16;
6
+ exports.fullscreenIconSize = 16;
7
7
  const rotate = {
8
8
  transform: `rotate(90deg)`,
9
9
  };
@@ -15,13 +15,13 @@ const PauseIcon = () => {
15
15
  return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 100 100", width: exports.ICON_SIZE, height: exports.ICON_SIZE, children: [(0, jsx_runtime_1.jsx)("rect", { x: "25", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" }), (0, jsx_runtime_1.jsx)("rect", { x: "55", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" })] }));
16
16
  };
17
17
  exports.PauseIcon = PauseIcon;
18
- const FullscreenIcon = ({ minimized }) => {
18
+ const FullscreenIcon = ({ isFullscreen, }) => {
19
19
  const strokeWidth = 6;
20
20
  const viewSize = 32;
21
- const out = minimized ? strokeWidth / 2 : 0;
22
- const middleInset = minimized ? strokeWidth / 2 : strokeWidth * 1.6;
23
- const inset = minimized ? strokeWidth * 2 : strokeWidth * 1.6;
24
- return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${viewSize} ${viewSize}`, height: fullscreenIconSize, width: fullscreenIconSize, children: [(0, jsx_runtime_1.jsx)("path", { d: `
21
+ const out = isFullscreen ? 0 : strokeWidth / 2;
22
+ const middleInset = isFullscreen ? strokeWidth * 1.6 : strokeWidth / 2;
23
+ const inset = isFullscreen ? strokeWidth * 1.6 : strokeWidth * 2;
24
+ return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${viewSize} ${viewSize}`, height: exports.fullscreenIconSize, width: exports.fullscreenIconSize, children: [(0, jsx_runtime_1.jsx)("path", { d: `
25
25
  M ${out} ${inset}
26
26
  L ${middleInset} ${middleInset}
27
27
  L ${inset} ${out}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import type { CallbackListener, EventTypes } from './event-emitter';
3
3
  import { PlayerEmitter } from './event-emitter';
4
- export { ErrorFallback, Player, PlayerProps } from './Player';
4
+ export { Player, PlayerProps } from './Player';
5
5
  export { PlayerMethods, PlayerRef } from './player-methods';
6
- export type { RenderLoading, RenderPoster } from './PlayerUI';
6
+ export type { RenderFullscreenButton, RenderPlayPauseButton, } from './PlayerControls';
7
+ export type { ErrorFallback, RenderLoading, RenderPoster } from './PlayerUI';
7
8
  export { PreviewSize, Translation } from './utils/preview-size';
8
9
  export { Size } from './utils/use-element-size';
9
10
  export type { CallbackListener, EventTypes };
package/dist/index.js CHANGED
File without changes
@@ -1,2 +1 @@
1
1
  export declare const PLAYER_CSS_CLASSNAME = "__remotion-player";
2
- export declare const VOLUME_SLIDER_INPUT_CSS_CLASSNAME: string;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VOLUME_SLIDER_INPUT_CSS_CLASSNAME = exports.PLAYER_CSS_CLASSNAME = void 0;
3
+ exports.PLAYER_CSS_CLASSNAME = void 0;
4
4
  exports.PLAYER_CSS_CLASSNAME = '__remotion-player';
5
- exports.VOLUME_SLIDER_INPUT_CSS_CLASSNAME = exports.PLAYER_CSS_CLASSNAME.concat('_volume-slider-input');
@@ -16,5 +16,6 @@ export declare type PlayerMethods = {
16
16
  isPlaying: () => boolean;
17
17
  mute: () => void;
18
18
  unmute: () => void;
19
+ getScale: () => number;
19
20
  };
20
21
  export declare type PlayerRef = PlayerEmitter & PlayerMethods;
File without changes
File without changes
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
3
4
  const use_player_1 = require("../use-player");
4
- test('It should throw an error if not being used inside a RemotionRoot', () => {
5
- expect(() => {
5
+ (0, vitest_1.test)('It should throw an error if not being used inside a RemotionRoot', () => {
6
+ (0, vitest_1.expect)(() => {
6
7
  (0, use_player_1.usePlayer)();
7
8
  }).toThrow();
8
9
  });
File without changes
File without changes
File without changes
@@ -1,53 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
3
4
  const validate_in_out_frame_1 = require("../utils/validate-in-out-frame");
4
- test('Validate in out frames', () => {
5
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
5
+ (0, vitest_1.test)('Validate in out frames', () => {
6
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
6
7
  durationInFrames: 200,
7
8
  inFrame: 201,
8
9
  outFrame: undefined,
9
10
  })).toThrow(/inFrame must be less than \(durationInFrames - 1\)/);
10
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
11
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
11
12
  durationInFrames: 200,
12
13
  inFrame: 199,
13
14
  outFrame: 201,
14
15
  })).toThrow(/outFrame must be less than \(durationInFrames - 1\)/);
15
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
16
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
16
17
  durationInFrames: 200,
17
18
  inFrame: -10,
18
19
  outFrame: null,
19
20
  })).toThrow(/inFrame must be greater than 0, but is -10/);
20
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
21
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
21
22
  durationInFrames: 200,
22
23
  inFrame: null,
23
24
  outFrame: -10,
24
25
  })).toThrow(/outFrame must be greater than 0, but is -10/);
25
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
26
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
26
27
  durationInFrames: 200,
27
28
  inFrame: 1.5,
28
29
  outFrame: null,
29
30
  })).toThrow(/"inFrame" must be an integer, but is 1.5/);
30
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
31
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
31
32
  durationInFrames: 200,
32
33
  inFrame: 20,
33
34
  outFrame: 20,
34
35
  })).toThrow(/outFrame must be greater than inFrame, but is 20/);
35
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
36
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
36
37
  durationInFrames: 200,
37
38
  inFrame: 21,
38
39
  outFrame: 20,
39
40
  })).toThrow(/outFrame must be greater than inFrame, but is 20 <= 21/);
40
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
41
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
41
42
  durationInFrames: 200,
42
43
  inFrame: null,
43
44
  outFrame: 20,
44
45
  })).not.toThrow();
45
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
46
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
46
47
  durationInFrames: 200,
47
48
  inFrame: null,
48
49
  outFrame: null,
49
50
  })).not.toThrow();
50
- expect(() => (0, validate_in_out_frame_1.validateInOutFrames)({
51
+ (0, vitest_1.expect)(() => (0, validate_in_out_frame_1.validateInOutFrames)({
51
52
  durationInFrames: 200,
52
53
  inFrame: 10,
53
54
  outFrame: 20,
File without changes
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const remotion_1 = require("remotion");
5
+ const vitest_1 = require("vitest");
5
6
  const index_1 = require("../index");
6
7
  const test_utils_1 = require("./test-utils");
7
- test('no compositionWidth should give errors', () => {
8
+ (0, vitest_1.test)('no compositionWidth should give errors', () => {
8
9
  try {
9
10
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player
10
11
  // @ts-expect-error
@@ -13,27 +14,27 @@ test('no compositionWidth should give errors', () => {
13
14
  compositionWidth: null, errorFallback: () => 'something went wrong', compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
14
15
  }
15
16
  catch (e) {
16
- expect(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
17
+ (0, vitest_1.expect)(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
17
18
  }
18
19
  });
19
- test('no compositionHeight should give errors', () => {
20
+ (0, vitest_1.test)('no compositionHeight should give errors', () => {
20
21
  try {
21
22
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 400, errorFallback: () => 'something went wrong',
22
23
  // @ts-expect-error
23
24
  compositionHeight: undefined, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
24
25
  }
25
26
  catch (e) {
26
- expect(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
27
+ (0, vitest_1.expect)(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
27
28
  }
28
29
  });
29
- test('No fps should give errors', () => {
30
+ (0, vitest_1.test)('No fps should give errors', () => {
30
31
  try {
31
32
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
32
33
  // @ts-expect-error
33
34
  fps: null, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
34
35
  }
35
36
  catch (e) {
36
- expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
37
+ (0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
37
38
  }
38
39
  try {
39
40
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
@@ -41,51 +42,51 @@ test('No fps should give errors', () => {
41
42
  fps: undefined, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
42
43
  }
43
44
  catch (e) {
44
- expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
45
+ (0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
45
46
  }
46
47
  });
47
- test('No durationInFrames should give errors', () => {
48
+ (0, vitest_1.test)('No durationInFrames should give errors', () => {
48
49
  try {
49
50
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30,
50
51
  // @ts-expect-error
51
52
  durationInFrames: undefined, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
52
53
  }
53
54
  catch (e) {
54
- expect(e.message).toMatch(/durationInFrames` must be a number, but is undefined/);
55
+ (0, vitest_1.expect)(e.message).toMatch(/durationInFrames` must be a number, but is undefined/);
55
56
  }
56
57
  });
57
- test('Invalid playbackRate should give error', () => {
58
+ (0, vitest_1.test)('Invalid playbackRate should give error', () => {
58
59
  try {
59
60
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: -5 }));
60
61
  }
61
62
  catch (e) {
62
- expect(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
63
+ (0, vitest_1.expect)(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
63
64
  }
64
65
  });
65
- test('playbackRate of 0 should not be possible', () => {
66
+ (0, vitest_1.test)('playbackRate of 0 should not be possible', () => {
66
67
  try {
67
68
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: 0 }));
68
69
  }
69
70
  catch (e) {
70
- expect(e.message).toMatch(/A playback rate of 0 is not supported./);
71
+ (0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
71
72
  }
72
73
  });
73
- test('playbackRate of wrong type should not be possible', () => {
74
+ (0, vitest_1.test)('playbackRate of wrong type should not be possible', () => {
74
75
  try {
75
76
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true,
76
77
  // @ts-expect-error
77
78
  playbackRate: 'hi' }));
78
79
  }
79
80
  catch (e) {
80
- expect(e.message).toMatch(/A playback rate of 0 is not supported./);
81
+ (0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
81
82
  }
82
83
  });
83
- test('playbackRate of undefined should be okay', () => {
84
+ (0, vitest_1.test)('playbackRate of undefined should be okay', () => {
84
85
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
85
- expect(true).toBe(true);
86
+ (0, vitest_1.expect)(true).toBe(true);
86
87
  });
87
- test('passing in <Composition /> instance should not be possible', () => {
88
- expect(() => {
88
+ (0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
89
+ (0, vitest_1.expect)(() => {
89
90
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: remotion_1.Composition, controls: true, showVolumeControls: true, inputProps: {
90
91
  id: 'HelloWorld',
91
92
  width: 500,
@@ -96,8 +97,8 @@ test('passing in <Composition /> instance should not be possible', () => {
96
97
  } }));
97
98
  }).toThrow(/'component' must not be the 'Composition' component\. Pass your own React/);
98
99
  });
99
- test('passing in <Composition /> instance should not be possible', () => {
100
- expect(() => {
100
+ (0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
101
+ (0, vitest_1.expect)(() => {
101
102
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500,
102
103
  // @ts-expect-error
103
104
  component: (0, jsx_runtime_1.jsx)(remotion_1.Composition, { durationInFrames: 30, fps: 30, height: 10, width: 10, id: "hello", component: test_utils_1.HelloWorld }), controls: true, showVolumeControls: true, inputProps: {
@@ -110,7 +111,7 @@ test('passing in <Composition /> instance should not be possible', () => {
110
111
  } }));
111
112
  }).toThrow(/'component' should not be an instance of <Composition\/>\. Pass the React component dir/);
112
113
  });
113
- test.each([
114
+ vitest_1.test.each([
114
115
  ['controls'],
115
116
  ['loop'],
116
117
  ['autoPlay'],
@@ -125,6 +126,6 @@ test.each([
125
126
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30, durationInFrames: 100, component: test_utils_1.HelloWorld, ...props }));
126
127
  }
127
128
  catch (e) {
128
- expect(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
129
+ (0, vitest_1.expect)(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
129
130
  }
130
131
  });
File without changes
File without changes
File without changes
@@ -85,5 +85,8 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
85
85
  }, 250);
86
86
  return () => clearInterval(interval);
87
87
  }, [emitter]);
88
+ (0, react_1.useEffect)(() => {
89
+ emitter.dispatchFrameUpdate({ frame });
90
+ }, [emitter, frame]);
88
91
  };
89
92
  exports.usePlayback = usePlayback;
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ export declare const useVideoControlsResize: ({ allowFullscreen: allowFullScreen, playerWidth, }: {
2
+ allowFullscreen: boolean;
3
+ playerWidth: number;
4
+ }) => {
5
+ maxTimeLabelWidth: number;
6
+ displayVerticalVolumeSlider: boolean;
7
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useVideoControlsResize = void 0;
4
+ const react_1 = require("react");
5
+ const icons_1 = require("./icons");
6
+ const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
7
+ const PlayerControls_1 = require("./PlayerControls");
8
+ const useVideoControlsResize = ({ allowFullscreen: allowFullScreen, playerWidth, }) => {
9
+ const resizeInfo = (0, react_1.useMemo)(() => {
10
+ const playPauseIconSize = icons_1.ICON_SIZE;
11
+ const volumeIconSize = icons_1.ICON_SIZE;
12
+ const _fullscreenIconSize = allowFullScreen ? icons_1.fullscreenIconSize : 0;
13
+ const elementsSize = volumeIconSize +
14
+ playPauseIconSize +
15
+ _fullscreenIconSize +
16
+ PlayerControls_1.X_PADDING * 2 +
17
+ PlayerControls_1.X_SPACER * 2;
18
+ const maxTimeLabelWidth = playerWidth - elementsSize;
19
+ const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
20
+ const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH;
21
+ // If max label width is lower than the volume width
22
+ // then it means we need to take it's width as the max label width
23
+ // otherwise we took the available width when volume open
24
+ const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen < MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH
25
+ ? maxTimeLabelWidthWithoutNegativeValue
26
+ : availableTimeLabelWidthIfVolumeOpen;
27
+ const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize + MediaVolumeSlider_1.VOLUME_SLIDER_WIDTH;
28
+ const displayVerticalVolumeSlider = playerWidth < minWidthForHorizontalDisplay;
29
+ return {
30
+ maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue,
31
+ displayVerticalVolumeSlider,
32
+ };
33
+ }, [allowFullScreen, playerWidth]);
34
+ return resizeInfo;
35
+ };
36
+ exports.useVideoControlsResize = useVideoControlsResize;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@remotion/player",
3
- "version": "4.0.0-prefetch.10+cf59c29c7",
3
+ "version": "4.0.0-prefetch.12+c7eb5bd76",
4
4
  "description": "Remotion Player",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "lint": "eslint src --ext ts,tsx",
9
- "test": "jest",
10
9
  "build": "tsc -d",
11
10
  "watch": "tsc -w",
12
11
  "prerelease": "cp ../../README.md ."
@@ -28,7 +27,7 @@
28
27
  ],
29
28
  "license": "SEE LICENSE IN LICENSE.md",
30
29
  "dependencies": {
31
- "remotion": "4.0.0-prefetch.10+cf59c29c7"
30
+ "remotion": "4.0.0-prefetch.12+c7eb5bd76"
32
31
  },
33
32
  "peerDependencies": {
34
33
  "react": ">=16.8.0",
@@ -37,20 +36,20 @@
37
36
  "devDependencies": {
38
37
  "@jonny/eslint-config": "3.0.266",
39
38
  "@testing-library/react": "13.1.1",
40
- "@types/jest": "^27.4.0",
41
39
  "@types/node": "^14.14.14",
42
40
  "@types/react": "18.0.1",
43
41
  "@types/react-dom": "18.0.0",
42
+ "@vitejs/plugin-react": "^2.0.0",
44
43
  "csstype": "^3.0.9",
45
- "eslint": "8.13.0",
46
- "jest": "^27.2.4",
47
- "prettier": "^2.0.5",
44
+ "eslint": "8.25.0",
45
+ "jsdom": "20.0.1",
46
+ "prettier": "^2.7.1",
48
47
  "prettier-plugin-organize-imports": "^2.3.4",
49
48
  "react": "^18.0.0",
50
49
  "react-dom": "^18.0.0",
51
- "ts-jest": "^27.0.5",
52
50
  "typescript": "^4.7.0",
53
- "webpack": "5.72.0"
51
+ "vitest": "0.24.3",
52
+ "webpack": "5.74.0"
54
53
  },
55
54
  "keywords": [
56
55
  "remotion",
@@ -63,5 +62,5 @@
63
62
  "publishConfig": {
64
63
  "access": "public"
65
64
  },
66
- "gitHead": "cf59c29c7b500377b7157afb761754159156d25f"
65
+ "gitHead": "c7eb5bd76f2f89677f007a54e1bc5d3e3403094f"
67
66
  }