@remotion/player 4.0.459 → 4.0.461

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.
@@ -39,7 +39,7 @@ export declare const PlayerInternals: {
39
39
  inFrame: number | null;
40
40
  outFrame: number | null;
41
41
  browserMediaControlsBehavior: import("./browser-mediasession.js").BrowserMediaControlsBehavior;
42
- getCurrentFrame: import("./use-frame-imperative.js").GetCurrentFrame;
42
+ getCurrentFrame: () => number;
43
43
  muted: boolean;
44
44
  }) => void;
45
45
  useElementSize: (ref: import("react").RefObject<HTMLElement | null>, options: {
@@ -67,5 +67,4 @@ export declare const PlayerInternals: {
67
67
  BufferingIndicator: import("react").FC<{
68
68
  readonly type: "player" | "studio";
69
69
  }>;
70
- useFrameImperative: () => import("./use-frame-imperative.js").GetCurrentFrame;
71
70
  };
package/dist/cjs/index.js CHANGED
@@ -7,7 +7,6 @@ const calculate_scale_js_1 = require("./calculate-scale.js");
7
7
  const emitter_context_js_1 = require("./emitter-context.js");
8
8
  const EmitterProvider_js_1 = require("./EmitterProvider.js");
9
9
  const event_emitter_js_1 = require("./event-emitter.js");
10
- const use_frame_imperative_js_1 = require("./use-frame-imperative.js");
11
10
  const use_hover_state_js_1 = require("./use-hover-state.js");
12
11
  const use_playback_js_1 = require("./use-playback.js");
13
12
  const use_player_js_1 = require("./use-player.js");
@@ -27,5 +26,4 @@ exports.PlayerInternals = {
27
26
  updateAllElementsSizes: use_element_size_js_1.updateAllElementsSizes,
28
27
  PlayerEmitterProvider: EmitterProvider_js_1.PlayerEmitterProvider,
29
28
  BufferingIndicator: BufferingIndicator_js_1.BufferingIndicator,
30
- useFrameImperative: use_frame_imperative_js_1.useFrameImperative,
31
29
  };
@@ -1,5 +1,5 @@
1
1
  export declare const ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
2
- export declare const setGlobalTimeAnchor: ({ audioContext, audioSyncAnchor, absoluteTimeInSeconds, globalPlaybackRate, logLevel, }: {
2
+ export declare const setGlobalTimeAnchor: ({ audioContext, audioSyncAnchor, absoluteTimeInSeconds, globalPlaybackRate, logLevel, force, }: {
3
3
  audioContext: AudioContext;
4
4
  audioSyncAnchor: {
5
5
  value: number;
@@ -7,4 +7,5 @@ export declare const setGlobalTimeAnchor: ({ audioContext, audioSyncAnchor, abso
7
7
  absoluteTimeInSeconds: number;
8
8
  globalPlaybackRate: number;
9
9
  logLevel: "error" | "info" | "trace" | "verbose" | "warn";
10
+ force: boolean;
10
11
  }) => boolean;
@@ -3,17 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setGlobalTimeAnchor = exports.ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = void 0;
4
4
  const remotion_1 = require("remotion");
5
5
  exports.ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
6
- const setGlobalTimeAnchor = ({ audioContext, audioSyncAnchor, absoluteTimeInSeconds, globalPlaybackRate, logLevel, }) => {
6
+ const setGlobalTimeAnchor = ({ audioContext, audioSyncAnchor, absoluteTimeInSeconds, globalPlaybackRate, logLevel, force, }) => {
7
7
  const newAnchor = audioContext.currentTime - absoluteTimeInSeconds / globalPlaybackRate;
8
8
  const shift = (newAnchor - audioSyncAnchor.value) * globalPlaybackRate;
9
9
  const { outputLatency } = audioContext;
10
10
  const safeOutputLatency = outputLatency === 0 ? 0.3 : outputLatency;
11
11
  const latency = audioContext.baseLatency + safeOutputLatency;
12
12
  // Skip small shifts to avoid audio glitches from frame-quantized re-anchoring
13
- if (Math.abs(shift) < exports.ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT + latency) {
13
+ if (Math.abs(shift) < exports.ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT + latency && !force) {
14
14
  return false;
15
15
  }
16
- remotion_1.Internals.Log.verbose({ logLevel, tag: 'audio-scheduling' }, 'Anchor changed from %s to %s with shift %s', audioSyncAnchor.value, newAnchor, shift);
16
+ remotion_1.Internals.Log.verbose({ logLevel, tag: 'audio-scheduling' }, 'Anchor ' +
17
+ (force ? 'forcibly ' : '') +
18
+ 'changed from %s to %s with shift %s', audioSyncAnchor.value, newAnchor, shift);
17
19
  audioSyncAnchor.value = newAnchor;
18
20
  return true;
19
21
  };
@@ -1,5 +1,4 @@
1
1
  import type { BrowserMediaControlsBehavior } from './browser-mediasession.js';
2
- import type { GetCurrentFrame } from './use-frame-imperative.js';
3
2
  export declare const usePlayback: ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, browserMediaControlsBehavior, getCurrentFrame, muted, }: {
4
3
  loop: boolean;
5
4
  playbackRate: number;
@@ -7,6 +6,6 @@ export declare const usePlayback: ({ loop, playbackRate, moveToBeginningWhenEnde
7
6
  inFrame: number | null;
8
7
  outFrame: number | null;
9
8
  browserMediaControlsBehavior: BrowserMediaControlsBehavior;
10
- getCurrentFrame: GetCurrentFrame;
9
+ getCurrentFrame: () => number;
11
10
  muted: boolean;
12
11
  }) => void;
@@ -31,6 +31,8 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
31
31
  playbackRate,
32
32
  videoConfig: config,
33
33
  });
34
+ // Update time anchor when seeking:
35
+ // If the user clicked on a different time in the timeline, we need to re-sync the anchor
34
36
  (0, react_1.useLayoutEffect)(() => {
35
37
  if (!sharedAudioContext) {
36
38
  return;
@@ -41,17 +43,58 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
41
43
  if (!config) {
42
44
  return;
43
45
  }
46
+ if (muted) {
47
+ return;
48
+ }
44
49
  const changed = (0, set_global_time_anchor_js_1.setGlobalTimeAnchor)({
45
50
  audioContext: sharedAudioContext.audioContext,
46
51
  audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
47
52
  absoluteTimeInSeconds: frame / config.fps,
48
53
  globalPlaybackRate: playbackRate,
49
54
  logLevel,
55
+ force: false,
50
56
  });
51
57
  if (changed) {
52
58
  sharedAudioContext.audioSyncAnchorEmitter.dispatch('changed');
53
59
  }
54
- }, [config, frame, logLevel, playbackRate, sharedAudioContext]);
60
+ }, [config, frame, logLevel, playbackRate, sharedAudioContext, muted]);
61
+ // When the audio context is suspended, we use the opportunity to
62
+ // re-anchor the time to be exact.
63
+ (0, react_1.useLayoutEffect)(() => {
64
+ const audioContext = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.audioContext;
65
+ if (!audioContext) {
66
+ return;
67
+ }
68
+ if (!config) {
69
+ return;
70
+ }
71
+ if (muted) {
72
+ return;
73
+ }
74
+ const callback = () => {
75
+ if (audioContext.state !== 'running') {
76
+ (0, set_global_time_anchor_js_1.setGlobalTimeAnchor)({
77
+ audioContext,
78
+ audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
79
+ absoluteTimeInSeconds: getCurrentFrame() / config.fps,
80
+ globalPlaybackRate: playbackRate,
81
+ logLevel,
82
+ force: true,
83
+ });
84
+ }
85
+ };
86
+ audioContext === null || audioContext === void 0 ? void 0 : audioContext.addEventListener('statechange', callback);
87
+ return () => {
88
+ audioContext === null || audioContext === void 0 ? void 0 : audioContext.removeEventListener('statechange', callback);
89
+ };
90
+ }, [
91
+ config,
92
+ getCurrentFrame,
93
+ logLevel,
94
+ muted,
95
+ playbackRate,
96
+ sharedAudioContext,
97
+ ]);
55
98
  (0, react_2.useEffect)(() => {
56
99
  var _a;
57
100
  if (!config) {
@@ -88,7 +131,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
88
131
  (_a = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _a === void 0 ? void 0 : _a.call(sharedAudioContext);
89
132
  return;
90
133
  }
91
- if (!muted) {
134
+ if (!muted && !context.buffering.current) {
92
135
  (_b = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.resume) === null || _b === void 0 ? void 0 : _b.call(sharedAudioContext);
93
136
  }
94
137
  const time = performance.now() - startedTime;
@@ -107,7 +150,8 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
107
150
  });
108
151
  framesAdvanced += framesToAdvance;
109
152
  if (nextFrame !== getCurrentFrame() &&
110
- (!hasEnded || moveToBeginningWhenEnded)) {
153
+ (!hasEnded || moveToBeginningWhenEnded) &&
154
+ !context.buffering.current) {
111
155
  setFrame((c) => ({ ...c, [config.id]: nextFrame }));
112
156
  }
113
157
  if (hasEnded) {
@@ -124,31 +168,16 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
124
168
  const getIsResumingAudioContext = (_c = (_a = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.getIsResumingAudioContext) === null || _a === void 0 ? void 0 : _a.call(sharedAudioContext)) !== null && _c !== void 0 ? _c : null;
125
169
  if (getIsResumingAudioContext !== null && !muted) {
126
170
  getIsResumingAudioContext.then(() => {
127
- if (!(sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.audioContext)) {
128
- return;
129
- }
130
- if (!sharedAudioContext.audioSyncAnchor) {
131
- return;
132
- }
133
- // set it here and DON'T propagate an event
134
- // the useLayoutEffect above is supposed to handle a user seek,
135
- // this is a natural wait for the audio playback to start.
136
- // we don't wanna destroy the iterators.
137
- (0, set_global_time_anchor_js_1.setGlobalTimeAnchor)({
138
- audioContext: sharedAudioContext.audioContext,
139
- audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
140
- absoluteTimeInSeconds: getCurrentFrame() / config.fps,
141
- globalPlaybackRate: playbackRate,
142
- logLevel,
143
- });
144
171
  startedTime = performance.now();
145
172
  framesAdvanced = 0;
146
173
  queueNextFrame();
147
174
  });
148
175
  return;
149
176
  }
150
- if (context.buffering.current && !muted) {
151
- (_b = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _b === void 0 ? void 0 : _b.call(sharedAudioContext);
177
+ if (context.buffering.current) {
178
+ if (!muted) {
179
+ (_b = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _b === void 0 ? void 0 : _b.call(sharedAudioContext);
180
+ }
152
181
  const stopListening = context.listenForResume(() => {
153
182
  stopListening.remove();
154
183
  startedTime = performance.now();
@@ -495,19 +495,6 @@ var PlayerEmitterProvider = ({ children, currentPlaybackRate }) => {
495
495
  });
496
496
  };
497
497
 
498
- // src/use-frame-imperative.ts
499
- import { useCallback, useRef } from "react";
500
- import { Internals as Internals4 } from "remotion";
501
- var useFrameImperative = () => {
502
- const frame = Internals4.Timeline.useTimelinePosition();
503
- const frameRef = useRef(frame);
504
- frameRef.current = frame;
505
- const getCurrentFrame = useCallback(() => {
506
- return frameRef.current;
507
- }, []);
508
- return getCurrentFrame;
509
- };
510
-
511
498
  // src/use-hover-state.ts
512
499
  import { useEffect as useEffect2, useState as useState2 } from "react";
513
500
  var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
@@ -553,29 +540,29 @@ var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
553
540
 
554
541
  // src/use-playback.ts
555
542
  import { useLayoutEffect as useLayoutEffect2 } from "react";
556
- import { useContext as useContext4, useEffect as useEffect5, useRef as useRef5 } from "react";
557
- import { Internals as Internals7 } from "remotion";
543
+ import { useContext as useContext4, useEffect as useEffect5, useRef as useRef4 } from "react";
544
+ import { Internals as Internals6 } from "remotion";
558
545
 
559
546
  // src/browser-mediasession.ts
560
- import { useEffect as useEffect3, useRef as useRef3 } from "react";
547
+ import { useEffect as useEffect3, useRef as useRef2 } from "react";
561
548
 
562
549
  // src/use-player.ts
563
- import { useCallback as useCallback2, useContext as useContext3, useMemo, useRef as useRef2, useState as useState3 } from "react";
564
- import { Internals as Internals5 } from "remotion";
550
+ import { useCallback, useContext as useContext3, useMemo, useRef, useState as useState3 } from "react";
551
+ import { Internals as Internals4 } from "remotion";
565
552
  var usePlayer = () => {
566
- const [playing, setPlaying, imperativePlaying] = Internals5.Timeline.usePlayingState();
553
+ const [playing, setPlaying, imperativePlaying] = Internals4.Timeline.usePlayingState();
567
554
  const [hasPlayed, setHasPlayed] = useState3(false);
568
- const frame = Internals5.Timeline.useTimelinePosition();
569
- const playStart = useRef2(frame);
570
- const setFrame = Internals5.Timeline.useTimelineSetFrame();
571
- const setTimelinePosition = Internals5.Timeline.useTimelineSetFrame();
572
- const audioContext = useContext3(Internals5.SharedAudioContext);
573
- const audioTagsContext = useContext3(Internals5.SharedAudioTagsContext);
574
- const { audioAndVideoTags } = Internals5.useTimelineContext();
575
- const frameRef = useRef2(frame);
555
+ const frame = Internals4.Timeline.useTimelinePosition();
556
+ const playStart = useRef(frame);
557
+ const setFrame = Internals4.Timeline.useTimelineSetFrame();
558
+ const setTimelinePosition = Internals4.Timeline.useTimelineSetFrame();
559
+ const audioContext = useContext3(Internals4.SharedAudioContext);
560
+ const audioTagsContext = useContext3(Internals4.SharedAudioTagsContext);
561
+ const { audioAndVideoTags } = Internals4.useTimelineContext();
562
+ const frameRef = useRef(frame);
576
563
  frameRef.current = frame;
577
- const video = Internals5.useVideo();
578
- const config = Internals5.useUnsafeVideoConfig();
564
+ const video = Internals4.useVideo();
565
+ const config = Internals4.useUnsafeVideoConfig();
579
566
  const emitter = useContext3(PlayerEventEmitterContext);
580
567
  const lastFrame = (config?.durationInFrames ?? 1) - 1;
581
568
  const isLastFrame = frame === lastFrame;
@@ -583,19 +570,19 @@ var usePlayer = () => {
583
570
  if (!emitter) {
584
571
  throw new TypeError("Expected Player event emitter context");
585
572
  }
586
- const bufferingContext = useContext3(Internals5.BufferingContextReact);
573
+ const bufferingContext = useContext3(Internals4.BufferingContextReact);
587
574
  if (!bufferingContext) {
588
575
  throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
589
576
  }
590
577
  const { buffering } = bufferingContext;
591
- const seek = useCallback2((newFrame) => {
578
+ const seek = useCallback((newFrame) => {
592
579
  if (video?.id) {
593
580
  setTimelinePosition((c) => ({ ...c, [video.id]: newFrame }));
594
581
  }
595
582
  frameRef.current = newFrame;
596
583
  emitter.dispatchSeek(newFrame);
597
584
  }, [emitter, setTimelinePosition, video?.id]);
598
- const play = useCallback2((e) => {
585
+ const play = useCallback((e) => {
599
586
  if (imperativePlaying.current) {
600
587
  return;
601
588
  }
@@ -622,7 +609,7 @@ var usePlayer = () => {
622
609
  seek,
623
610
  audioAndVideoTags
624
611
  ]);
625
- const pause = useCallback2(() => {
612
+ const pause = useCallback(() => {
626
613
  if (imperativePlaying.current) {
627
614
  imperativePlaying.current = false;
628
615
  setPlaying(false);
@@ -630,7 +617,7 @@ var usePlayer = () => {
630
617
  audioContext?.suspend();
631
618
  }
632
619
  }, [emitter, imperativePlaying, setPlaying, audioContext]);
633
- const pauseAndReturnToPlayStart = useCallback2(() => {
620
+ const pauseAndReturnToPlayStart = useCallback(() => {
634
621
  if (imperativePlaying.current) {
635
622
  imperativePlaying.current = false;
636
623
  frameRef.current = playStart.current;
@@ -645,7 +632,7 @@ var usePlayer = () => {
645
632
  }
646
633
  }, [config, emitter, imperativePlaying, setPlaying, setTimelinePosition]);
647
634
  const videoId = video?.id;
648
- const frameBack = useCallback2((frames) => {
635
+ const frameBack = useCallback((frames) => {
649
636
  if (!videoId) {
650
637
  return null;
651
638
  }
@@ -664,7 +651,7 @@ var usePlayer = () => {
664
651
  };
665
652
  });
666
653
  }, [imperativePlaying, setFrame, videoId]);
667
- const frameForward = useCallback2((frames) => {
654
+ const frameForward = useCallback((frames) => {
668
655
  if (!videoId) {
669
656
  return null;
670
657
  }
@@ -683,20 +670,20 @@ var usePlayer = () => {
683
670
  };
684
671
  });
685
672
  }, [videoId, imperativePlaying, lastFrame, setFrame]);
686
- const toggle = useCallback2((e) => {
673
+ const toggle = useCallback((e) => {
687
674
  if (imperativePlaying.current) {
688
675
  pause();
689
676
  } else {
690
677
  play(e);
691
678
  }
692
679
  }, [imperativePlaying, pause, play]);
693
- const isPlaying = useCallback2(() => {
680
+ const isPlaying = useCallback(() => {
694
681
  return imperativePlaying.current;
695
682
  }, [imperativePlaying]);
696
- const getCurrentFrame = useCallback2(() => {
683
+ const getCurrentFrame = useCallback(() => {
697
684
  return frameRef.current;
698
685
  }, [frameRef]);
699
- const isBuffering = useCallback2(() => {
686
+ const isBuffering = useCallback(() => {
700
687
  return buffering.current;
701
688
  }, [buffering]);
702
689
  const returnValue = useMemo(() => {
@@ -744,7 +731,7 @@ var useBrowserMediaSession = ({
744
731
  playbackRate
745
732
  }) => {
746
733
  const { playing, pause, play, emitter, getCurrentFrame, seek } = usePlayer();
747
- const hasEverPlayed = useRef3(false);
734
+ const hasEverPlayed = useRef2(false);
748
735
  useEffect3(() => {
749
736
  if (playing) {
750
737
  hasEverPlayed.current = true;
@@ -883,7 +870,7 @@ var calculateNextFrame = ({
883
870
  };
884
871
 
885
872
  // src/is-backgrounded.ts
886
- import { useEffect as useEffect4, useRef as useRef4 } from "react";
873
+ import { useEffect as useEffect4, useRef as useRef3 } from "react";
887
874
  var getIsBackgrounded = () => {
888
875
  if (typeof document === "undefined") {
889
876
  return false;
@@ -891,7 +878,7 @@ var getIsBackgrounded = () => {
891
878
  return document.visibilityState === "hidden";
892
879
  };
893
880
  var useIsBackgrounded = () => {
894
- const isBackgrounded = useRef4(getIsBackgrounded());
881
+ const isBackgrounded = useRef3(getIsBackgrounded());
895
882
  useEffect4(() => {
896
883
  const onVisibilityChange = () => {
897
884
  isBackgrounded.current = getIsBackgrounded();
@@ -905,24 +892,25 @@ var useIsBackgrounded = () => {
905
892
  };
906
893
 
907
894
  // src/set-global-time-anchor.ts
908
- import { Internals as Internals6 } from "remotion";
895
+ import { Internals as Internals5 } from "remotion";
909
896
  var ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
910
897
  var setGlobalTimeAnchor = ({
911
898
  audioContext,
912
899
  audioSyncAnchor,
913
900
  absoluteTimeInSeconds,
914
901
  globalPlaybackRate,
915
- logLevel
902
+ logLevel,
903
+ force
916
904
  }) => {
917
905
  const newAnchor = audioContext.currentTime - absoluteTimeInSeconds / globalPlaybackRate;
918
906
  const shift = (newAnchor - audioSyncAnchor.value) * globalPlaybackRate;
919
907
  const { outputLatency } = audioContext;
920
908
  const safeOutputLatency = outputLatency === 0 ? 0.3 : outputLatency;
921
909
  const latency = audioContext.baseLatency + safeOutputLatency;
922
- if (Math.abs(shift) < ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT + latency) {
910
+ if (Math.abs(shift) < ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT + latency && !force) {
923
911
  return false;
924
912
  }
925
- Internals6.Log.verbose({ logLevel, tag: "audio-scheduling" }, "Anchor changed from %s to %s with shift %s", audioSyncAnchor.value, newAnchor, shift);
913
+ Internals5.Log.verbose({ logLevel, tag: "audio-scheduling" }, "Anchor " + (force ? "forcibly " : "") + "changed from %s to %s with shift %s", audioSyncAnchor.value, newAnchor, shift);
926
914
  audioSyncAnchor.value = newAnchor;
927
915
  return true;
928
916
  };
@@ -938,15 +926,15 @@ var usePlayback = ({
938
926
  getCurrentFrame,
939
927
  muted
940
928
  }) => {
941
- const config = Internals7.useUnsafeVideoConfig();
942
- const frame = Internals7.Timeline.useTimelinePosition();
929
+ const config = Internals6.useUnsafeVideoConfig();
930
+ const frame = Internals6.Timeline.useTimelinePosition();
943
931
  const { playing, pause, emitter, isPlaying } = usePlayer();
944
- const setFrame = Internals7.Timeline.useTimelineSetFrame();
945
- const sharedAudioContext = useContext4(Internals7.SharedAudioContext);
946
- const logLevel = Internals7.useLogLevel();
932
+ const setFrame = Internals6.Timeline.useTimelineSetFrame();
933
+ const sharedAudioContext = useContext4(Internals6.SharedAudioContext);
934
+ const logLevel = Internals6.useLogLevel();
947
935
  const isBackgroundedRef = useIsBackgrounded();
948
- const lastTimeUpdateTimestamp = useRef5(0);
949
- const context = useContext4(Internals7.BufferingContextReact);
936
+ const lastTimeUpdateTimestamp = useRef4(0);
937
+ const context = useContext4(Internals6.BufferingContextReact);
950
938
  if (!context) {
951
939
  throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
952
940
  }
@@ -965,17 +953,56 @@ var usePlayback = ({
965
953
  if (!config) {
966
954
  return;
967
955
  }
956
+ if (muted) {
957
+ return;
958
+ }
968
959
  const changed = setGlobalTimeAnchor({
969
960
  audioContext: sharedAudioContext.audioContext,
970
961
  audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
971
962
  absoluteTimeInSeconds: frame / config.fps,
972
963
  globalPlaybackRate: playbackRate,
973
- logLevel
964
+ logLevel,
965
+ force: false
974
966
  });
975
967
  if (changed) {
976
968
  sharedAudioContext.audioSyncAnchorEmitter.dispatch("changed");
977
969
  }
978
- }, [config, frame, logLevel, playbackRate, sharedAudioContext]);
970
+ }, [config, frame, logLevel, playbackRate, sharedAudioContext, muted]);
971
+ useLayoutEffect2(() => {
972
+ const audioContext = sharedAudioContext?.audioContext;
973
+ if (!audioContext) {
974
+ return;
975
+ }
976
+ if (!config) {
977
+ return;
978
+ }
979
+ if (muted) {
980
+ return;
981
+ }
982
+ const callback = () => {
983
+ if (audioContext.state !== "running") {
984
+ setGlobalTimeAnchor({
985
+ audioContext,
986
+ audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
987
+ absoluteTimeInSeconds: getCurrentFrame() / config.fps,
988
+ globalPlaybackRate: playbackRate,
989
+ logLevel,
990
+ force: true
991
+ });
992
+ }
993
+ };
994
+ audioContext?.addEventListener("statechange", callback);
995
+ return () => {
996
+ audioContext?.removeEventListener("statechange", callback);
997
+ };
998
+ }, [
999
+ config,
1000
+ getCurrentFrame,
1001
+ logLevel,
1002
+ muted,
1003
+ playbackRate,
1004
+ sharedAudioContext
1005
+ ]);
979
1006
  useEffect5(() => {
980
1007
  if (!config) {
981
1008
  return;
@@ -1009,7 +1036,7 @@ var usePlayback = ({
1009
1036
  sharedAudioContext?.suspend?.();
1010
1037
  return;
1011
1038
  }
1012
- if (!muted) {
1039
+ if (!muted && !context.buffering.current) {
1013
1040
  sharedAudioContext?.resume?.();
1014
1041
  }
1015
1042
  const time = performance.now() - startedTime;
@@ -1027,7 +1054,7 @@ var usePlayback = ({
1027
1054
  shouldLoop: loop
1028
1055
  });
1029
1056
  framesAdvanced += framesToAdvance;
1030
- if (nextFrame !== getCurrentFrame() && (!hasEnded || moveToBeginningWhenEnded)) {
1057
+ if (nextFrame !== getCurrentFrame() && (!hasEnded || moveToBeginningWhenEnded) && !context.buffering.current) {
1031
1058
  setFrame((c) => ({ ...c, [config.id]: nextFrame }));
1032
1059
  }
1033
1060
  if (hasEnded) {
@@ -1042,27 +1069,16 @@ var usePlayback = ({
1042
1069
  const getIsResumingAudioContext = sharedAudioContext?.getIsResumingAudioContext?.() ?? null;
1043
1070
  if (getIsResumingAudioContext !== null && !muted) {
1044
1071
  getIsResumingAudioContext.then(() => {
1045
- if (!sharedAudioContext?.audioContext) {
1046
- return;
1047
- }
1048
- if (!sharedAudioContext.audioSyncAnchor) {
1049
- return;
1050
- }
1051
- setGlobalTimeAnchor({
1052
- audioContext: sharedAudioContext.audioContext,
1053
- audioSyncAnchor: sharedAudioContext.audioSyncAnchor,
1054
- absoluteTimeInSeconds: getCurrentFrame() / config.fps,
1055
- globalPlaybackRate: playbackRate,
1056
- logLevel
1057
- });
1058
1072
  startedTime = performance.now();
1059
1073
  framesAdvanced = 0;
1060
1074
  queueNextFrame();
1061
1075
  });
1062
1076
  return;
1063
1077
  }
1064
- if (context.buffering.current && !muted) {
1065
- sharedAudioContext?.suspend?.();
1078
+ if (context.buffering.current) {
1079
+ if (!muted) {
1080
+ sharedAudioContext?.suspend?.();
1081
+ }
1066
1082
  const stopListening = context.listenForResume(() => {
1067
1083
  stopListening.remove();
1068
1084
  startedTime = performance.now();
@@ -1132,7 +1148,7 @@ var usePlayback = ({
1132
1148
  };
1133
1149
 
1134
1150
  // src/utils/use-element-size.ts
1135
- import { useCallback as useCallback3, useEffect as useEffect6, useMemo as useMemo2, useState as useState4 } from "react";
1151
+ import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useState as useState4 } from "react";
1136
1152
  var elementSizeHooks = [];
1137
1153
  var updateAllElementsSizes = () => {
1138
1154
  for (const listener of elementSizeHooks) {
@@ -1192,7 +1208,7 @@ var useElementSize = (ref, options) => {
1192
1208
  });
1193
1209
  });
1194
1210
  }, [options.shouldApplyCssTransforms]);
1195
- const updateSize = useCallback3(() => {
1211
+ const updateSize = useCallback2(() => {
1196
1212
  if (!ref.current) {
1197
1213
  return;
1198
1214
  }
@@ -1262,10 +1278,10 @@ import {
1262
1278
  useImperativeHandle as useImperativeHandle2,
1263
1279
  useLayoutEffect as useLayoutEffect3,
1264
1280
  useMemo as useMemo14,
1265
- useRef as useRef12,
1281
+ useRef as useRef11,
1266
1282
  useState as useState13
1267
1283
  } from "react";
1268
- import { Composition, Internals as Internals16 } from "remotion";
1284
+ import { Composition, Internals as Internals15 } from "remotion";
1269
1285
 
1270
1286
  // src/player-css-classname.ts
1271
1287
  var playerCssClassname = (override) => {
@@ -1276,15 +1292,15 @@ var playerCssClassname = (override) => {
1276
1292
  import React10, {
1277
1293
  Suspense,
1278
1294
  forwardRef,
1279
- useCallback as useCallback11,
1295
+ useCallback as useCallback10,
1280
1296
  useContext as useContext5,
1281
1297
  useEffect as useEffect12,
1282
1298
  useImperativeHandle,
1283
1299
  useMemo as useMemo12,
1284
- useRef as useRef11,
1300
+ useRef as useRef10,
1285
1301
  useState as useState11
1286
1302
  } from "react";
1287
- import { Internals as Internals12 } from "remotion";
1303
+ import { Internals as Internals11 } from "remotion";
1288
1304
 
1289
1305
  // src/error-boundary.tsx
1290
1306
  import React3 from "react";
@@ -1409,7 +1425,7 @@ var RenderWarningIfBlacklist = () => {
1409
1425
  };
1410
1426
 
1411
1427
  // src/PlayerControls.tsx
1412
- import { useCallback as useCallback8, useEffect as useEffect11, useMemo as useMemo9, useRef as useRef9, useState as useState10 } from "react";
1428
+ import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo9, useRef as useRef8, useState as useState10 } from "react";
1413
1429
 
1414
1430
  // src/DefaultPlayPauseButton.tsx
1415
1431
  import { jsx as jsx6 } from "react/jsx-runtime";
@@ -1426,11 +1442,11 @@ var DefaultPlayPauseButton = ({ playing, buffering }) => {
1426
1442
  };
1427
1443
 
1428
1444
  // src/MediaVolumeSlider.tsx
1429
- import { useCallback as useCallback5, useMemo as useMemo4, useRef as useRef6, useState as useState6 } from "react";
1430
- import { Internals as Internals8 } from "remotion";
1445
+ import { useCallback as useCallback4, useMemo as useMemo4, useRef as useRef5, useState as useState6 } from "react";
1446
+ import { Internals as Internals7 } from "remotion";
1431
1447
 
1432
1448
  // src/render-volume-slider.tsx
1433
- import React5, { useCallback as useCallback4, useMemo as useMemo3, useState as useState5 } from "react";
1449
+ import React5, { useCallback as useCallback3, useMemo as useMemo3, useState as useState5 } from "react";
1434
1450
  import { random } from "remotion";
1435
1451
  import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1436
1452
  var KNOB_SIZE = 12;
@@ -1464,7 +1480,7 @@ var DefaultVolumeSlider = ({
1464
1480
  }, [isVertical]);
1465
1481
  const randomId = typeof React5.useId === "undefined" ? "volume-slider" : React5.useId();
1466
1482
  const [randomClass] = useState5(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
1467
- const onVolumeChange = useCallback4((e) => {
1483
+ const onVolumeChange = useCallback3((e) => {
1468
1484
  setVolume(parseFloat(e.target.value));
1469
1485
  }, [setVolume]);
1470
1486
  const inputStyle = useMemo3(() => {
@@ -1541,13 +1557,13 @@ var renderDefaultVolumeSlider = (props) => {
1541
1557
  import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1542
1558
  var VOLUME_SLIDER_WIDTH = 100;
1543
1559
  var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, renderVolumeSlider }) => {
1544
- const [mediaMuted, setMediaMuted] = Internals8.useMediaMutedState();
1545
- const [mediaVolume, setMediaVolume] = Internals8.useMediaVolumeState();
1560
+ const [mediaMuted, setMediaMuted] = Internals7.useMediaMutedState();
1561
+ const [mediaVolume, setMediaVolume] = Internals7.useMediaVolumeState();
1546
1562
  const [focused, setFocused] = useState6(false);
1547
- const parentDivRef = useRef6(null);
1548
- const inputRef = useRef6(null);
1563
+ const parentDivRef = useRef5(null);
1564
+ const inputRef = useRef5(null);
1549
1565
  const hover = useHoverState(parentDivRef, false);
1550
- const onBlur = useCallback5(() => {
1566
+ const onBlur = useCallback4(() => {
1551
1567
  setTimeout(() => {
1552
1568
  if (inputRef.current && document.activeElement !== inputRef.current) {
1553
1569
  setFocused(false);
@@ -1555,7 +1571,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1555
1571
  }, 10);
1556
1572
  }, []);
1557
1573
  const isVolume0 = mediaVolume === 0;
1558
- const onClick = useCallback5(() => {
1574
+ const onClick = useCallback4(() => {
1559
1575
  if (isVolume0) {
1560
1576
  setMediaVolume(1);
1561
1577
  setMediaMuted(false);
@@ -1586,7 +1602,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1586
1602
  padding: 0
1587
1603
  };
1588
1604
  }, []);
1589
- const renderDefaultMuteButton = useCallback5(({ muted, volume }) => {
1605
+ const renderDefaultMuteButton = useCallback4(({ muted, volume }) => {
1590
1606
  const isMutedOrZero = muted || volume === 0;
1591
1607
  return /* @__PURE__ */ jsx8("button", {
1592
1608
  "aria-label": isMutedOrZero ? "Unmute sound" : "Mute sound",
@@ -1603,7 +1619,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1603
1619
  return renderMuteButton ? renderMuteButton({ muted: mediaMuted, volume: mediaVolume }) : renderDefaultMuteButton({ muted: mediaMuted, volume: mediaVolume });
1604
1620
  }, [mediaMuted, mediaVolume, renderDefaultMuteButton, renderMuteButton]);
1605
1621
  const volumeSlider = useMemo4(() => {
1606
- return (focused || hover) && !mediaMuted && !Internals8.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
1622
+ return (focused || hover) && !mediaMuted && !Internals7.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
1607
1623
  isVertical: displayVerticalVolumeSlider,
1608
1624
  volume: mediaVolume,
1609
1625
  onBlur: () => setFocused(false),
@@ -1630,14 +1646,14 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1630
1646
  };
1631
1647
 
1632
1648
  // src/PlaybackrateControl.tsx
1633
- import { useCallback as useCallback6, useEffect as useEffect9, useMemo as useMemo5, useState as useState8 } from "react";
1634
- import { Internals as Internals9 } from "remotion";
1649
+ import { useCallback as useCallback5, useEffect as useEffect9, useMemo as useMemo5, useState as useState8 } from "react";
1650
+ import { Internals as Internals8 } from "remotion";
1635
1651
 
1636
1652
  // src/utils/use-component-visible.ts
1637
- import { useEffect as useEffect8, useRef as useRef7, useState as useState7 } from "react";
1653
+ import { useEffect as useEffect8, useRef as useRef6, useState as useState7 } from "react";
1638
1654
  function useComponentVisible(initialIsVisible) {
1639
1655
  const [isComponentVisible, setIsComponentVisible] = useState7(initialIsVisible);
1640
- const ref = useRef7(null);
1656
+ const ref = useRef6(null);
1641
1657
  useEffect8(() => {
1642
1658
  const handleClickOutside = (event) => {
1643
1659
  if (ref.current && !ref.current.contains(event.target)) {
@@ -1687,16 +1703,16 @@ var formatPlaybackRate = (rate) => {
1687
1703
  return str.includes(".") ? str : str + ".0";
1688
1704
  };
1689
1705
  var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }) => {
1690
- const onClick = useCallback6((e) => {
1706
+ const onClick = useCallback5((e) => {
1691
1707
  e.stopPropagation();
1692
1708
  e.preventDefault();
1693
1709
  onSelect(rate);
1694
1710
  }, [onSelect, rate]);
1695
1711
  const [hovered, setHovered] = useState8(false);
1696
- const onMouseEnter = useCallback6(() => {
1712
+ const onMouseEnter = useCallback5(() => {
1697
1713
  setHovered(true);
1698
1714
  }, []);
1699
- const onMouseLeave = useCallback6(() => {
1715
+ const onMouseLeave = useCallback5(() => {
1700
1716
  setHovered(false);
1701
1717
  }, []);
1702
1718
  const isFocused = keyboardSelectedRate === rate;
@@ -1723,7 +1739,7 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1723
1739
  }, rate);
1724
1740
  };
1725
1741
  var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1726
- const { setPlaybackRate, playbackRate } = Internals9.usePlaybackRate();
1742
+ const { setPlaybackRate, playbackRate } = Internals8.usePlaybackRate();
1727
1743
  const [keyboardSelectedRate, setKeyboardSelectedRate] = useState8(playbackRate);
1728
1744
  useEffect9(() => {
1729
1745
  const listener = (e) => {
@@ -1763,7 +1779,7 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1763
1779
  setPlaybackRate,
1764
1780
  setIsComponentVisible
1765
1781
  ]);
1766
- const onSelect = useCallback6((rate) => {
1782
+ const onSelect = useCallback5((rate) => {
1767
1783
  setPlaybackRate(rate);
1768
1784
  setIsComponentVisible(false);
1769
1785
  }, [setIsComponentVisible, setPlaybackRate]);
@@ -1825,8 +1841,8 @@ var button = {
1825
1841
  };
1826
1842
  var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1827
1843
  const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false);
1828
- const { playbackRate } = Internals9.usePlaybackRate();
1829
- const onClick = useCallback6((e) => {
1844
+ const { playbackRate } = Internals8.usePlaybackRate();
1845
+ const onClick = useCallback5((e) => {
1830
1846
  e.stopPropagation();
1831
1847
  e.preventDefault();
1832
1848
  setIsComponentVisible((prevIsComponentVisible) => !prevIsComponentVisible);
@@ -1857,8 +1873,8 @@ var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1857
1873
  };
1858
1874
 
1859
1875
  // src/PlayerSeekBar.tsx
1860
- import { useCallback as useCallback7, useEffect as useEffect10, useMemo as useMemo6, useRef as useRef8, useState as useState9 } from "react";
1861
- import { Internals as Internals10, interpolate } from "remotion";
1876
+ import { useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo6, useRef as useRef7, useState as useState9 } from "react";
1877
+ import { Internals as Internals9, interpolate } from "remotion";
1862
1878
  import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
1863
1879
  var getFrameFromX = (clientX, durationInFrames, width) => {
1864
1880
  const pos = clientX;
@@ -1895,19 +1911,19 @@ var findBodyInWhichDivIsLocated = (div) => {
1895
1911
  return current;
1896
1912
  };
1897
1913
  var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFrame }) => {
1898
- const containerRef = useRef8(null);
1914
+ const containerRef = useRef7(null);
1899
1915
  const barHovered = useHoverState(containerRef, false);
1900
1916
  const size = useElementSize(containerRef, {
1901
1917
  triggerOnWindowResize: true,
1902
1918
  shouldApplyCssTransforms: true
1903
1919
  });
1904
1920
  const { seek, play, pause, playing } = usePlayer();
1905
- const frame = Internals10.Timeline.useTimelinePosition();
1921
+ const frame = Internals9.Timeline.useTimelinePosition();
1906
1922
  const [dragging, setDragging] = useState9({
1907
1923
  dragging: false
1908
1924
  });
1909
1925
  const width = size?.width ?? 0;
1910
- const onPointerDown = useCallback7((e) => {
1926
+ const onPointerDown = useCallback6((e) => {
1911
1927
  if (e.button !== 0) {
1912
1928
  return;
1913
1929
  }
@@ -1921,7 +1937,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
1921
1937
  });
1922
1938
  onSeekStart();
1923
1939
  }, [durationInFrames, width, pause, seek, playing, onSeekStart]);
1924
- const onPointerMove = useCallback7((e) => {
1940
+ const onPointerMove = useCallback6((e) => {
1925
1941
  if (!size) {
1926
1942
  throw new Error("Player has no size");
1927
1943
  }
@@ -1932,7 +1948,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
1932
1948
  const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, size.width);
1933
1949
  seek(_frame);
1934
1950
  }, [dragging.dragging, durationInFrames, seek, size]);
1935
- const onPointerUp = useCallback7(() => {
1951
+ const onPointerUp = useCallback6(() => {
1936
1952
  setDragging({
1937
1953
  dragging: false
1938
1954
  });
@@ -2015,7 +2031,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2015
2031
 
2016
2032
  // src/PlayerTimeLabel.tsx
2017
2033
  import { useMemo as useMemo7 } from "react";
2018
- import { Internals as Internals11 } from "remotion";
2034
+ import { Internals as Internals10 } from "remotion";
2019
2035
 
2020
2036
  // src/format-time.ts
2021
2037
  var formatTime = (timeInSeconds) => {
@@ -2027,7 +2043,7 @@ var formatTime = (timeInSeconds) => {
2027
2043
  // src/PlayerTimeLabel.tsx
2028
2044
  import { jsxs as jsxs7 } from "react/jsx-runtime";
2029
2045
  var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
2030
- const frame = Internals11.Timeline.useTimelinePosition();
2046
+ const frame = Internals10.Timeline.useTimelinePosition();
2031
2047
  const timeLabel = useMemo7(() => {
2032
2048
  return {
2033
2049
  color: "white",
@@ -2187,7 +2203,7 @@ var Controls = ({
2187
2203
  toggle,
2188
2204
  renderCustomControls
2189
2205
  }) => {
2190
- const playButtonRef = useRef9(null);
2206
+ const playButtonRef = useRef8(null);
2191
2207
  const [supportsFullscreen, setSupportsFullscreen] = useState10(false);
2192
2208
  const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
2193
2209
  const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
@@ -2262,14 +2278,14 @@ var Controls = ({
2262
2278
  return null;
2263
2279
  }, [showPlaybackRateControl]);
2264
2280
  const customControlsElement = renderCustomControls ? renderCustomControls() : null;
2265
- const ref = useRef9(null);
2266
- const flexRef = useRef9(null);
2267
- const onPointerDownIfContainer = useCallback8((e) => {
2281
+ const ref = useRef8(null);
2282
+ const flexRef = useRef8(null);
2283
+ const onPointerDownIfContainer = useCallback7((e) => {
2268
2284
  if (e.target === ref.current || e.target === flexRef.current) {
2269
2285
  onPointerDown?.(e);
2270
2286
  }
2271
2287
  }, [onPointerDown]);
2272
- const onDoubleClickIfContainer = useCallback8((e) => {
2288
+ const onDoubleClickIfContainer = useCallback7((e) => {
2273
2289
  if (e.target === ref.current || e.target === flexRef.current) {
2274
2290
  onDoubleClick?.(e);
2275
2291
  }
@@ -2377,7 +2393,7 @@ var Controls = ({
2377
2393
  var IS_NODE = typeof document === "undefined";
2378
2394
 
2379
2395
  // src/utils/use-click-prevention-on-double-click.ts
2380
- import { useCallback as useCallback10, useMemo as useMemo11 } from "react";
2396
+ import { useCallback as useCallback9, useMemo as useMemo11 } from "react";
2381
2397
 
2382
2398
  // src/utils/cancellable-promise.ts
2383
2399
  var cancellablePromise = (promise) => {
@@ -2405,16 +2421,16 @@ var cancellablePromise = (promise) => {
2405
2421
  var delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
2406
2422
 
2407
2423
  // src/utils/use-cancellable-promises.ts
2408
- import { useCallback as useCallback9, useMemo as useMemo10, useRef as useRef10 } from "react";
2424
+ import { useCallback as useCallback8, useMemo as useMemo10, useRef as useRef9 } from "react";
2409
2425
  var useCancellablePromises = () => {
2410
- const pendingPromises = useRef10([]);
2411
- const appendPendingPromise = useCallback9((promise) => {
2426
+ const pendingPromises = useRef9([]);
2427
+ const appendPendingPromise = useCallback8((promise) => {
2412
2428
  pendingPromises.current = [...pendingPromises.current, promise];
2413
2429
  }, []);
2414
- const removePendingPromise = useCallback9((promise) => {
2430
+ const removePendingPromise = useCallback8((promise) => {
2415
2431
  pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
2416
2432
  }, []);
2417
- const clearPendingPromises = useCallback9(() => pendingPromises.current.map((p) => p.cancel()), []);
2433
+ const clearPendingPromises = useCallback8(() => pendingPromises.current.map((p) => p.cancel()), []);
2418
2434
  const api = useMemo10(() => ({
2419
2435
  appendPendingPromise,
2420
2436
  removePendingPromise,
@@ -2426,7 +2442,7 @@ var useCancellablePromises = () => {
2426
2442
  // src/utils/use-click-prevention-on-double-click.ts
2427
2443
  var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
2428
2444
  const api = useCancellablePromises();
2429
- const handleClick = useCallback10(async (e) => {
2445
+ const handleClick = useCallback9(async (e) => {
2430
2446
  if (e instanceof PointerEvent ? e.pointerType === "touch" : e.nativeEvent.pointerType === "touch") {
2431
2447
  onClick(e);
2432
2448
  return;
@@ -2446,14 +2462,14 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
2446
2462
  }
2447
2463
  }
2448
2464
  }, [api, onClick]);
2449
- const handlePointerDown = useCallback10(() => {
2465
+ const handlePointerDown = useCallback9(() => {
2450
2466
  document.addEventListener("pointerup", (newEvt) => {
2451
2467
  handleClick(newEvt);
2452
2468
  }, {
2453
2469
  once: true
2454
2470
  });
2455
2471
  }, [handleClick]);
2456
- const handleDoubleClick = useCallback10(() => {
2472
+ const handleDoubleClick = useCallback9(() => {
2457
2473
  api.clearPendingPromises();
2458
2474
  onDoubleClick();
2459
2475
  }, [api, onDoubleClick]);
@@ -2515,9 +2531,9 @@ var PlayerUI = ({
2515
2531
  overrideInternalClassName,
2516
2532
  noSuspense
2517
2533
  }, ref) => {
2518
- const config = Internals12.useUnsafeVideoConfig();
2519
- const video = Internals12.useVideo();
2520
- const container = useRef11(null);
2534
+ const config = Internals11.useUnsafeVideoConfig();
2535
+ const video = Internals11.useVideo();
2536
+ const container = useRef10(null);
2521
2537
  const canvasSize = useElementSize(container, {
2522
2538
  triggerOnWindowResize: false,
2523
2539
  shouldApplyCssTransforms: false
@@ -2534,7 +2550,7 @@ var PlayerUI = ({
2534
2550
  }, []);
2535
2551
  const player = usePlayer();
2536
2552
  const playerToggle = player.toggle;
2537
- const { mediaMuted, mediaVolume } = useContext5(Internals12.MediaVolumeContext);
2553
+ const { mediaMuted, mediaVolume } = useContext5(Internals11.MediaVolumeContext);
2538
2554
  useEffect12(() => {
2539
2555
  player.emitter.dispatchVolumeChange(mediaVolume);
2540
2556
  }, [player.emitter, mediaVolume]);
@@ -2576,10 +2592,10 @@ var PlayerUI = ({
2576
2592
  document.removeEventListener("webkitfullscreenchange", onFullscreenChange);
2577
2593
  };
2578
2594
  }, []);
2579
- const toggle = useCallback11((e) => {
2595
+ const toggle = useCallback10((e) => {
2580
2596
  playerToggle(e);
2581
2597
  }, [playerToggle]);
2582
- const requestFullscreen = useCallback11(() => {
2598
+ const requestFullscreen = useCallback10(() => {
2583
2599
  if (!allowFullscreen) {
2584
2600
  throw new Error("allowFullscreen is false");
2585
2601
  }
@@ -2595,7 +2611,7 @@ var PlayerUI = ({
2595
2611
  container.current.requestFullscreen();
2596
2612
  }
2597
2613
  }, [allowFullscreen, supportsFullScreen]);
2598
- const exitFullscreen = useCallback11(() => {
2614
+ const exitFullscreen = useCallback10(() => {
2599
2615
  if (document.webkitExitFullscreen) {
2600
2616
  document.webkitExitFullscreen();
2601
2617
  } else {
@@ -2639,7 +2655,7 @@ var PlayerUI = ({
2639
2655
  });
2640
2656
  }, [canvasSize, config]);
2641
2657
  const scale = layout?.scale ?? 1;
2642
- const initialScaleIgnored = useRef11(false);
2658
+ const initialScaleIgnored = useRef10(false);
2643
2659
  useEffect12(() => {
2644
2660
  if (!initialScaleIgnored.current) {
2645
2661
  initialScaleIgnored.current = true;
@@ -2647,7 +2663,7 @@ var PlayerUI = ({
2647
2663
  }
2648
2664
  player.emitter.dispatchScaleChange(scale);
2649
2665
  }, [player.emitter, scale]);
2650
- const { setMediaVolume, setMediaMuted } = useContext5(Internals12.SetMediaVolumeContext);
2666
+ const { setMediaVolume, setMediaMuted } = useContext5(Internals11.SetMediaVolumeContext);
2651
2667
  const [showBufferIndicator, setShowBufferState] = useState11(false);
2652
2668
  useEffect12(() => {
2653
2669
  let timeout = null;
@@ -2788,32 +2804,32 @@ var PlayerUI = ({
2788
2804
  }, [config, layout, overflowVisible, scale]);
2789
2805
  const playerPause = player.pause;
2790
2806
  const playerDispatchError = player.emitter.dispatchError;
2791
- const onError = useCallback11((error) => {
2807
+ const onError = useCallback10((error) => {
2792
2808
  playerPause();
2793
2809
  playerDispatchError(error);
2794
2810
  }, [playerDispatchError, playerPause]);
2795
- const onFullscreenButtonClick = useCallback11((e) => {
2811
+ const onFullscreenButtonClick = useCallback10((e) => {
2796
2812
  e.stopPropagation();
2797
2813
  requestFullscreen();
2798
2814
  }, [requestFullscreen]);
2799
- const onExitFullscreenButtonClick = useCallback11((e) => {
2815
+ const onExitFullscreenButtonClick = useCallback10((e) => {
2800
2816
  e.stopPropagation();
2801
2817
  exitFullscreen();
2802
2818
  }, [exitFullscreen]);
2803
- const onSingleClick = useCallback11((e) => {
2819
+ const onSingleClick = useCallback10((e) => {
2804
2820
  const rightClick = e instanceof MouseEvent ? e.button === 2 : e.nativeEvent.button;
2805
2821
  if (rightClick) {
2806
2822
  return;
2807
2823
  }
2808
2824
  toggle(e);
2809
2825
  }, [toggle]);
2810
- const onSeekStart = useCallback11(() => {
2826
+ const onSeekStart = useCallback10(() => {
2811
2827
  setSeeking(true);
2812
2828
  }, []);
2813
- const onSeekEnd = useCallback11(() => {
2829
+ const onSeekEnd = useCallback10(() => {
2814
2830
  setSeeking(false);
2815
2831
  }, []);
2816
- const onDoubleClick = useCallback11(() => {
2832
+ const onDoubleClick = useCallback10(() => {
2817
2833
  if (isFullscreen) {
2818
2834
  exitFullscreen();
2819
2835
  } else {
@@ -2873,7 +2889,7 @@ var PlayerUI = ({
2873
2889
  VideoComponent ? /* @__PURE__ */ jsx12(ErrorBoundary, {
2874
2890
  onError,
2875
2891
  errorFallback,
2876
- children: /* @__PURE__ */ jsx12(Internals12.CurrentScaleContext.Provider, {
2892
+ children: /* @__PURE__ */ jsx12(Internals11.CurrentScaleContext.Provider, {
2877
2893
  value: currentScale,
2878
2894
  children: /* @__PURE__ */ jsx12(VideoComponent, {
2879
2895
  ...video?.props ?? {},
@@ -2955,11 +2971,11 @@ var PlayerUI = ({
2955
2971
  var PlayerUI_default = forwardRef(PlayerUI);
2956
2972
 
2957
2973
  // src/SharedPlayerContext.tsx
2958
- import { useCallback as useCallback12, useMemo as useMemo13, useState as useState12 } from "react";
2959
- import { Internals as Internals14 } from "remotion";
2974
+ import { useCallback as useCallback11, useMemo as useMemo13, useState as useState12 } from "react";
2975
+ import { Internals as Internals13 } from "remotion";
2960
2976
 
2961
2977
  // src/volume-persistence.ts
2962
- import { Internals as Internals13 } from "remotion";
2978
+ import { Internals as Internals12 } from "remotion";
2963
2979
  var DEFAULT_VOLUME_PERSISTENCE_KEY = "remotion.volumePreference";
2964
2980
  var persistVolume = (volume, logLevel, volumePersistenceKey) => {
2965
2981
  if (typeof window === "undefined") {
@@ -2968,7 +2984,7 @@ var persistVolume = (volume, logLevel, volumePersistenceKey) => {
2968
2984
  try {
2969
2985
  window.localStorage.setItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTENCE_KEY, String(volume));
2970
2986
  } catch (e) {
2971
- Internals13.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
2987
+ Internals12.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
2972
2988
  }
2973
2989
  };
2974
2990
  var getPreferredVolume = (volumePersistenceKey) => {
@@ -3056,7 +3072,7 @@ var SharedPlayerContexts = ({
3056
3072
  mediaVolume
3057
3073
  };
3058
3074
  }, [mediaMuted, mediaVolume]);
3059
- const setMediaVolumeAndPersist = useCallback12((vol) => {
3075
+ const setMediaVolumeAndPersist = useCallback11((vol) => {
3060
3076
  setMediaVolume(vol);
3061
3077
  if (persistVolumeToStorage) {
3062
3078
  persistVolume(vol, logLevel, volumePersistenceKey ?? null);
@@ -3083,30 +3099,30 @@ var SharedPlayerContexts = ({
3083
3099
  isReadOnlyStudio: false
3084
3100
  };
3085
3101
  }, []);
3086
- return /* @__PURE__ */ jsx13(Internals14.RemotionEnvironmentContext.Provider, {
3102
+ return /* @__PURE__ */ jsx13(Internals13.RemotionEnvironmentContext.Provider, {
3087
3103
  value: env,
3088
- children: /* @__PURE__ */ jsx13(Internals14.LogLevelContext.Provider, {
3104
+ children: /* @__PURE__ */ jsx13(Internals13.LogLevelContext.Provider, {
3089
3105
  value: logLevelContext,
3090
- children: /* @__PURE__ */ jsx13(Internals14.CanUseRemotionHooksProvider, {
3091
- children: /* @__PURE__ */ jsx13(Internals14.AbsoluteTimeContext.Provider, {
3106
+ children: /* @__PURE__ */ jsx13(Internals13.CanUseRemotionHooksProvider, {
3107
+ children: /* @__PURE__ */ jsx13(Internals13.AbsoluteTimeContext.Provider, {
3092
3108
  value: timelineContext,
3093
- children: /* @__PURE__ */ jsx13(Internals14.PlaybackRateContext.Provider, {
3109
+ children: /* @__PURE__ */ jsx13(Internals13.PlaybackRateContext.Provider, {
3094
3110
  value: playbackRateContext,
3095
- children: /* @__PURE__ */ jsx13(Internals14.TimelineContext.Provider, {
3111
+ children: /* @__PURE__ */ jsx13(Internals13.TimelineContext.Provider, {
3096
3112
  value: timelineContext,
3097
- children: /* @__PURE__ */ jsx13(Internals14.CompositionManager.Provider, {
3113
+ children: /* @__PURE__ */ jsx13(Internals13.CompositionManager.Provider, {
3098
3114
  value: compositionManagerContext,
3099
- children: /* @__PURE__ */ jsx13(Internals14.PrefetchProvider, {
3100
- children: /* @__PURE__ */ jsx13(Internals14.DurationsContextProvider, {
3101
- children: /* @__PURE__ */ jsx13(Internals14.MediaVolumeContext.Provider, {
3115
+ children: /* @__PURE__ */ jsx13(Internals13.PrefetchProvider, {
3116
+ children: /* @__PURE__ */ jsx13(Internals13.DurationsContextProvider, {
3117
+ children: /* @__PURE__ */ jsx13(Internals13.MediaVolumeContext.Provider, {
3102
3118
  value: mediaVolumeContextValue,
3103
- children: /* @__PURE__ */ jsx13(Internals14.SetMediaVolumeContext.Provider, {
3119
+ children: /* @__PURE__ */ jsx13(Internals13.SetMediaVolumeContext.Provider, {
3104
3120
  value: setMediaVolumeContextValue,
3105
- children: /* @__PURE__ */ jsx13(Internals14.BufferingProvider, {
3106
- children: /* @__PURE__ */ jsx13(Internals14.SharedAudioContextProvider, {
3121
+ children: /* @__PURE__ */ jsx13(Internals13.BufferingProvider, {
3122
+ children: /* @__PURE__ */ jsx13(Internals13.SharedAudioContextProvider, {
3107
3123
  audioLatencyHint,
3108
3124
  audioEnabled,
3109
- children: /* @__PURE__ */ jsx13(Internals14.SharedAudioTagsContextProvider, {
3125
+ children: /* @__PURE__ */ jsx13(Internals13.SharedAudioTagsContextProvider, {
3110
3126
  numberOfAudioTags: numberOfSharedAudioTags,
3111
3127
  children
3112
3128
  })
@@ -3126,7 +3142,7 @@ var SharedPlayerContexts = ({
3126
3142
  };
3127
3143
 
3128
3144
  // src/use-remotion-license-acknowledge.ts
3129
- import { Internals as Internals15 } from "remotion";
3145
+ import { Internals as Internals14 } from "remotion";
3130
3146
  var warningShown = false;
3131
3147
  var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
3132
3148
  if (acknowledge) {
@@ -3136,7 +3152,7 @@ var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
3136
3152
  return;
3137
3153
  }
3138
3154
  warningShown = true;
3139
- Internals15.Log.warn({ logLevel, tag: null }, "Note: Some companies are required to obtain a license to use Remotion. See: https://remotion.dev/license\nPass the `acknowledgeRemotionLicense` prop to `<Player />` function to make this message disappear.");
3155
+ Internals14.Log.warn({ logLevel, tag: null }, "Note: Some companies are required to obtain a license to use Remotion. See: https://remotion.dev/license\nPass the `acknowledgeRemotionLicense` prop to `<Player />` function to make this message disappear.");
3140
3156
  };
3141
3157
 
3142
3158
  // src/utils/validate-in-out-frame.ts
@@ -3311,7 +3327,7 @@ var PlayerFn = ({
3311
3327
  throw new TypeError(`'component' must not be the 'Composition' component. Pass your own React component directly, and set the duration, fps and dimensions as separate props. See https://www.remotion.dev/docs/player/examples for an example.`);
3312
3328
  }
3313
3329
  useState13(() => acknowledgeRemotionLicenseMessage(Boolean(acknowledgeRemotionLicense), logLevel));
3314
- const component = Internals16.useLazyComponent({
3330
+ const component = Internals15.useLazyComponent({
3315
3331
  compProps: componentProps,
3316
3332
  componentName: "Player",
3317
3333
  noSuspense: Boolean(noSuspense)
@@ -3322,9 +3338,9 @@ var PlayerFn = ({
3322
3338
  }));
3323
3339
  const [playing, setPlaying] = useState13(false);
3324
3340
  const [rootId] = useState13("player-comp");
3325
- const rootRef = useRef12(null);
3326
- const audioAndVideoTags = useRef12([]);
3327
- const imperativePlaying = useRef12(false);
3341
+ const rootRef = useRef11(null);
3342
+ const audioAndVideoTags = useRef11([]);
3343
+ const imperativePlaying = useRef11(false);
3328
3344
  const [currentPlaybackRate, setCurrentPlaybackRate] = useState13(playbackRate);
3329
3345
  if (typeof compositionHeight !== "number") {
3330
3346
  throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
@@ -3384,7 +3400,7 @@ var PlayerFn = ({
3384
3400
  }, [playbackRate]);
3385
3401
  useImperativeHandle2(ref, () => rootRef.current, []);
3386
3402
  useState13(() => {
3387
- Internals16.playbackLogging({
3403
+ Internals15.playbackLogging({
3388
3404
  logLevel,
3389
3405
  message: `[player] Mounting <Player>. User agent = ${typeof navigator === "undefined" ? "server" : navigator.userAgent}`,
3390
3406
  tag: "player",
@@ -3414,7 +3430,7 @@ var PlayerFn = ({
3414
3430
  }, [setFrame]);
3415
3431
  if (typeof window !== "undefined") {
3416
3432
  useLayoutEffect3(() => {
3417
- Internals16.CSSUtils.injectCSS(Internals16.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
3433
+ Internals15.CSSUtils.injectCSS(Internals15.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
3418
3434
  }, [overrideInternalClassName]);
3419
3435
  }
3420
3436
  const actualInputProps = useMemo14(() => inputProps ?? {}, [inputProps]);
@@ -3423,7 +3439,7 @@ var PlayerFn = ({
3423
3439
  mode: "prevent-media-session"
3424
3440
  };
3425
3441
  }, [passedBrowserMediaControlsBehavior]);
3426
- return /* @__PURE__ */ jsx14(Internals16.IsPlayerContextProvider, {
3442
+ return /* @__PURE__ */ jsx14(Internals15.IsPlayerContextProvider, {
3427
3443
  children: /* @__PURE__ */ jsx14(SharedPlayerContexts, {
3428
3444
  timelineContext: timelineContextValue,
3429
3445
  playbackRateContext: playbackRateContextValue,
@@ -3440,7 +3456,7 @@ var PlayerFn = ({
3440
3456
  initialVolume,
3441
3457
  inputProps: actualInputProps,
3442
3458
  audioEnabled: true,
3443
- children: /* @__PURE__ */ jsx14(Internals16.SetTimelineContext.Provider, {
3459
+ children: /* @__PURE__ */ jsx14(Internals15.SetTimelineContext.Provider, {
3444
3460
  value: setTimelineContextValue,
3445
3461
  children: /* @__PURE__ */ jsx14(PlayerEmitterProvider, {
3446
3462
  currentPlaybackRate,
@@ -3498,21 +3514,21 @@ import {
3498
3514
  useImperativeHandle as useImperativeHandle4,
3499
3515
  useLayoutEffect as useLayoutEffect4,
3500
3516
  useMemo as useMemo17,
3501
- useRef as useRef14,
3517
+ useRef as useRef13,
3502
3518
  useState as useState14
3503
3519
  } from "react";
3504
- import { Internals as Internals18, random as random2 } from "remotion";
3520
+ import { Internals as Internals17, random as random2 } from "remotion";
3505
3521
 
3506
3522
  // src/ThumbnailUI.tsx
3507
3523
  import React13, {
3508
3524
  forwardRef as forwardRef3,
3509
3525
  Suspense as Suspense2,
3510
- useCallback as useCallback13,
3526
+ useCallback as useCallback12,
3511
3527
  useImperativeHandle as useImperativeHandle3,
3512
3528
  useMemo as useMemo16,
3513
- useRef as useRef13
3529
+ useRef as useRef12
3514
3530
  } from "react";
3515
- import { Internals as Internals17 } from "remotion";
3531
+ import { Internals as Internals16 } from "remotion";
3516
3532
 
3517
3533
  // src/use-thumbnail.ts
3518
3534
  import { useContext as useContext6, useMemo as useMemo15 } from "react";
@@ -3546,9 +3562,9 @@ var ThumbnailUI = ({
3546
3562
  noSuspense,
3547
3563
  overrideInternalClassName
3548
3564
  }, ref) => {
3549
- const config = Internals17.useUnsafeVideoConfig();
3550
- const video = Internals17.useVideo();
3551
- const container = useRef13(null);
3565
+ const config = Internals16.useUnsafeVideoConfig();
3566
+ const video = Internals16.useVideo();
3567
+ const container = useRef12(null);
3552
3568
  const canvasSize = useElementSize(container, {
3553
3569
  triggerOnWindowResize: false,
3554
3570
  shouldApplyCssTransforms: false
@@ -3595,7 +3611,7 @@ var ThumbnailUI = ({
3595
3611
  overflowVisible
3596
3612
  });
3597
3613
  }, [config, layout, overflowVisible, scale]);
3598
- const onError = useCallback13((error) => {
3614
+ const onError = useCallback12((error) => {
3599
3615
  thumbnail.emitter.dispatchError(error);
3600
3616
  }, [thumbnail.emitter]);
3601
3617
  const loadingMarkup = useMemo16(() => {
@@ -3622,7 +3638,7 @@ var ThumbnailUI = ({
3622
3638
  children: VideoComponent ? /* @__PURE__ */ jsx15(ErrorBoundary, {
3623
3639
  onError,
3624
3640
  errorFallback,
3625
- children: /* @__PURE__ */ jsx15(Internals17.CurrentScaleContext.Provider, {
3641
+ children: /* @__PURE__ */ jsx15(Internals16.CurrentScaleContext.Provider, {
3626
3642
  value: currentScaleContext,
3627
3643
  children: /* @__PURE__ */ jsx15(VideoComponent, {
3628
3644
  ...video?.props ?? {},
@@ -3677,7 +3693,7 @@ var ThumbnailFn = ({
3677
3693
  }, []);
3678
3694
  }
3679
3695
  const [thumbnailId] = useState14(() => String(random2(null)));
3680
- const rootRef = useRef14(null);
3696
+ const rootRef = useRef13(null);
3681
3697
  const timelineState = useMemo17(() => {
3682
3698
  const value = {
3683
3699
  playing: false,
@@ -3701,7 +3717,7 @@ var ThumbnailFn = ({
3701
3717
  };
3702
3718
  }, []);
3703
3719
  useImperativeHandle4(ref, () => rootRef.current, []);
3704
- const Component = Internals18.useLazyComponent({
3720
+ const Component = Internals17.useLazyComponent({
3705
3721
  compProps: componentProps,
3706
3722
  componentName: "Thumbnail",
3707
3723
  noSuspense: Boolean(noSuspense)
@@ -3710,7 +3726,7 @@ var ThumbnailFn = ({
3710
3726
  const passedInputProps = useMemo17(() => {
3711
3727
  return inputProps ?? {};
3712
3728
  }, [inputProps]);
3713
- return /* @__PURE__ */ jsx16(Internals18.IsPlayerContextProvider, {
3729
+ return /* @__PURE__ */ jsx16(Internals17.IsPlayerContextProvider, {
3714
3730
  children: /* @__PURE__ */ jsx16(SharedPlayerContexts, {
3715
3731
  timelineContext: timelineState,
3716
3732
  playbackRateContext,
@@ -3756,8 +3772,7 @@ var PlayerInternals = {
3756
3772
  useHoverState,
3757
3773
  updateAllElementsSizes,
3758
3774
  PlayerEmitterProvider,
3759
- BufferingIndicator,
3760
- useFrameImperative
3775
+ BufferingIndicator
3761
3776
  };
3762
3777
  export {
3763
3778
  Thumbnail,
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.459",
6
+ "version": "4.0.461",
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.459"
39
+ "remotion": "4.0.461"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=16.8.0",
@@ -45,12 +45,12 @@
45
45
  "devDependencies": {
46
46
  "@testing-library/react": "16.1.0",
47
47
  "@happy-dom/global-registrator": "14.5.1",
48
- "csstype": "^3.1.1",
48
+ "csstype": "3.2.3",
49
49
  "react": "19.2.3",
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.459",
53
+ "@remotion/eslint-config-internal": "4.0.461",
54
54
  "eslint": "9.19.0",
55
55
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
56
56
  },