@remotion/player 4.0.452 → 4.0.453

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.
@@ -61,6 +61,7 @@ export type PlayerProps<Schema extends AnyZodObject, Props extends Record<string
61
61
  readonly acknowledgeRemotionLicense?: boolean;
62
62
  readonly audioLatencyHint?: AudioContextLatencyCategory;
63
63
  readonly volumePersistenceKey?: string;
64
+ readonly initialVolume?: number;
64
65
  } & CompProps<Props> & PropsIfHasProps<Schema, Props>;
65
66
  export type PlayerPropsWithoutZod<Props extends Record<string, unknown>> = PlayerProps<AnyZodObject, Props>;
66
67
  export declare const componentOrNullIfLazy: <Props>(props: CompProps<Props>) => ComponentType<Props> | null;
@@ -23,7 +23,7 @@ const componentOrNullIfLazy = (props) => {
23
23
  return null;
24
24
  };
25
25
  exports.componentOrNullIfLazy = componentOrNullIfLazy;
26
- 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, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, renderVolumeSlider, renderCustomControls, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'playback', volumePersistenceKey, ...componentProps }, ref) => {
26
+ 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, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, renderVolumeSlider, renderCustomControls, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'playback', volumePersistenceKey, initialVolume, ...componentProps }, ref) => {
27
27
  if (typeof window !== 'undefined') {
28
28
  window.remotion_isPlayer = true;
29
29
  }
@@ -102,6 +102,17 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
102
102
  typeof spaceKeyToPlayOrPause !== 'undefined') {
103
103
  throw new TypeError(`'spaceKeyToPlayOrPause' must be a boolean or undefined but got '${typeof spaceKeyToPlayOrPause}' instead`);
104
104
  }
105
+ if (typeof initialVolume !== 'undefined' &&
106
+ typeof initialVolume !== 'number') {
107
+ throw new TypeError(`'initialVolume' must be a number or undefined but got '${typeof initialVolume}' instead`);
108
+ }
109
+ if (typeof initialVolume === 'number' &&
110
+ (!Number.isFinite(initialVolume) ||
111
+ Number.isNaN(initialVolume) ||
112
+ initialVolume < 0 ||
113
+ initialVolume > 1)) {
114
+ throw new TypeError(`'initialVolume' must be between 0 and 1 but got '${initialVolume}' instead`);
115
+ }
105
116
  if (typeof numberOfSharedAudioTags !== 'number' ||
106
117
  numberOfSharedAudioTags % 1 !== 0 ||
107
118
  !Number.isFinite(numberOfSharedAudioTags) ||
@@ -154,7 +165,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
154
165
  mode: 'prevent-media-session',
155
166
  });
156
167
  }, [passedBrowserMediaControlsBehavior]);
