@remotion/player 4.0.304 → 4.0.306

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.
@@ -60,6 +60,7 @@ export type PlayerProps<Schema extends AnyZodObject, Props extends Record<string
60
60
  readonly noSuspense?: boolean;
61
61
  readonly acknowledgeRemotionLicense?: boolean;
62
62
  readonly audioLatencyHint?: AudioContextLatencyCategory;
63
+ readonly volumePersistenceKey?: string;
63
64
  } & CompProps<Props> & PropsIfHasProps<Schema, Props>;
64
65
  export type PlayerPropsWithoutZod<Props extends Record<string, unknown>> = PlayerProps<AnyZodObject, Props>;
65
66
  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, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'interactive', ...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, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'interactive', volumePersistenceKey, ...componentProps }, ref) => {
27
27
  if (typeof window !== 'undefined') {
28
28
  // eslint-disable-next-line react-hooks/rules-of-hooks
29
29
  (0, react_1.useLayoutEffect)(() => {
@@ -157,7 +157,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
157
157
  mode: 'prevent-media-session',
158
158
  });
159
159
  }, [passedBrowserMediaControlsBehavior]);
160
- return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: (0, 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'
160
+ return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, volumePersistenceKey: volumePersistenceKey, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: (0, 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'
161
161
  ? clickToPlay
162
162
  : 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, 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) }) }) }) }) }));
163
163
  };
@@ -14,4 +14,5 @@ export declare const SharedPlayerContexts: React.FC<{
14
14
  readonly initiallyMuted: boolean;
15
15
  readonly logLevel: LogLevel;
16
16
  readonly audioLatencyHint: AudioContextLatencyCategory;
17
+ readonly volumePersistenceKey?: string;
17
18
  }>;
@@ -6,7 +6,7 @@ const react_1 = require("react");
6
6
  const remotion_1 = require("remotion");
7
7
  const volume_persistance_js_1 = require("./volume-persistance.js");
8
8
  exports.PLAYER_COMP_ID = 'player-comp';
9
- const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, initiallyMuted, logLevel, audioLatencyHint, }) => {
9
+ const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, initiallyMuted, logLevel, audioLatencyHint, volumePersistenceKey, }) => {
10
10
  const compositionManagerContext = (0, react_1.useMemo)(() => {
11
11
  const context = {
12
12
  compositions: [
@@ -31,7 +31,7 @@ const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeigh
31
31
  return context;
32
32
  }, [component, durationInFrames, compositionHeight, compositionWidth, fps]);
33
33
  const [mediaMuted, setMediaMuted] = (0, react_1.useState)(() => initiallyMuted);
34
- const [mediaVolume, setMediaVolume] = (0, react_1.useState)(() => (0, volume_persistance_js_1.getPreferredVolume)());
34
+ const [mediaVolume, setMediaVolume] = (0, react_1.useState)(() => (0, volume_persistance_js_1.getPreferredVolume)(volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : null));
35
35
  const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
36
36
  return {
37
37
  mediaMuted,
@@ -40,8 +40,8 @@ const SharedPlayerContexts = ({ children, timelineContext, fps, compositionHeigh
40
40
  }, [mediaMuted, mediaVolume]);
41
41
  const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
42
42
  setMediaVolume(vol);
43
- (0, volume_persistance_js_1.persistVolume)(vol, logLevel);
44
- }, [logLevel]);
43
+ (0, volume_persistance_js_1.persistVolume)(vol, logLevel, volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : null);
44
+ }, [logLevel, volumePersistenceKey]);
45
45
  const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
46
46
  return {
47
47
  setMediaMuted,
@@ -85,6 +85,10 @@ const test_utils_js_1 = require("./test-utils.js");
85
85
  (0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true }));
86
86
  (0, bun_test_1.expect)(true).toBe(true);
87
87
  });
