@remotion/player 4.0.537 → 4.0.538

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 (37) hide show
  1. package/dist/cjs/BufferingIndicator.js +3 -5
  2. package/dist/cjs/DefaultPlayPauseButton.js +3 -3
  3. package/dist/cjs/EmitterProvider.js +1 -1
  4. package/dist/cjs/MediaVolumeSlider.js +2 -2
  5. package/dist/cjs/PlaybackrateControl.js +5 -7
  6. package/dist/cjs/Player.d.ts +6 -1
  7. package/dist/cjs/Player.js +6 -4
  8. package/dist/cjs/PlayerControls.js +3 -11
  9. package/dist/cjs/PlayerSeekBar.js +1 -5
  10. package/dist/cjs/PlayerTimeLabel.js +1 -1
  11. package/dist/cjs/PlayerUI.d.ts +3 -3
  12. package/dist/cjs/PlayerUI.js +4 -7
  13. package/dist/cjs/SharedPlayerContext.d.ts +1 -0
  14. package/dist/cjs/SharedPlayerContext.js +2 -2
  15. package/dist/cjs/Thumbnail.d.ts +1 -1
  16. package/dist/cjs/Thumbnail.js +1 -1
  17. package/dist/cjs/ThumbnailUI.d.ts +1 -1
  18. package/dist/cjs/ThumbnailUI.js +3 -3
  19. package/dist/cjs/calculate-scale.d.ts +11 -11
  20. package/dist/cjs/error-boundary.js +5 -2
  21. package/dist/cjs/event-emitter.js +88 -84
  22. package/dist/cjs/icons.js +9 -13
  23. package/dist/cjs/index.d.ts +14 -32
  24. package/dist/cjs/index.js +2 -2
  25. package/dist/cjs/license-blacklist.js +1 -1
  26. package/dist/cjs/player-css-classname.d.ts +1 -1
  27. package/dist/cjs/render-volume-slider.js +3 -5
  28. package/dist/cjs/set-global-time-anchor.d.ts +2 -1
  29. package/dist/cjs/use-hover-state.d.ts +1 -1
  30. package/dist/cjs/use-playback.d.ts +2 -1
  31. package/dist/cjs/use-playback.js +48 -38
  32. package/dist/cjs/use-player-methods.js +9 -8
  33. package/dist/cjs/use-remotion-license-acknowledge.d.ts +2 -1
  34. package/dist/cjs/utils/calculate-player-size.d.ts +4 -3
  35. package/dist/cjs/volume-persistence.d.ts +2 -1
  36. package/dist/esm/index.mjs +70 -50
  37. package/package.json +5 -5
@@ -1 +1,2 @@
1
- export declare const acknowledgeRemotionLicenseMessage: (acknowledge: boolean, logLevel: "error" | "info" | "trace" | "verbose" | "warn") => void;
1
+ import { type LogLevel } from 'remotion';
2
+ export declare const acknowledgeRemotionLicenseMessage: (acknowledge: boolean, logLevel: LogLevel) => void;
@@ -1,8 +1,9 @@
1
+ import type { StandardLonghandProperties } from 'csstype';
1
2
  import type { Size } from './use-element-size.js';
2
3
  export declare const calculatePlayerSize: ({ currentSize, width, height, compositionWidth, compositionHeight, }: {
3
4
  currentSize: Size | null;
4
- width: import("csstype").Property.Width<0 | (string & {})> | undefined;
5
- height: import("csstype").Property.Height<0 | (string & {})> | undefined;
5
+ width: StandardLonghandProperties['width'] | undefined;
6
+ height: StandardLonghandProperties['height'] | undefined;
6
7
  compositionWidth: number;
7
8
  compositionHeight: number;
8
- }) => import("react").CSSProperties;
9
+ }) => React.CSSProperties;
@@ -1,2 +1,3 @@
1
- export declare const persistVolume: (volume: number, logLevel: "error" | "info" | "trace" | "verbose" | "warn", volumePersistenceKey: string | null) => void;
1
+ import { type LogLevel } from 'remotion';
2
+ export declare const persistVolume: (volume: number, logLevel: LogLevel, volumePersistenceKey: string | null) => void;
2
3
  export declare const getPreferredVolume: (volumePersistenceKey: string | null) => number;