157
- return (jsx_runtime_1.jsx(remotion_1.Internals.IsPlayerContextProvider, { children: jsx_runtime_1.jsx(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, volumePersistenceKey: volumePersistenceKey, inputProps: actualInputProps, audioEnabled: true, children: jsx_runtime_1.jsx(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx_runtime_1.jsx(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: jsx_runtime_1.jsx(PlayerUI_js_1.default, { ref: rootRef, posterFillMode: posterFillMode, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: actualInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
168
+ return (jsx_runtime_1.jsx(remotion_1.Internals.IsPlayerContextProvider, { children: jsx_runtime_1.jsx(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, volumePersistenceKey: volumePersistenceKey, initialVolume: initialVolume, inputProps: actualInputProps, audioEnabled: true, children: jsx_runtime_1.jsx(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx_runtime_1.jsx(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: jsx_runtime_1.jsx(PlayerUI_js_1.default, { ref: rootRef, posterFillMode: posterFillMode, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: actualInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
158
169
  ? clickToPlay
159
170
  : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: currentPlaybackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), showPosterWhenBuffering: Boolean(showPosterWhenBuffering), showPosterWhenBufferingAndPaused: Boolean(showPosterWhenBufferingAndPaused), 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, renderMuteButton: renderMuteButton !== null && renderMuteButton !== void 0 ? renderMuteButton : null, renderVolumeSlider: renderVolumeSlider !== null && renderVolumeSlider !== void 0 ? renderVolumeSlider : null, renderCustomControls: renderCustomControls !== null && renderCustomControls !== void 0 ? renderCustomControls : null, alwaysShowControls: alwaysShowControls, showPlaybackRateControl: showPlaybackRateControl, bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds !== null && bufferStateDelayInMilliseconds !== void 0 ? bufferStateDelayInMilliseconds : 300, hideControlsWhenPointerDoesntMove: hideControlsWhenPointerDoesntMove, overflowVisible: overflowVisible, browserMediaControlsBehavior: browserMediaControlsBehavior, overrideInternalClassName: overrideInternalClassName !== null && overrideInternalClassName !== void 0 ? overrideInternalClassName : undefined, noSuspense: Boolean(noSuspense) }) }) }) }) }));
160
171
  };
@@ -15,6 +15,7 @@ export declare const SharedPlayerContexts: React.FC<{
15
15
  readonly logLevel: LogLevel;
16
16
  readonly audioLatencyHint: AudioContextLatencyCategory;
17
17
  readonly volumePersistenceKey?: string;
18
+ readonly initialVolume?: number;
18
19
  readonly inputProps: Record<string, unknown>;
19
20
  readonly audioEnabled: boolean;
20
21
  }>;
@@ -6,7 +6,8 @@ const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
7
  const volume_persistence_js_1 = require("./volume-persistence.js");
8
8
  exports.PLAYER_COMP_ID = 'player-comp';
9
- const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, initiallyMuted, logLevel, audioLatencyHint, volumePersistenceKey, inputProps, audioEnabled, }) => {
9
+ const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, initiallyMuted, logLevel, audioLatencyHint, volumePersistenceKey, initialVolume, inputProps, audioEnabled, }) => {
10
+ const persistVolumeToStorage = initialVolume === undefined;
10
11
  const compositionManagerContext = (0, react_1.useMemo)(() => {
11
12
  const context = {
12
13
  compositions: [
@@ -51,7 +52,9 @@ const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeigh
51
52
  inputProps,
52
53
  ]);
53
54
  const [mediaMuted, setMediaMuted] = (0, react_1.useState)(() => initiallyMuted);
54
- const [mediaVolume, setMediaVolume] = (0, react_1.useState)(() => (0, volume_persistence_js_1.getPreferredVolume)(volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : null));
55
+ const [mediaVolume, setMediaVolume] = (0, react_1.useState)(() => persistVolumeToStorage
56
+ ? (0, volume_persistence_js_1.getPreferredVolume)(volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : null)
57
+ : initialVolume);
55
58
  const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
56
59
  return {
57
60
  mediaMuted,
@@ -60,8 +63,10 @@ const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeigh
60
63
  }, [mediaMuted, mediaVolume]);
61
64
  const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
62
65
  setMediaVolume(vol);
63
- (0, volume_persistence_js_1.persistVolume)(vol, logLevel, volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : null);
64
- }, [logLevel, volumePersistenceKey]);
66
+ if (persistVolumeToStorage) {
67
+ (0, volume_persistence_js_1.persistVolume)(vol, logLevel, volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : null);
68
+ }
69
+ }, [persistVolumeToStorage, logLevel, volumePersistenceKey]);
65
70
  const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