88
+ (0, bun_test_1.test)('volumePersistenceKey of string should be okay', () => {
89
+ (0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true, volumePersistenceKey: "custom-key" }));
90
+ (0, bun_test_1.expect)(true).toBe(true);
91
+ });
88
92
  (0, bun_test_1.test)('passing in <Composition /> instance should not be possible', () => {
89
93
  (0, bun_test_1.expect)(() => {
90
94
  (0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: remotion_1.Composition, controls: true, showVolumeControls: true, inputProps: {
@@ -1,3 +1,3 @@
1
1
  import { type LogLevel } from 'remotion';
2
- export declare const persistVolume: (volume: number, logLevel: LogLevel) => void;
3
- export declare const getPreferredVolume: () => number;
2
+ export declare const persistVolume: (volume: number, logLevel: LogLevel, volumePersistenceKey: string | null) => void;
3
+ export declare const getPreferredVolume: (volumePersistenceKey: string | null) => number;
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPreferredVolume = exports.persistVolume = void 0;
4
4
  const remotion_1 = require("remotion");
5
- const VOLUME_PERSISTANCE_KEY = 'remotion.volumePreference';
6
- const persistVolume = (volume, logLevel) => {
5
+ const DEFAULT_VOLUME_PERSISTANCE_KEY = 'remotion.volumePreference';
6
+ const persistVolume = (volume, logLevel, volumePersistenceKey) => {
7
7
  if (typeof window === 'undefined') {
8
8
  return;
9
9
  }
10
10
  try {
11
- window.localStorage.setItem(VOLUME_PERSISTANCE_KEY, String(volume));
11
+ window.localStorage.setItem(volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : DEFAULT_VOLUME_PERSISTANCE_KEY, String(volume));
12
12
  }
13
13
  catch (e) {
14
14
  // User can disallow localStorage access
@@ -17,12 +17,12 @@ const persistVolume = (volume, logLevel) => {
17
17
  }
18
18
  };
19
19
  exports.persistVolume = persistVolume;
20
- const getPreferredVolume = () => {
20
+ const getPreferredVolume = (volumePersistenceKey) => {
21
21
  if (typeof window === 'undefined') {
22
22
  return 1;
23
23
  }
24
24
  try {
25
- const val = window.localStorage.getItem(VOLUME_PERSISTANCE_KEY);
25
+ const val = window.localStorage.getItem(volumePersistenceKey !== null && volumePersistenceKey !== void 0 ? volumePersistenceKey : DEFAULT_VOLUME_PERSISTANCE_KEY);
26
26
  return val ? Number(val) : 1;
27
27
  }
28
28
  catch (_a) {
@@ -2832,23 +2832,23 @@ import { Internals as Internals13 } from "remotion";
2832
2832
 
2833
2833
  // src/volume-persistance.ts
2834
2834
  import { Internals as Internals12 } from "remotion";
2835
- var VOLUME_PERSISTANCE_KEY = "remotion.volumePreference";
2836
- var persistVolume = (volume, logLevel) => {
2835
+ var DEFAULT_VOLUME_PERSISTANCE_KEY = "remotion.volumePreference";
2836
+ var persistVolume = (volume, logLevel, volumePersistenceKey) => {
2837
2837
  if (typeof window === "undefined") {
2838
2838
  return;
2839
2839
  }
2840
2840
  try {
2841
- window.localStorage.setItem(VOLUME_PERSISTANCE_KEY, String(volume));
2841
+ window.localStorage.setItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTANCE_KEY, String(volume));
2842
2842
  } catch (e) {
2843
2843
  Internals12.Log.error(logLevel, "Could not persist volume", e);
2844
2844
  }
2845
2845
  };
2846
- var getPreferredVolume = () => {
2846
+ var getPreferredVolume = (volumePersistenceKey) => {
2847
2847
  if (typeof window === "undefined") {
2848
2848
  return 1;
2849
2849
  }
2850
2850
  try {
2851
- const val = window.localStorage.getItem(VOLUME_PERSISTANCE_KEY);
2851
+ const val = window.localStorage.getItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTANCE_KEY);
2852
2852
  return val ? Number(val) : 1;
2853
2853
  } catch {
2854
2854
  return 1;
@@ -2869,7 +2869,8 @@ var SharedPlayerContexts = ({
2869
2869
  numberOfSharedAudioTags,
2870
2870
  initiallyMuted,
2871
2871
  logLevel,
2872
- audioLatencyHint
2872
+ audioLatencyHint,
2873
+ volumePersistenceKey
2873
2874
  }) => {
2874
2875
  const compositionManagerContext = useMemo13(() => {
2875
2876
  const context = {
@@ -2895,7 +2896,7 @@ var SharedPlayerContexts = ({
2895
2896
  return context;
2896
2897
  }, [component, durationInFrames, compositionHeight, compositionWidth, fps]);
2897
2898
  const [mediaMuted, setMediaMuted] = useState12(() => initiallyMuted);
2898
- const [mediaVolume, setMediaVolume] = useState12(() => getPreferredVolume());
2899
+ const [mediaVolume, setMediaVolume] = useState12(() => getPreferredVolume(volumePersistenceKey ?? null));
2899
2900
  const mediaVolumeContextValue = useMemo13(() => {
2900
2901
  return {
2901
2902
  mediaMuted,
@@ -2904,8 +2905,8 @@ var SharedPlayerContexts = ({
2904
2905
  }, [mediaMuted, mediaVolume]);
2905
2906
  const setMediaVolumeAndPersist = useCallback12((vol) => {
2906
2907
  setMediaVolume(vol);
2907
- persistVolume(vol, logLevel);
2908
- }, [logLevel]);
2908
+ persistVolume(vol, logLevel, volumePersistenceKey ?? null);
2909
+ }, [logLevel, volumePersistenceKey]);
2909
2910
  const setMediaVolumeContextValue = useMemo13(() => {
2910
2911
  return {
2911
2912
  setMediaMuted,
@@ -3119,6 +3120,7 @@ var PlayerFn = ({
3119
3120
  noSuspense,
3120
3121
  acknowledgeRemotionLicense,
3121
3122
  audioLatencyHint = "interactive",
3123
+ volumePersistenceKey,
3122
3124
  ...componentProps
3123
3125
  }, ref) => {
3124
3126
  if (typeof window !== "undefined") {
@@ -3253,6 +3255,7 @@ var PlayerFn = ({
3253
3255
  initiallyMuted,
3254
3256
  logLevel,
3255
3257
  audioLatencyHint,
3258
+ volumePersistenceKey,
3256
3259
  children: /* @__PURE__ */ jsx14(Internals15.Timeline.SetTimelineContext.Provider, {
3257
3260
  value: setTimelineContextValue,
3258
3261
  children: /* @__PURE__ */ jsx14(PlayerEmitterProvider, {
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.304",
6
+ "version": "4.0.306",
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",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "license": "SEE LICENSE IN LICENSE.md",
30
30
  "dependencies": {
31
- "remotion": "4.0.304"
31
+ "remotion": "4.0.306"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=16.8.0",
@@ -43,7 +43,7 @@
43
43
  "webpack": "5.96.1",
44
44
  "zod": "3.22.3",
45
45
  "eslint": "9.19.0",
46
- "@remotion/eslint-config-internal": "4.0.304"
46
+ "@remotion/eslint-config-internal": "4.0.306"
47
47
  },
48
48
  "keywords": [
49
49
  "remotion",