@@ -577,6 +577,8 @@ var usePlayerMethods = () => {
577
577
  const audioTagsContext = useContext2(Internals3.SharedAudioTagsContext);
578
578
  const environment = useRemotionEnvironment();
579
579
  const video = Internals3.useVideo();
580
+ const videoId = video?.id ?? null;
581
+ const videoDurationInFrames = video?.durationInFrames ?? null;
580
582
  const config = Internals3.useUnsafeVideoConfig();
581
583
  const emitter = useContext2(PlayerEventEmitterContext);
582
584
  const playStart = useRef(0);
@@ -586,12 +588,12 @@ var usePlayerMethods = () => {
586
588
  throw new TypeError("Expected Player event emitter context");
587
589
  }
588
590
  const getCurrentFrame = useCallback(() => {
589
- if (!video) {
591
+ if (videoId === null || videoDurationInFrames === null) {
590
592
  return fallbackFrame.current ?? (typeof window === "undefined" ? 0 : window.remotion_initialFrame ?? 0);
591
593
  }
592
- const unclamped = frameRef.current[video.id] ?? (environment.isPlayer ? 0 : Internals3.Timeline.getFrameForComposition(video.id));
593
- return Internals3.Timeline.clampFrameToCompositionRange(unclamped, video.durationInFrames);
594
- }, [environment.isPlayer, frameRef, video]);
594
+ const unclamped = frameRef.current[videoId] ?? (environment.isPlayer ? 0 : Internals3.Timeline.getFrameForComposition(videoId));
595
+ return Internals3.Timeline.clampFrameToCompositionRange(unclamped, videoDurationInFrames);
596
+ }, [environment.isPlayer, frameRef, videoId, videoDurationInFrames]);
595
597
  const seek = useCallback((newFrame) => {
596
598
  const frameToSeekTo = config ? Internals3.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames) : Math.max(0, newFrame);
597
599
  fallbackFrame.current = frameToSeekTo;
@@ -667,7 +669,6 @@ var usePlayerMethods = () => {
667
669
  }
668
670
  }
669
671
  }, [config, emitter, frameRef, readIsPlaying, setPlaying, seekFrame]);
670
- const videoId = video?.id;
671
672
  const lastFrame = (config?.durationInFrames ?? 1) - 1;