66
71
  return {
67
72
  setMediaMuted,
@@ -34,21 +34,24 @@ const useElementSize = (ref, options) => {
34
34
  return null;
35
35
  }
36
36
  return new ResizeObserver((entries) => {
37
- // The contentRect returns the width without any `scale()`'s being applied. The height is wrong
37
+ // `contentRect` is the element's pre-transform content box.
38
+ // `getClientRects()` is the post-transform AABB. Dividing each AABB
39
+ // axis by its content-box counterpart cancels the parent CSS transform
40
+ // whether it is uniform or not.
38
41
  const { contentRect, target } = entries[0];
39
- // The clientRect returns the size with `scale()` being applied.
40
42
  const newSize = target.getClientRects();
41
43
  if (!(newSize === null || newSize === void 0 ? void 0 : newSize[0])) {
42
44
  setSize(null);
43
45
  return;
44
46
  }
45
- const probableCssParentScale = contentRect.width === 0 ? 1 : newSize[0].width / contentRect.width;
46
- const width = options.shouldApplyCssTransforms || probableCssParentScale === 0
47
+ const probableCssParentScaleX = contentRect.width === 0 ? 1 : newSize[0].width / contentRect.width;
48
+ const probableCssParentScaleY = contentRect.height === 0 ? 1 : newSize[0].height / contentRect.height;
49
+ const width = options.shouldApplyCssTransforms || probableCssParentScaleX === 0
47
50
  ? newSize[0].width
48
- : newSize[0].width * (1 / probableCssParentScale);
49
- const height = options.shouldApplyCssTransforms || probableCssParentScale === 0
51
+ : newSize[0].width * (1 / probableCssParentScaleX);
52
+ const height = options.shouldApplyCssTransforms || probableCssParentScaleY === 0
50
53
  ? newSize[0].height
51
- : newSize[0].height * (1 / probableCssParentScale);
54
+ : newSize[0].height * (1 / probableCssParentScaleY);
52
55
  setSize((prevState) => {
53
56
  const isSame = prevState &&
54
57
  prevState.width === width &&
@@ -1174,9 +1174,10 @@ var useElementSize = (ref, options) => {
1174
1174
  setSize(null);
1175
1175
  return;
1176
1176
  }
1177
- const probableCssParentScale = contentRect.width === 0 ? 1 : newSize[0].width / contentRect.width;
1178
- const width = options.shouldApplyCssTransforms || probableCssParentScale === 0 ? newSize[0].width : newSize[0].width * (1 / probableCssParentScale);
1179
- const height = options.shouldApplyCssTransforms || probableCssParentScale === 0 ? newSize[0].height : newSize[0].height * (1 / probableCssParentScale);
1177
+ const probableCssParentScaleX = contentRect.width === 0 ? 1 : newSize[0].width / contentRect.width;
1178
+ const probableCssParentScaleY = contentRect.height === 0 ? 1 : newSize[0].height / contentRect.height;
1179
+ const width = options.shouldApplyCssTransforms || probableCssParentScaleX === 0 ? newSize[0].width : newSize[0].width * (1 / probableCssParentScaleX);
1180
+ const height = options.shouldApplyCssTransforms || probableCssParentScaleY === 0 ? newSize[0].height : newSize[0].height * (1 / probableCssParentScaleY);
1180
1181
  setSize((prevState) => {
1181
1182
  const isSame = prevState && prevState.width === width && prevState.height === height && prevState.left === newSize[0].x && prevState.top === newSize[0].y && prevState.windowSize.height === window.innerHeight && prevState.windowSize.width === window.innerWidth;
1182
1183
  if (isSame) {
@@ -3001,9 +3002,11 @@ var SharedPlayerContexts = ({
3001
3002
  logLevel,
3002
3003
  audioLatencyHint,
3003
3004
  volumePersistenceKey,
3005
+ initialVolume,
3004
3006
  inputProps,
3005
3007
  audioEnabled
3006
3008
  }) => {
3009
+ const persistVolumeToStorage = initialVolume === undefined;
3007
3010
  const compositionManagerContext = useMemo13(() => {
3008
3011
  const context = {
3009
3012
  compositions: [
@@ -3048,7 +3051,7 @@ var SharedPlayerContexts = ({
3048
3051
  inputProps
3049
3052
  ]);
3050
3053
  const [mediaMuted, setMediaMuted] = useState12(() => initiallyMuted);
3051
- const [mediaVolume, setMediaVolume] = useState12(() => getPreferredVolume(volumePersistenceKey ?? null));
3054
+ const [mediaVolume, setMediaVolume] = useState12(() => persistVolumeToStorage ? getPreferredVolume(volumePersistenceKey ?? null) : initialVolume);
3052
3055
  const mediaVolumeContextValue = useMemo13(() => {
3053
3056
  return {
3054
3057
  mediaMuted,
@@ -3057,8 +3060,10 @@ var SharedPlayerContexts = ({
3057
3060
  }, [mediaMuted, mediaVolume]);
3058
3061
  const setMediaVolumeAndPersist = useCallback12((vol) => {
3059
3062
  setMediaVolume(vol);
3060
- persistVolume(vol, logLevel, volumePersistenceKey ?? null);
3061
- }, [logLevel, volumePersistenceKey]);
3063
+ if (persistVolumeToStorage) {
3064
+ persistVolume(vol, logLevel, volumePersistenceKey ?? null);
3065
+ }
3066
+ }, [persistVolumeToStorage, logLevel, volumePersistenceKey]);
3062
3067
  const setMediaVolumeContextValue = useMemo13(() => {
3063
3068
  return {
3064
3069
  setMediaMuted,
@@ -3288,6 +3293,7 @@ var PlayerFn = ({
3288
3293
  acknowledgeRemotionLicense,
3289
3294
  audioLatencyHint = "playback",
3290
3295
  volumePersistenceKey,
3296
+ initialVolume,
3291
3297
  ...componentProps
3292
3298
  }, ref) => {
3293
3299
  if (typeof window !== "undefined") {
@@ -3362,6 +3368,12 @@ var PlayerFn = ({
3362
3368
  if (typeof spaceKeyToPlayOrPause !== "boolean" && typeof spaceKeyToPlayOrPause !== "undefined") {
3363
3369
  throw new TypeError(`'spaceKeyToPlayOrPause' must be a boolean or undefined but got '${typeof spaceKeyToPlayOrPause}' instead`);
3364
3370
  }
3371
+ if (typeof initialVolume !== "undefined" && typeof initialVolume !== "number") {
3372
+ throw new TypeError(`'initialVolume' must be a number or undefined but got '${typeof initialVolume}' instead`);
3373
+ }
3374
+ if (typeof initialVolume === "number" && (!Number.isFinite(initialVolume) || Number.isNaN(initialVolume) || initialVolume < 0 || initialVolume > 1)) {
3375
+ throw new TypeError(`'initialVolume' must be between 0 and 1 but got '${initialVolume}' instead`);
3376
+ }
3365
3377
  if (typeof numberOfSharedAudioTags !== "number" || numberOfSharedAudioTags % 1 !== 0 || !Number.isFinite(numberOfSharedAudioTags) || Number.isNaN(numberOfSharedAudioTags) || numberOfSharedAudioTags < 0) {
3366
3378
  throw new TypeError(`'numberOfSharedAudioTags' must be an integer but got '${numberOfSharedAudioTags}' instead`);
3367
3379
  }
@@ -3421,6 +3433,7 @@ var PlayerFn = ({
3421
3433
  logLevel,
3422
3434
  audioLatencyHint,
3423
3435
  volumePersistenceKey,
3436
+ initialVolume,
3424
3437
  inputProps: actualInputProps,
3425
3438
  audioEnabled: true,
3426
3439
  children: /* @__PURE__ */ jsx14(Internals16.SetTimelineContext.Provider, {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/player"
4
4
  },
5
5
  "name": "@remotion/player",
6
- "version": "4.0.452",
6
+ "version": "4.0.453",
7
7
  "description": "React component for embedding a Remotion preview into your app",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "license": "SEE LICENSE IN LICENSE.md",
38
38
  "dependencies": {
39
- "remotion": "4.0.452"
39
+ "remotion": "4.0.453"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=16.8.0",
@@ -50,7 +50,7 @@
50
50
  "react-dom": "19.2.3",
51
51
  "webpack": "5.105.0",
52
52
  "zod": "4.3.6",
53
- "@remotion/eslint-config-internal": "4.0.452",
53
+ "@remotion/eslint-config-internal": "4.0.453",
54
54
  "eslint": "9.19.0",
55
55
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
56
56
  },
@@ -1,2 +0,0 @@
1
- export declare const persistVolume: (volume: number, logLevel: "error" | "info" | "trace" | "verbose" | "warn", volumePersistenceKey: string | null) => void;
2
- export declare const getPreferredVolume: (volumePersistenceKey: string | null) => number;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPreferredVolume = exports.persistVolume = void 0;
4
- const remotion_1 = require("remotion");
5
- const DEFAULT_VOLUME_PERSISTANCE_KEY = 'remotion.volumePreference';
6
- const persistVolume = (volume, logLevel, volumePersistenceKey) => {
7
- if (typeof window === 'undefined') {
8
- return;
9
- }
10
- try {
11
- window.localStorage.setItem(volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : DEFAULT_VOLUME_PERSISTANCE_KEY, String(volume));
12
- }
13
- catch (e) {
14
- // User can disallow localStorage access
15
- // https://github.com/remotion-dev/remotion/issues/3540
16
- remotion_1.Internals.Log.error({ logLevel, tag: null }, 'Could not persist volume', e);
17
- }
18
- };
19
- exports.persistVolume = persistVolume;
20
- const getPreferredVolume = (volumePersistenceKey) => {
21
- if (typeof window === 'undefined') {
22
- return 1;
23
- }
24
- try {
25
- const val = window.localStorage.getItem(volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : DEFAULT_VOLUME_PERSISTANCE_KEY);
26
- return val ? Number(val) : 1;
27
- }
28
- catch (_a) {
29
- // User can disallow localStorage access
30
- // https://github.com/remotion-dev/remotion/issues/3540
31
- return 1;
32
- }
33
- };
34
- exports.getPreferredVolume = getPreferredVolume;