672
673
  const frameBack = useCallback((frames) => {
673
674
  if (!videoId) {
@@ -954,6 +955,9 @@ var usePlayback = ({
954
955
  muted
955
956
  }) => {
956
957
  const config = Internals6.useUnsafeVideoConfig();
958
+ const fps = config?.fps ?? null;
959
+ const durationInFrames = config?.durationInFrames ?? null;
960
+ const compositionId = config?.id ?? null;
957
961
  const frame = Internals6.Timeline.useTimelinePosition();
958
962
  const playing = Internals6.usePlaying();
959
963
  const { pause, emitter, isPlaying } = usePlayerMethods();
@@ -965,6 +969,8 @@ var usePlayback = ({
965
969
  const isBackgroundedRef = useIsBackgrounded();
966
970
  const lastTimeUpdateTimestamp = useRef4(0);
967
971
  const playbackClockRef = useRef4(null);
972
+ const previousMutedRef = useRef4(muted);
973
+ const anchoredAudioContextRef = useRef4(null);
968
974
  useBrowserMediaSession({
969
975
  browserMediaControlsBehavior,
970
976
  playbackRate,
@@ -977,7 +983,7 @@ var usePlayback = ({
977
983
  if (!sharedAudioContext.audioContext) {
978
984
  return;
979
985
  }
980
- if (!config) {
986
+ if (fps === null) {
981
987
  return;
982
988
  }
983
989
  if (muted) {
@@ -986,7 +992,7 @@ var usePlayback = ({
986
992
  const changed = setGlobalTimeAnchor({
987
993
  audioContext: sharedAudioContext.audioContext,
988
994
  audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
989
- absoluteTimeInSeconds: frame / config.fps,
995
+ absoluteTimeInSeconds: frame / fps,
990
996
  globalPlaybackRate: playbackRate,
991
997
  logLevel,
992
998
  force: false
@@ -994,13 +1000,13 @@ var usePlayback = ({
994
1000
  if (changed) {
995
1001
  sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
996
1002
  }
997
- }, [config, frame, logLevel, playbackRate, sharedAudioContext, muted]);
1003
+ }, [fps, frame, logLevel, playbackRate, sharedAudioContext, muted]);
998
1004
  useLayoutEffect2(() => {
999
1005
  const audioContext = sharedAudioContext?.audioContext;
1000
1006
  if (!audioContext) {
1001
1007
  return;
1002
1008
  }
1003
- if (!config) {
1009
+ if (fps === null) {
1004
1010
  return;
1005
1011
  }
1006
1012
  if (muted) {
@@ -1012,7 +1018,7 @@ var usePlayback = ({
1012
1018
  const changed = setGlobalTimeAnchor({
1013
1019
  audioContext,
1014
1020
  audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
1015
- absoluteTimeInSeconds: getCurrentFrame() / config.fps,
1021
+ absoluteTimeInSeconds: getCurrentFrame() / fps,
1016
1022
  globalPlaybackRate: playbackRate,
1017
1023
  logLevel,
1018
1024
  force: true
@@ -1026,16 +1032,12 @@ var usePlayback = ({
1026
1032
  return () => {
1027
1033
  audioContext?.removeEventListener("statechange", callback);
1028
1034
  };
1029
- }, [
1030
- config,
1031
- getCurrentFrame,
1032
- logLevel,
1033
- muted,
1034
- playbackRate,
1035
- sharedAudioContext
1036
- ]);
1035
+ }, [fps, getCurrentFrame, logLevel, muted, playbackRate, sharedAudioContext]);
1037
1036
  useEffect5(() => {
1038
- if (!config) {
1037
+ const wasMuted = previousMutedRef.current;
1038
+ previousMutedRef.current = muted;
1039
+ if (fps === null || durationInFrames === null || compositionId === null) {
1040
+ playbackClockRef.current = null;
1039
1041
  return;
1040
1042
  }
1041
1043
  if (!playing) {
@@ -1044,23 +1046,29 @@ var usePlayback = ({
1044
1046
  return;
1045
1047
  }
1046
1048
  const previousClock = playbackClockRef.current;
1047
- const clock = previousClock !== null && previousClock.fps === config.fps && previousClock.playbackRate === playbackRate ? previousClock : {
1049
+ const shouldRestartClock = previousClock === null || previousClock.compositionId !== compositionId || previousClock.fps !== fps || previousClock.playbackRate !== playbackRate;
1050
+ const clock = shouldRestartClock ? {
1051
+ compositionId,
1048
1052
  startedTime: performance.now(),
1049
1053
  framesAdvanced: 0,
1050
- fps: config.fps,
1054
+ fps,
1051
1055
  playbackRate
1052
- };
1056
+ } : previousClock;
1053
1057
  playbackClockRef.current = clock;
1054
1058
  if (sharedAudioContext?._experimentalKeepAudioContextAlive && sharedAudioContext.audioContext && !muted) {
1059
+ const didUnmute = wasMuted && !muted;
1060
+ const didReplaceAudioContext = anchoredAudioContextRef.current !== sharedAudioContext.audioContext;
1061
+ const shouldRescheduleAudio = shouldRestartClock || didUnmute || didReplaceAudioContext;
1055
1062
  const changed = setGlobalTimeAnchor({
1056
1063
  audioContext: sharedAudioContext.audioContext,
1057
1064
  audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
1058
- absoluteTimeInSeconds: getCurrentFrame() / config.fps,
1065
+ absoluteTimeInSeconds: getCurrentFrame() / fps,
1059
1066
  globalPlaybackRate: playbackRate,
1060
1067
  logLevel,
1061
- force: true
1068
+ force: shouldRescheduleAudio
1062
1069
  });
1063
- if (changed) {
1070
+ anchoredAudioContextRef.current = sharedAudioContext.audioContext;
1071
+ if (changed || shouldRescheduleAudio) {
1064
1072
  sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
1065
1073
  }
1066
1074
  }
@@ -1094,7 +1102,7 @@ var usePlayback = ({
1094
1102
  sharedAudioContext?.resume?.();
1095
1103
  }
1096
1104
  const time = performance.now() - clock.startedTime;
1097
- const actualLastFrame = outFrame ?? config.durationInFrames - 1;
1105
+ const actualLastFrame = outFrame ?? durationInFrames - 1;
1098
1106
  const actualFirstFrame = inFrame ?? 0;
1099
1107
  const seekRevision = seek?.revision.current ?? null;
1100
1108
  if (seekRevision !== lastSeekRevision) {
@@ -1106,7 +1114,7 @@ var usePlayback = ({
1106
1114
  time,
1107
1115
  currentFrame,
1108
1116
  playbackSpeed: playbackRate,
1109
- fps: config.fps,
1117
+ fps,
1110
1118
  actualFirstFrame,
1111
1119
  actualLastFrame,
1112
1120
  framesAdvanced: clock.framesAdvanced,
@@ -1116,7 +1124,7 @@ var usePlayback = ({
1116
1124
  const frameToDisplay = hasEnded && !moveToBeginningWhenEnded ? playbackRate > 0 ? actualLastFrame : actualFirstFrame : nextFrame;
1117
1125
  if (frameToDisplay !== currentFrame && !isBuffering()) {
1118
1126
  playbackFrame = frameToDisplay;
1119
- setFrameFromPlayback((c) => ({ ...c, [config.id]: frameToDisplay }));
1127
+ setFrameFromPlayback((c) => ({ ...c, [compositionId]: frameToDisplay }));
1120
1128
  }
1121
1129
  if (hasEnded) {
1122
1130
  stop();
@@ -1168,7 +1176,7 @@ var usePlayback = ({
1168
1176
  if (isBackgroundedRef.current) {
1169
1177
  reqAnimFrameCall = {
1170
1178
  type: "timeout",
1171
- id: setTimeout(callback, 1000 / config.fps)
1179
+ id: setTimeout(callback, 1000 / fps)
1172
1180
  };
1173
1181
  return;
1174
1182
  }
@@ -1188,7 +1196,9 @@ var usePlayback = ({
1188
1196
  stop();
1189
1197
  };
1190
1198
  }, [
1191
- config,
1199
+ compositionId,
1200
+ durationInFrames,
1201
+ fps,
1192
1202
  loop,
1193
1203
  pause,
1194
1204
  playing,
@@ -3130,6 +3140,7 @@ var SharedPlayerContexts = ({
3130
3140
  children,
3131
3141
  timelineContext,
3132
3142
  playbackRateContext,
3143
+ preservePitch,
3133
3144
  fps,
3134
3145
  compositionHeight,
3135
3146
  compositionWidth,
@@ -3238,26 +3249,29 @@ var SharedPlayerContexts = ({
3238
3249
  value: timelineContext,
3239
3250
  children: /* @__PURE__ */ jsx13(Internals13.PlaybackRateContext.Provider, {
3240
3251
  value: playbackRateContext,
3241
- children: /* @__PURE__ */ jsx13(Internals13.TimelineContext.Provider, {
3242
- value: timelineContext,
3243
- children: /* @__PURE__ */ jsx13(Internals13.CompositionManager.Provider, {
3244
- value: compositionManagerContext,
3245
- children: /* @__PURE__ */ jsx13(Internals13.VideoProvider, {
3246
- children: /* @__PURE__ */ jsx13(Internals13.PrefetchProvider, {
3247
- children: /* @__PURE__ */ jsx13(Internals13.DurationsContextProvider, {
3248
- children: /* @__PURE__ */ jsx13(Internals13.MediaVolumeContext.Provider, {
3249
- value: mediaVolumeContextValue,
3250
- children: /* @__PURE__ */ jsx13(Internals13.SetMediaVolumeContext.Provider, {
3251
- value: setMediaVolumeContextValue,
3252
- children: /* @__PURE__ */ jsx13(Internals13.BufferingProvider, {
3253
- children: /* @__PURE__ */ jsx13(Internals13.SharedAudioContextProvider, {
3254
- audioLatencyHint,
3255
- audioEnabled: shouldCreateAudioContext,
3256
- previewSampleRate: sampleRate,
3257
- _experimentalKeepAudioContextAlive,
3258
- children: /* @__PURE__ */ jsx13(Internals13.SharedAudioTagsContextProvider, {
3259
- numberOfAudioTags: numberOfSharedAudioTags,
3260
- children
3252
+ children: /* @__PURE__ */ jsx13(Internals13.PlaybackPitchContext.Provider, {
3253
+ value: preservePitch,
3254
+ children: /* @__PURE__ */ jsx13(Internals13.TimelineContext.Provider, {
3255
+ value: timelineContext,
3256
+ children: /* @__PURE__ */ jsx13(Internals13.CompositionManager.Provider, {
3257
+ value: compositionManagerContext,
3258
+ children: /* @__PURE__ */ jsx13(Internals13.VideoProvider, {
3259
+ children: /* @__PURE__ */ jsx13(Internals13.PrefetchProvider, {
3260
+ children: /* @__PURE__ */ jsx13(Internals13.DurationsContextProvider, {
3261
+ children: /* @__PURE__ */ jsx13(Internals13.MediaVolumeContext.Provider, {
3262
+ value: mediaVolumeContextValue,
3263
+ children: /* @__PURE__ */ jsx13(Internals13.SetMediaVolumeContext.Provider, {
3264
+ value: setMediaVolumeContextValue,
3265
+ children: /* @__PURE__ */ jsx13(Internals13.BufferingProvider, {
3266
+ children: /* @__PURE__ */ jsx13(Internals13.SharedAudioContextProvider, {
3267
+ audioLatencyHint,
3268
+ audioEnabled: shouldCreateAudioContext,
3269
+ previewSampleRate: sampleRate,
3270
+ _experimentalKeepAudioContextAlive,
3271
+ children: /* @__PURE__ */ jsx13(Internals13.SharedAudioTagsContextProvider, {
3272
+ numberOfAudioTags: numberOfSharedAudioTags,
3273
+ children
3274
+ })
3261
3275
  })
3262
3276
  })
3263
3277
  })
@@ -3426,6 +3440,7 @@ var PlayerFn = ({
3426
3440
  numberOfSharedAudioTags = NoReactInternals2.ENABLE_V5_BREAKING_CHANGES ? 0 : 5,
3427
3441
  errorFallback = () => "⚠️",
3428
3442
  playbackRate = 1,
3443
+ preservePitch = false,
3429
3444
  renderLoading,
3430
3445
  className,
3431
3446
  showPosterWhenUnplayed,
@@ -3520,6 +3535,9 @@ var PlayerFn = ({
3520
3535
  if (typeof controls !== "boolean" && typeof controls !== "undefined") {
3521
3536
  throw new TypeError(`'controls' must be a boolean or undefined but got '${typeof controls}' instead`);
3522
3537
  }
3538
+ if (typeof preservePitch !== "boolean") {
3539
+ throw new TypeError(`'preservePitch' must be a boolean but got '${typeof preservePitch}' instead`);
3540
+ }
3523
3541
  if (typeof autoPlay !== "boolean" && typeof autoPlay !== "undefined") {
3524
3542
  throw new TypeError(`'autoPlay' must be a boolean or undefined but got '${typeof autoPlay}' instead`);
3525
3543
  }
@@ -3629,6 +3647,7 @@ var PlayerFn = ({
3629
3647
  children: /* @__PURE__ */ jsx14(SharedPlayerContexts, {
3630
3648
  timelineContext: timelineContextValue,
3631
3649
  playbackRateContext: playbackRateContextValue,
3650
+ preservePitch,
3632
3651
  component,
3633
3652
  compositionHeight,
3634
3653
  compositionWidth,
@@ -3956,6 +3975,7 @@ var ThumbnailFn = ({
3956
3975
  children: /* @__PURE__ */ jsx16(SharedPlayerContexts, {
3957
3976
  timelineContext: timelineState,
3958
3977
  playbackRateContext,
3978
+ preservePitch: false,
3959
3979
  component: Component,
3960
3980
  compositionHeight,
3961
3981
  compositionWidth,
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.537",
6
+ "version": "4.0.538",
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",
@@ -12,7 +12,7 @@
12
12
  "formatting": "oxfmt src --check",
13
13
  "format": "oxfmt src",
14
14
  "lint": "eslint src",
15
- "make": "tsgo -d && bun ensure-correct-version.ts && bun --env-file=../.env.bundle bundle.ts",
15
+ "make": "tsc -d && bun ensure-correct-version.ts && bun --env-file=../.env.bundle bundle.ts",
16
16
  "test": "bun test src",
17
17
  "prerelease": "cp ../../README.md . && cp ../../LICENSE.md ."
18
18
  },
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "license": "SEE LICENSE IN LICENSE.md",
37
37
  "dependencies": {
38
- "remotion": "4.0.537"
38
+ "remotion": "4.0.538"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=16.8.0",
@@ -49,9 +49,9 @@
49
49
  "react-dom": "19.2.3",
50
50
  "webpack": "5.105.0",
51
51
  "zod": "4.5.4",
52
- "@remotion/eslint-config-internal": "4.0.537",
52
+ "@remotion/eslint-config-internal": "4.0.538",
53
53
  "eslint": "9.19.0",
54
- "@typescript/native-preview": "7.0.0-dev.20260217.1"
54
+ "typescript": "7.1.0-beta"
55
55
  },
56
56
  "keywords": [
57
57
  "remotion",