@remotion/player 4.0.505 → 4.0.507

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.
@@ -354,7 +354,7 @@ var ThumbnailEmitterContext = React.createContext(undefined);
354
354
 
355
355
  // src/EmitterProvider.tsx
356
356
  import { useContext as useContext2, useEffect, useState } from "react";
357
- import { Internals as Internals3 } from "remotion";
357
+ import { Internals as Internals4 } from "remotion";
358
358
 
359
359
  // src/event-emitter.ts
360
360
  class PlayerEmitter {
@@ -469,11 +469,57 @@ class ThumbnailEmitter {
469
469
  };
470
470
  }
471
471
 
472
+ // src/timeline-imperative-context.tsx
473
+ import React2, { useMemo, useRef } from "react";
474
+ import { Internals as Internals2 } from "remotion";
475
+ import { jsx as jsx3 } from "react/jsx-runtime";
476
+ var PlayerTimelineImperativeContext = React2.createContext(null);
477
+ var getCoreTimelineImperativeContext = () => {
478
+ return Internals2.TimelineImperativeContext;
479
+ };
480
+ var getTimelineImperativeContext = () => {
481
+ return getCoreTimelineImperativeContext() ?? PlayerTimelineImperativeContext;
482
+ };
483
+ var CoreTimelineImperativeContextProvider = ({ children, value }) => {
484
+ const TimelineImperativeContext = getCoreTimelineImperativeContext();
485
+ if (!TimelineImperativeContext) {
486
+ return children;
487
+ }
488
+ return /* @__PURE__ */ jsx3(TimelineImperativeContext.Provider, {
489
+ value,
490
+ children
491
+ });
492
+ };
493
+ var LegacyTimelineImperativeContextProvider = ({ children }) => {
494
+ const timelineContext = Internals2.Timeline.useTimelineContext();
495
+ const frameRef = useRef(timelineContext.frame);
496
+ frameRef.current = timelineContext.frame;
497
+ const value = useMemo(() => {
498
+ return {
499
+ frameRef,
500
+ imperativePlaying: timelineContext.imperativePlaying,
501
+ audioAndVideoTags: timelineContext.audioAndVideoTags
502
+ };
503
+ }, [timelineContext.audioAndVideoTags, timelineContext.imperativePlaying]);
504
+ return /* @__PURE__ */ jsx3(PlayerTimelineImperativeContext.Provider, {
505
+ value,
506
+ children
507
+ });
508
+ };
509
+ var TimelineImperativeCompatibilityProvider = ({ children }) => {
510
+ if (getCoreTimelineImperativeContext()) {
511
+ return children;
512
+ }
513
+ return /* @__PURE__ */ jsx3(LegacyTimelineImperativeContextProvider, {
514
+ children
515
+ });
516
+ };
517
+
472
518
  // src/use-buffer-state-emitter.ts
473
519
  import { useContext, useLayoutEffect } from "react";
474
- import { Internals as Internals2 } from "remotion";
520
+ import { Internals as Internals3 } from "remotion";
475
521
  var useBufferStateEmitter = (emitter) => {
476
- const bufferManager = useContext(Internals2.BufferingContextReact);
522
+ const bufferManager = useContext(Internals3.BufferingContextReact);
477
523
  if (!bufferManager) {
478
524
  throw new Error("BufferingContextReact not found");
479
525
  }
@@ -494,10 +540,10 @@ var useBufferStateEmitter = (emitter) => {
494
540
  };
495
541
 
496
542
  // src/EmitterProvider.tsx
497
- import { jsx as jsx3 } from "react/jsx-runtime";
543
+ import { jsx as jsx4 } from "react/jsx-runtime";
498
544
  var PlayerEmitterProvider = ({ children, currentPlaybackRate }) => {
499
545
  const [emitter] = useState(() => new PlayerEmitter);
500
- const bufferManager = useContext2(Internals3.BufferingContextReact);
546
+ const bufferManager = useContext2(Internals4.BufferingContextReact);
501
547
  if (!bufferManager) {
502
548
  throw new Error("BufferingContextReact not found");
503
549
  }
@@ -507,9 +553,11 @@ var PlayerEmitterProvider = ({ children, currentPlaybackRate }) => {
507
553
  }
508
554
  }, [emitter, currentPlaybackRate]);
509
555
  useBufferStateEmitter(emitter);
510
- return /* @__PURE__ */ jsx3(PlayerEventEmitterContext.Provider, {
511
- value: emitter,
512
- children
556
+ return /* @__PURE__ */ jsx4(TimelineImperativeCompatibilityProvider, {
557
+ children: /* @__PURE__ */ jsx4(PlayerEventEmitterContext.Provider, {
558
+ value: emitter,
559
+ children
560
+ })
513
561
  });
514
562
  };
515
563
 
@@ -558,189 +606,203 @@ var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
558
606
 
559
607
  // src/use-playback.ts
560
608
  import { useLayoutEffect as useLayoutEffect2 } from "react";
561
- import { useContext as useContext4, useEffect as useEffect5, useRef as useRef4 } from "react";
562
- import { Internals as Internals6 } from "remotion";
609
+ import { useContext as useContext4, useEffect as useEffect5, useRef as useRef5 } from "react";
610
+ import { Internals as Internals8 } from "remotion";
563
611
 
564
612
  // src/browser-mediasession.ts
565
- import { useEffect as useEffect3, useRef as useRef2 } from "react";
613
+ import { useEffect as useEffect3, useRef as useRef3 } from "react";
614
+ import { Internals as Internals6 } from "remotion";
566
615
 
567
- // src/use-player.ts
568
- import { useCallback, useContext as useContext3, useMemo, useRef, useState as useState3 } from "react";
569
- import { Internals as Internals4 } from "remotion";
570
- var usePlayer = () => {
571
- const [playing, setPlaying, imperativePlaying] = Internals4.Timeline.usePlayingState();
572
- const [hasPlayed, setHasPlayed] = useState3(false);
573
- const frame = Internals4.Timeline.useTimelinePosition();
574
- const playStart = useRef(frame);
575
- const setFrame = Internals4.Timeline.useTimelineSetFrame();
576
- const setTimelinePosition = Internals4.Timeline.useTimelineSetFrame();
577
- const audioContext = useContext3(Internals4.SharedAudioContext);
578
- const audioTagsContext = useContext3(Internals4.SharedAudioTagsContext);
579
- const { audioAndVideoTags } = Internals4.useTimelineContext();
580
- const frameRef = useRef(frame);
581
- frameRef.current = frame;
582
- const video = Internals4.useVideo();
583
- const config = Internals4.useUnsafeVideoConfig();
616
+ // src/use-player-methods.ts
617
+ import { useCallback, useContext as useContext3, useMemo as useMemo2, useRef as useRef2 } from "react";
618
+ import { Internals as Internals5, useRemotionEnvironment } from "remotion";
619
+ var usePlayerMethods = () => {
620
+ const setFrame = Internals5.Timeline.useTimelineSetFrame();
621
+ const setTimelinePosition = Internals5.Timeline.useTimelineSetFrame();
622
+ const { setPlaying } = useContext3(Internals5.SetTimelineContext);
623
+ const timelineImperativeContext = useContext3(getTimelineImperativeContext());
624
+ const audioContext = useContext3(Internals5.SharedAudioContext);
625
+ const audioTagsContext = useContext3(Internals5.SharedAudioTagsContext);
626
+ const environment = useRemotionEnvironment();
627
+ const video = Internals5.useVideo();
628
+ const config = Internals5.useUnsafeVideoConfig();
584
629
  const emitter = useContext3(PlayerEventEmitterContext);
585
- const lastFrame = (config?.durationInFrames ?? 1) - 1;
586
- const isLastFrame = frame === lastFrame;
587
- const isFirstFrame = frame === 0;
630
+ const playStart = useRef2(0);
631
+ const fallbackFrame = useRef2(null);
632
+ if (!timelineImperativeContext) {
633
+ throw new Error("Timeline imperative context is not available. This hook must be used inside a <Player> or the Remotion Studio.");
634
+ }
588
635
  if (!emitter) {
589
636
  throw new TypeError("Expected Player event emitter context");
590
637
  }
591
- const bufferingContext = useContext3(Internals4.BufferingContextReact);
638
+ const bufferingContext = useContext3(Internals5.BufferingContextReact);
592
639
  if (!bufferingContext) {
593
640
  throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
594
641
  }
595
- const { buffering } = bufferingContext;
642
+ const getCurrentFrame = useCallback(() => {
643
+ if (!video) {
644
+ return fallbackFrame.current ?? (typeof window === "undefined" ? 0 : window.remotion_initialFrame ?? 0);
645
+ }
646
+ const unclamped = timelineImperativeContext.frameRef.current[video.id] ?? (environment.isPlayer ? 0 : Internals5.Timeline.getFrameForComposition(video.id));
647
+ return Internals5.Timeline.clampFrameToCompositionRange(unclamped, video.durationInFrames);
648
+ }, [environment.isPlayer, timelineImperativeContext, video]);
596
649
  const seek = useCallback((newFrame) => {
597
- const frameToSeekTo = config ? Internals4.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames) : Math.max(0, newFrame);
650
+ const frameToSeekTo = config ? Internals5.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames) : Math.max(0, newFrame);
651
+ fallbackFrame.current = frameToSeekTo;
598
652
  if (video?.id) {
599
- setTimelinePosition((c) => c[video.id] === frameToSeekTo ? c : { ...c, [video.id]: frameToSeekTo });
653
+ if (timelineImperativeContext.frameRef.current[video.id] !== frameToSeekTo) {
654
+ timelineImperativeContext.frameRef.current = {
655
+ ...timelineImperativeContext.frameRef.current,
656
+ [video.id]: frameToSeekTo
657
+ };
658
+ }
659
+ setTimelinePosition((currentFrames) => currentFrames[video.id] === frameToSeekTo ? currentFrames : { ...currentFrames, [video.id]: frameToSeekTo });
600
660
  }
601
- frameRef.current = frameToSeekTo;
602
661
  emitter.dispatchSeek(frameToSeekTo);
603
- }, [config, emitter, setTimelinePosition, video?.id]);
662
+ }, [
663
+ config,
664
+ emitter,
665
+ setTimelinePosition,
666
+ timelineImperativeContext,
667
+ video?.id
668
+ ]);
604
669
  const play = useCallback((e) => {
605
- if (imperativePlaying.current) {
670
+ if (timelineImperativeContext.imperativePlaying.current) {
606
671
  return;
607
672
  }
608
- setHasPlayed(true);
609
- if (isLastFrame) {
673
+ const lastFrameForPlayback = (config?.durationInFrames ?? 1) - 1;
674
+ if (getCurrentFrame() === lastFrameForPlayback) {
610
675
  seek(0);
611
676
  }
612
677
  audioContext?.resume();
613
678
  if (audioTagsContext && audioTagsContext.numberOfAudioTags > 0 && e) {
614
679
  audioTagsContext.playAllAudios();
615
680
  }
616
- audioAndVideoTags.current.forEach((a) => a.play("player play() was called and playing audio from a click"));
617
- imperativePlaying.current = true;
681
+ timelineImperativeContext.audioAndVideoTags.current.forEach((tag) => tag.play("player play() was called and playing audio from a click"));
682
+ timelineImperativeContext.imperativePlaying.current = true;
618
683
  setPlaying(true);
619
- playStart.current = frameRef.current;
684
+ playStart.current = getCurrentFrame();
620
685
  emitter.dispatchPlay();
621
686
  }, [
622
- imperativePlaying,
623
- isLastFrame,
624
687
  audioContext,
625
688
  audioTagsContext,
626
- setPlaying,
689
+ config?.durationInFrames,
627
690
  emitter,
691
+ getCurrentFrame,
628
692
  seek,
629
- audioAndVideoTags
693
+ setPlaying,
694
+ timelineImperativeContext
630
695
  ]);
631
696
  const pause = useCallback(() => {
632
- if (imperativePlaying.current) {
633
- imperativePlaying.current = false;
697
+ if (timelineImperativeContext.imperativePlaying.current) {
698
+ timelineImperativeContext.imperativePlaying.current = false;
634
699
  setPlaying(false);
635
700
  emitter.dispatchPause();
636
701
  audioContext?.suspend();
637
702
  }
638
- }, [emitter, imperativePlaying, setPlaying, audioContext]);
703
+ }, [audioContext, emitter, setPlaying, timelineImperativeContext]);
639
704
  const pauseAndReturnToPlayStart = useCallback(() => {
640
- if (imperativePlaying.current) {
641
- imperativePlaying.current = false;
642
- frameRef.current = playStart.current;
705
+ if (timelineImperativeContext.imperativePlaying.current) {
706
+ timelineImperativeContext.imperativePlaying.current = false;
707
+ fallbackFrame.current = playStart.current;
643
708
  if (config) {
644
- setTimelinePosition((c) => ({
645
- ...c,
709
+ timelineImperativeContext.frameRef.current = {
710
+ ...timelineImperativeContext.frameRef.current,
711
+ [config.id]: playStart.current
712
+ };
713
+ setTimelinePosition((currentFrames) => ({
714
+ ...currentFrames,
646
715
  [config.id]: playStart.current
647
716
  }));
648
717
  setPlaying(false);
649
718
  emitter.dispatchPause();
650
719
  }
651
720
  }
652
- }, [config, emitter, imperativePlaying, setPlaying, setTimelinePosition]);
721
+ }, [
722
+ config,
723
+ emitter,
724
+ setPlaying,
725
+ setTimelinePosition,
726
+ timelineImperativeContext
727
+ ]);
653
728
  const videoId = video?.id;
729
+ const lastFrame = (config?.durationInFrames ?? 1) - 1;
654
730
  const frameBack = useCallback((frames) => {
655
731
  if (!videoId) {
656
732
  return null;
657
733
  }
658
- if (imperativePlaying.current) {
734
+ if (timelineImperativeContext.imperativePlaying.current) {
659
735
  return;
660
736
  }
661
- setFrame((c) => {
662
- const prevFrame = c[videoId] ?? window.remotion_initialFrame ?? 0;
663
- const newFrame = Math.max(0, prevFrame - frames);
664
- if (prevFrame === newFrame) {
665
- return c;
666
- }
667
- return {
668
- ...c,
669
- [videoId]: newFrame
670
- };
671
- });
672
- }, [imperativePlaying, setFrame, videoId]);
737
+ const previousFrame = timelineImperativeContext.frameRef.current[videoId] ?? window.remotion_initialFrame ?? 0;
738
+ const newFrame = Math.max(0, previousFrame - frames);
739
+ if (previousFrame === newFrame) {
740
+ return;
741
+ }
742
+ timelineImperativeContext.frameRef.current = {
743
+ ...timelineImperativeContext.frameRef.current,
744
+ [videoId]: newFrame
745
+ };
746
+ setFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
747
+ }, [setFrame, timelineImperativeContext, videoId]);
673
748
  const frameForward = useCallback((frames) => {
674
749
  if (!videoId) {
675
750
  return null;
676
751
  }
677
- if (imperativePlaying.current) {
752
+ if (timelineImperativeContext.imperativePlaying.current) {
678
753
  return;
679
754
  }
680
- setFrame((c) => {
681
- const prevFrame = c[videoId] ?? window.remotion_initialFrame ?? 0;
682
- const newFrame = Math.min(lastFrame, prevFrame + frames);
683
- if (prevFrame === newFrame) {
684
- return c;
685
- }
686
- return {
687
- ...c,
688
- [videoId]: newFrame
689
- };
690
- });
691
- }, [videoId, imperativePlaying, lastFrame, setFrame]);
755
+ const previousFrame = timelineImperativeContext.frameRef.current[videoId] ?? window.remotion_initialFrame ?? 0;
756
+ const newFrame = Math.min(lastFrame, previousFrame + frames);
757
+ if (previousFrame === newFrame) {
758
+ return;
759
+ }
760
+ timelineImperativeContext.frameRef.current = {
761
+ ...timelineImperativeContext.frameRef.current,
762
+ [videoId]: newFrame
763
+ };
764
+ setFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
765
+ }, [lastFrame, setFrame, timelineImperativeContext, videoId]);
692
766
  const toggle = useCallback((e) => {
693
- if (imperativePlaying.current) {
767
+ if (timelineImperativeContext.imperativePlaying.current) {
694
768
  pause();
695
769
  } else {
696
770
  play(e);
697
771
  }
698
- }, [imperativePlaying, pause, play]);
772
+ }, [pause, play, timelineImperativeContext]);
699
773
  const isPlaying = useCallback(() => {
700
- return imperativePlaying.current;
701
- }, [imperativePlaying]);
702
- const getCurrentFrame = useCallback(() => {
703
- return frameRef.current;
704
- }, [frameRef]);
774
+ return timelineImperativeContext.imperativePlaying.current;
775
+ }, [timelineImperativeContext]);
705
776
  const isBuffering = useCallback(() => {
706
- return buffering.current;
707
- }, [buffering]);
708
- const returnValue = useMemo(() => {
777
+ return bufferingContext.buffering.current;
778
+ }, [bufferingContext.buffering]);
779
+ return useMemo2(() => {
709
780
  return {
710
781
  frameBack,
711
782
  frameForward,
712
- isLastFrame,
713
783
  emitter,
714
- playing,
715
784
  play,
716
785
  pause,
717
786
  seek,
718
- isFirstFrame,
719
787
  getCurrentFrame,
720
788
  isPlaying,
721
789
  isBuffering,
722
790
  pauseAndReturnToPlayStart,
723
- hasPlayed,
724
791
  toggle
725
792
  };
726
793
  }, [
727
794
  emitter,
728
795
  frameBack,
729
796
  frameForward,
730
- hasPlayed,
731
- isFirstFrame,
732
- isLastFrame,
733
797
  getCurrentFrame,
798
+ isBuffering,
799
+ isPlaying,
734
800
  pause,
735
801
  pauseAndReturnToPlayStart,
736
802
  play,
737
- playing,
738
803
  seek,
739
- toggle,
740
- isPlaying,
741
- isBuffering
804
+ toggle
742
805
  ]);
743
- return returnValue;
744
806
  };
745
807
 
746
808
  // src/browser-mediasession.ts
@@ -749,8 +811,9 @@ var useBrowserMediaSession = ({
749
811
  videoConfig,
750
812
  playbackRate
751
813
  }) => {
752
- const { playing, pause, play, emitter, getCurrentFrame, seek } = usePlayer();
753
- const hasEverPlayed = useRef2(false);
814
+ const [playing] = Internals6.Timeline.usePlayingState();
815
+ const { pause, play, emitter, getCurrentFrame, seek } = usePlayerMethods();
816
+ const hasEverPlayed = useRef3(false);
754
817
  useEffect3(() => {
755
818
  if (playing) {
756
819
  hasEverPlayed.current = true;
@@ -889,7 +952,7 @@ var calculateNextFrame = ({
889
952
  };
890
953
 
891
954
  // src/is-backgrounded.ts
892
- import { useEffect as useEffect4, useRef as useRef3 } from "react";
955
+ import { useEffect as useEffect4, useRef as useRef4 } from "react";
893
956
  var getIsBackgrounded = () => {
894
957
  if (typeof document === "undefined") {
895
958
  return false;
@@ -897,7 +960,7 @@ var getIsBackgrounded = () => {
897
960
  return document.visibilityState === "hidden";
898
961
  };
899
962
  var useIsBackgrounded = () => {
900
- const isBackgrounded = useRef3(getIsBackgrounded());
963
+ const isBackgrounded = useRef4(getIsBackgrounded());
901
964
  useEffect4(() => {
902
965
  const onVisibilityChange = () => {
903
966
  isBackgrounded.current = getIsBackgrounded();
@@ -911,7 +974,7 @@ var useIsBackgrounded = () => {
911
974
  };
912
975
 
913
976
  // src/set-global-time-anchor.ts
914
- import { Internals as Internals5 } from "remotion";
977
+ import { Internals as Internals7 } from "remotion";
915
978
  var ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
916
979
  var setGlobalTimeAnchor = ({
917
980
  audioContext,
@@ -932,7 +995,7 @@ var setGlobalTimeAnchor = ({
932
995
  if (Math.abs(shift) < Number.EPSILON) {
933
996
  return false;
934
997
  }
935
- Internals5.Log.verbose({ logLevel, tag: "audio-scheduling" }, "Anchor " + (force ? "forcibly " : "") + "changed from %s to %s with shift %s", audioSyncAnchor.value, newAnchor, shift);
998
+ Internals7.Log.verbose({ logLevel, tag: "audio-scheduling" }, "Anchor " + (force ? "forcibly " : "") + "changed from %s to %s with shift %s", audioSyncAnchor.value, newAnchor, shift);
936
999
  audioSyncAnchor.value = newAnchor;
937
1000
  return true;
938
1001
  };
@@ -957,15 +1020,17 @@ var usePlayback = ({
957
1020
  getCurrentFrame,
958
1021
  muted
959
1022
  }) => {
960
- const config = Internals6.useUnsafeVideoConfig();
961
- const frame = Internals6.Timeline.useTimelinePosition();
962
- const { playing, pause, emitter, isPlaying } = usePlayer();
963
- const setFrame = Internals6.Timeline.useTimelineSetFrame();
964
- const sharedAudioContext = useContext4(Internals6.SharedAudioContext);
965
- const logLevel = Internals6.useLogLevel();
1023
+ const config = Internals8.useUnsafeVideoConfig();
1024
+ const frame = Internals8.Timeline.useTimelinePosition();
1025
+ const [playing] = Internals8.Timeline.usePlayingState();
1026
+ const { pause, emitter, isPlaying } = usePlayerMethods();
1027
+ const setFrame = Internals8.Timeline.useTimelineSetFrame();
1028
+ const sharedAudioContext = useContext4(Internals8.SharedAudioContext);
1029
+ const { setPlayerMuted } = useContext4(Internals8.SetMediaVolumeContext);
1030
+ const logLevel = Internals8.useLogLevel();
966
1031
  const isBackgroundedRef = useIsBackgrounded();
967
- const lastTimeUpdateTimestamp = useRef4(0);
968
- const context = useContext4(Internals6.BufferingContextReact);
1032
+ const lastTimeUpdateTimestamp = useRef5(0);
1033
+ const context = useContext4(Internals8.BufferingContextReact);
969
1034
  if (!context) {
970
1035
  throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
971
1036
  }
@@ -1044,6 +1109,7 @@ var usePlayback = ({
1044
1109
  return;
1045
1110
  }
1046
1111
  let hasBeenStopped = false;
1112
+ let audioContextFailed = false;
1047
1113
  let reqAnimFrameCall = null;
1048
1114
  let startedTime = performance.now();
1049
1115
  let framesAdvanced = 0;
@@ -1068,7 +1134,7 @@ var usePlayback = ({
1068
1134
  sharedAudioContext?.suspend?.();
1069
1135
  return;
1070
1136
  }
1071
- if (!muted && !context.buffering.current) {
1137
+ if (!muted && !audioContextFailed && !context.buffering.current) {
1072
1138
  sharedAudioContext?.resume?.();
1073
1139
  }
1074
1140
  const time = performance.now() - startedTime;
@@ -1098,9 +1164,20 @@ var usePlayback = ({
1098
1164
  queueNextFrame();
1099
1165
  };
1100
1166
  const queueNextFrame = () => {
1101
- const getIsResumingAudioContext = sharedAudioContext?.getIsResumingAudioContext?.() ?? null;
1167
+ if (hasBeenStopped) {
1168
+ return;
1169
+ }
1170
+ const getIsResumingAudioContext = audioContextFailed ? null : sharedAudioContext?.getIsResumingAudioContext?.() ?? null;
1102
1171
  if (getIsResumingAudioContext !== null && !muted) {
1103
- getIsResumingAudioContext.then(() => {
1172
+ getIsResumingAudioContext.then((result) => {
1173
+ if (hasBeenStopped) {
1174
+ return;
1175
+ }
1176
+ if (result === "failed") {
1177
+ audioContextFailed = true;
1178
+ sharedAudioContext?.suspend();
1179
+ setPlayerMuted(true);
1180
+ }
1104
1181
  startedTime = performance.now();
1105
1182
  framesAdvanced = 0;
1106
1183
  queueNextFrame();
@@ -1108,7 +1185,7 @@ var usePlayback = ({
1108
1185
  return;
1109
1186
  }
1110
1187
  if (context.buffering.current) {
1111
- if (!muted) {
1188
+ if (!muted && !audioContextFailed) {
1112
1189
  sharedAudioContext?.suspend?.();
1113
1190
  }
1114
1191
  const stopListening = context.listenForResume(() => {
@@ -1157,6 +1234,7 @@ var usePlayback = ({
1157
1234
  context,
1158
1235
  isPlaying,
1159
1236
  sharedAudioContext,
1237
+ setPlayerMuted,
1160
1238
  logLevel,
1161
1239
  muted
1162
1240
  ]);
@@ -1180,7 +1258,7 @@ var usePlayback = ({
1180
1258
  };
1181
1259
 
1182
1260
  // src/utils/use-element-size.ts
1183
- import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useState as useState4 } from "react";
1261
+ import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo3, useState as useState3 } from "react";
1184
1262
  var elementSizeHooks = [];
1185
1263
  var updateAllElementsSizes = () => {
1186
1264
  for (const listener of elementSizeHooks) {
@@ -1197,7 +1275,7 @@ var getElement = (source) => {
1197
1275
  return source;
1198
1276
  };
1199
1277
  var useElementSize = (source, options) => {
1200
- const [size, setSize] = useState4(() => {
1278
+ const [size, setSize] = useState3(() => {
1201
1279
  const element = getElement(source);
1202
1280
  if (!element) {
1203
1281
  return null;
@@ -1217,7 +1295,7 @@ var useElementSize = (source, options) => {
1217
1295
  }
1218
1296
  };
1219
1297
  });
1220
- const observer = useMemo2(() => {
1298
+ const observer = useMemo3(() => {
1221
1299
  if (typeof ResizeObserver === "undefined") {
1222
1300
  return null;
1223
1301
  }
@@ -1309,7 +1387,7 @@ var useElementSize = (source, options) => {
1309
1387
  elementSizeHooks = elementSizeHooks.filter((e) => e !== updateSize);
1310
1388
  };
1311
1389
  }, [updateSize]);
1312
- return useMemo2(() => {
1390
+ return useMemo3(() => {
1313
1391
  if (!size) {
1314
1392
  return null;
1315
1393
  }
@@ -1323,11 +1401,11 @@ import {
1323
1401
  useEffect as useEffect13,
1324
1402
  useImperativeHandle as useImperativeHandle2,
1325
1403
  useLayoutEffect as useLayoutEffect3,
1326
- useMemo as useMemo14,
1327
- useRef as useRef12,
1328
- useState as useState13
1404
+ useMemo as useMemo15,
1405
+ useRef as useRef13,
1406
+ useState as useState12
1329
1407
  } from "react";
1330
- import { Composition, Internals as Internals15 } from "remotion";
1408
+ import { Composition, Internals as Internals17 } from "remotion";
1331
1409
 
1332
1410
  // src/player-css-classname.ts
1333
1411
  var playerCssClassname = (override) => {
@@ -1335,22 +1413,22 @@ var playerCssClassname = (override) => {
1335
1413
  };
1336
1414
 
1337
1415
  // src/PlayerUI.tsx
1338
- import React10, {
1416
+ import React11, {
1339
1417
  Suspense,
1340
1418
  forwardRef,
1341
1419
  useCallback as useCallback10,
1342
1420
  useContext as useContext5,
1343
1421
  useEffect as useEffect12,
1344
1422
  useImperativeHandle,
1345
- useMemo as useMemo12,
1346
- useRef as useRef10,
1347
- useState as useState11
1423
+ useMemo as useMemo13,
1424
+ useRef as useRef11,
1425
+ useState as useState10
1348
1426
  } from "react";
1349
- import { Internals as Internals11 } from "remotion";
1427
+ import { Internals as Internals13 } from "remotion";
1350
1428
 
1351
1429
  // src/error-boundary.tsx
1352
- import React3 from "react";
1353
- import { jsx as jsx4 } from "react/jsx-runtime";
1430
+ import React4 from "react";
1431
+ import { jsx as jsx5 } from "react/jsx-runtime";
1354
1432
  var errorStyle = {
1355
1433
  display: "flex",
1356
1434
  justifyContent: "center",
@@ -1360,7 +1438,7 @@ var errorStyle = {
1360
1438
  width: "100%"
1361
1439
  };
1362
1440
 
1363
- class ErrorBoundary extends React3.Component {
1441
+ class ErrorBoundary extends React4.Component {
1364
1442
  state = { hasError: null };
1365
1443
  static getDerivedStateFromError(error) {
1366
1444
  return { hasError: error };
@@ -1370,7 +1448,7 @@ class ErrorBoundary extends React3.Component {
1370
1448
  }
1371
1449
  render() {
1372
1450
  if (this.state.hasError) {
1373
- return /* @__PURE__ */ jsx4("div", {
1451
+ return /* @__PURE__ */ jsx5("div", {
1374
1452
  style: errorStyle,
1375
1453
  children: this.props.errorFallback({
1376
1454
  error: this.state.hasError
@@ -1382,8 +1460,8 @@ class ErrorBoundary extends React3.Component {
1382
1460
  }
1383
1461
 
1384
1462
  // src/license-blacklist.tsx
1385
- import React4, { useEffect as useEffect7 } from "react";
1386
- import { jsx as jsx5 } from "react/jsx-runtime";
1463
+ import React5, { useEffect as useEffect7 } from "react";
1464
+ import { jsx as jsx6 } from "react/jsx-runtime";
1387
1465
  var getHashOfDomain = async () => {
1388
1466
  if (typeof window === "undefined") {
1389
1467
  return null;
@@ -1417,7 +1495,7 @@ var DOMAIN_BLACKLIST = [
1417
1495
  ];
1418
1496
  var ran = false;
1419
1497
  var RenderWarningIfBlacklist = () => {
1420
- const [unlicensed, setUnlicensed] = React4.useState(false);
1498
+ const [unlicensed, setUnlicensed] = React5.useState(false);
1421
1499
  useEffect7(() => {
1422
1500
  if (ran) {
1423
1501
  return;
@@ -1459,10 +1537,10 @@ var RenderWarningIfBlacklist = () => {
1459
1537
  if (!unlicensed) {
1460
1538
  return null;
1461
1539
  }
1462
- return /* @__PURE__ */ jsx5("div", {
1540
+ return /* @__PURE__ */ jsx6("div", {
1463
1541
  style,
1464
1542
  className: "warning-banner",
1465
- children: /* @__PURE__ */ jsx5("a", {
1543
+ children: /* @__PURE__ */ jsx6("a", {
1466
1544
  style: { color: "white" },
1467
1545
  href: "https://github.com/remotion-dev/remotion/pull/4589",
1468
1546
  children: "Remotion Unlicensed – Contact hi@remotion.dev"
@@ -1471,30 +1549,30 @@ var RenderWarningIfBlacklist = () => {
1471
1549
  };
1472
1550
 
1473
1551
  // src/PlayerControls.tsx
1474
- import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo9, useRef as useRef8, useState as useState10 } from "react";
1552
+ import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo10, useRef as useRef9, useState as useState9 } from "react";
1475
1553
 
1476
1554
  // src/DefaultPlayPauseButton.tsx
1477
- import { jsx as jsx6 } from "react/jsx-runtime";
1555
+ import { jsx as jsx7 } from "react/jsx-runtime";
1478
1556
  var DefaultPlayPauseButton = ({ playing, buffering }) => {
1479
1557
  if (playing && buffering) {
1480
- return /* @__PURE__ */ jsx6(BufferingIndicator, {
1558
+ return /* @__PURE__ */ jsx7(BufferingIndicator, {
1481
1559
  type: "player"
1482
1560
  });
1483
1561
  }
1484
1562
  if (playing) {
1485
- return /* @__PURE__ */ jsx6(PauseIcon, {});
1563
+ return /* @__PURE__ */ jsx7(PauseIcon, {});
1486
1564
  }
1487
- return /* @__PURE__ */ jsx6(PlayIcon, {});
1565
+ return /* @__PURE__ */ jsx7(PlayIcon, {});
1488
1566
  };
1489
1567
 
1490
1568
  // src/MediaVolumeSlider.tsx
1491
- import { useCallback as useCallback4, useMemo as useMemo4, useRef as useRef5, useState as useState6 } from "react";
1492
- import { Internals as Internals7 } from "remotion";
1569
+ import { useCallback as useCallback4, useMemo as useMemo5, useRef as useRef6, useState as useState5 } from "react";
1570
+ import { Internals as Internals9 } from "remotion";
1493
1571
 
1494
1572
  // src/render-volume-slider.tsx
1495
- import React5, { useCallback as useCallback3, useMemo as useMemo3, useState as useState5 } from "react";
1573
+ import React6, { useCallback as useCallback3, useMemo as useMemo4, useState as useState4 } from "react";
1496
1574
  import { random } from "remotion";
1497
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1575
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
1498
1576
  var KNOB_SIZE = 12;
1499
1577
  var BAR_HEIGHT = 5;
1500
1578
  var DefaultVolumeSlider = ({
@@ -1504,7 +1582,7 @@ var DefaultVolumeSlider = ({
1504
1582
  inputRef,
1505
1583
  setVolume
1506
1584
  }) => {
1507
- const sliderContainer = useMemo3(() => {
1585
+ const sliderContainer = useMemo4(() => {
1508
1586
  const paddingLeft = 5;
1509
1587
  const common = {
1510
1588
  paddingLeft,
@@ -1524,12 +1602,12 @@ var DefaultVolumeSlider = ({
1524
1602
  ...common
1525
1603
  };
1526
1604
  }, [isVertical]);
1527
- const randomId = typeof React5.useId === "undefined" ? "volume-slider" : React5.useId();
1528
- const [randomClass] = useState5(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
1605
+ const randomId = typeof React6.useId === "undefined" ? "volume-slider" : React6.useId();
1606
+ const [randomClass] = useState4(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
1529
1607
  const onVolumeChange = useCallback3((e) => {
1530
1608
  setVolume(parseFloat(e.target.value));
1531
1609
  }, [setVolume]);
1532
- const inputStyle = useMemo3(() => {
1610
+ const inputStyle = useMemo4(() => {
1533
1611
  const commonStyle = {
1534
1612
  WebkitAppearance: "none",
1535
1613
  backgroundColor: "rgba(255, 255, 255, 0.5)",
@@ -1572,12 +1650,12 @@ var DefaultVolumeSlider = ({
1572
1650
  return /* @__PURE__ */ jsxs3("div", {
1573
1651
  style: sliderContainer,
1574
1652
  children: [
1575
- /* @__PURE__ */ jsx7("style", {
1653
+ /* @__PURE__ */ jsx8("style", {
1576
1654
  dangerouslySetInnerHTML: {
1577
1655
  __html: sliderStyle
1578
1656
  }
1579
1657
  }),
1580
- /* @__PURE__ */ jsx7("input", {
1658
+ /* @__PURE__ */ jsx8("input", {
1581
1659
  ref: inputRef,
1582
1660
  "aria-label": "Change volume",
1583
1661
  className: randomClass,
@@ -1594,20 +1672,20 @@ var DefaultVolumeSlider = ({
1594
1672
  });
1595
1673
  };
1596
1674
  var renderDefaultVolumeSlider = (props) => {
1597
- return /* @__PURE__ */ jsx7(DefaultVolumeSlider, {
1675
+ return /* @__PURE__ */ jsx8(DefaultVolumeSlider, {
1598
1676
  ...props
1599
1677
  });
1600
1678
  };
1601
1679
 
1602
1680
  // src/MediaVolumeSlider.tsx
1603
- import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1681
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
1604
1682
  var VOLUME_SLIDER_WIDTH = 100;
1605
1683
  var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, renderVolumeSlider }) => {
1606
- const [playerMuted, setPlayerMuted] = Internals7.usePlayerMutedState();
1607
- const [mediaVolume, setMediaVolume] = Internals7.useMediaVolumeState();
1608
- const [focused, setFocused] = useState6(false);
1609
- const parentDivRef = useRef5(null);
1610
- const inputRef = useRef5(null);
1684
+ const [playerMuted, setPlayerMuted] = Internals9.usePlayerMutedState();
1685
+ const [mediaVolume, setMediaVolume] = Internals9.useMediaVolumeState();
1686
+ const [focused, setFocused] = useState5(false);
1687
+ const parentDivRef = useRef6(null);
1688
+ const inputRef = useRef6(null);
1611
1689
  const hover = useHoverState(parentDivRef, false);
1612
1690
  const onBlur = useCallback4(() => {
1613
1691
  setTimeout(() => {
@@ -1625,7 +1703,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1625
1703
  }
1626
1704
  setPlayerMuted((mute) => !mute);
1627
1705
  }, [isVolume0, setPlayerMuted, setMediaVolume]);
1628
- const parentDivStyle = useMemo4(() => {
1706
+ const parentDivStyle = useMemo5(() => {
1629
1707
  return {
1630
1708
  display: "inline-flex",
1631
1709
  background: "none",
@@ -1636,7 +1714,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1636
1714
  ...displayVerticalVolumeSlider && { position: "relative" }
1637
1715
  };
1638
1716
  }, [displayVerticalVolumeSlider]);
1639
- const volumeContainer = useMemo4(() => {
1717
+ const volumeContainer = useMemo5(() => {
1640
1718
  return {
1641
1719
  display: "inline",
1642
1720
  width: ICON_SIZE,
@@ -1650,7 +1728,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1650
1728
  }, []);
1651
1729
  const renderDefaultMuteButton = useCallback4(({ muted, volume }) => {
1652
1730
  const isMutedOrZero = muted || volume === 0;
1653
- return /* @__PURE__ */ jsx8("button", {
1731
+ return /* @__PURE__ */ jsx9("button", {
1654
1732
  "aria-label": isMutedOrZero ? "Unmute sound" : "Mute sound",
1655
1733
  title: isMutedOrZero ? "Unmute sound" : "Mute sound",
1656
1734
  onClick,
@@ -1658,14 +1736,14 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1658
1736
  onFocus: () => setFocused(true),
1659
1737
  style: volumeContainer,
1660
1738
  type: "button",
1661
- children: isMutedOrZero ? /* @__PURE__ */ jsx8(VolumeOffIcon, {}) : /* @__PURE__ */ jsx8(VolumeOnIcon, {})
1739
+ children: isMutedOrZero ? /* @__PURE__ */ jsx9(VolumeOffIcon, {}) : /* @__PURE__ */ jsx9(VolumeOnIcon, {})
1662
1740
  });
1663
1741
  }, [onBlur, onClick, volumeContainer]);
1664
- const muteButton = useMemo4(() => {
1742
+ const muteButton = useMemo5(() => {
1665
1743
  return renderMuteButton ? renderMuteButton({ muted: playerMuted, volume: mediaVolume }) : renderDefaultMuteButton({ muted: playerMuted, volume: mediaVolume });
1666
1744
  }, [playerMuted, mediaVolume, renderDefaultMuteButton, renderMuteButton]);
1667
- const volumeSlider = useMemo4(() => {
1668
- return (focused || hover) && !playerMuted && !Internals7.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
1745
+ const volumeSlider = useMemo5(() => {
1746
+ return (focused || hover) && !playerMuted && !Internals9.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
1669
1747
  isVertical: displayVerticalVolumeSlider,
1670
1748
  volume: mediaVolume,
1671
1749
  onBlur: () => setFocused(false),
@@ -1692,14 +1770,14 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1692
1770
  };
1693
1771
 
1694
1772
  // src/PlaybackrateControl.tsx
1695
- import { useCallback as useCallback5, useEffect as useEffect9, useMemo as useMemo5, useState as useState8 } from "react";
1696
- import { Internals as Internals8 } from "remotion";
1773
+ import { useCallback as useCallback5, useEffect as useEffect9, useMemo as useMemo6, useState as useState7 } from "react";
1774
+ import { Internals as Internals10 } from "remotion";
1697
1775
 
1698
1776
  // src/utils/use-component-visible.ts
1699
- import { useEffect as useEffect8, useRef as useRef6, useState as useState7 } from "react";
1777
+ import { useEffect as useEffect8, useRef as useRef7, useState as useState6 } from "react";
1700
1778
  function useComponentVisible(initialIsVisible) {
1701
- const [isComponentVisible, setIsComponentVisible] = useState7(initialIsVisible);
1702
- const ref = useRef6(null);
1779
+ const [isComponentVisible, setIsComponentVisible] = useState6(initialIsVisible);
1780
+ const ref = useRef7(null);
1703
1781
  useEffect8(() => {
1704
1782
  const handleClickOutside = (event) => {
1705
1783
  if (ref.current && !ref.current.contains(event.target)) {
@@ -1715,7 +1793,7 @@ function useComponentVisible(initialIsVisible) {
1715
1793
  }
1716
1794
 
1717
1795
  // src/PlaybackrateControl.tsx
1718
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1796
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1719
1797
  var BOTTOM = 35;
1720
1798
  var THRESHOLD = 70;
1721
1799
  var rateDiv = {
@@ -1736,10 +1814,10 @@ var checkmarkStyle = {
1736
1814
  height: 14,
1737
1815
  color: "black"
1738
1816
  };
1739
- var Checkmark = () => /* @__PURE__ */ jsx9("svg", {
1817
+ var Checkmark = () => /* @__PURE__ */ jsx10("svg", {
1740
1818
  viewBox: "0 0 512 512",
1741
1819
  style: checkmarkStyle,
1742
- children: /* @__PURE__ */ jsx9("path", {
1820
+ children: /* @__PURE__ */ jsx10("path", {
1743
1821
  fill: "currentColor",
1744
1822
  d: "M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"
1745
1823
  })
@@ -1754,7 +1832,7 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1754
1832
  e.preventDefault();
1755
1833
  onSelect(rate);
1756
1834
  }, [onSelect, rate]);
1757
- const [hovered, setHovered] = useState8(false);
1835
+ const [hovered, setHovered] = useState7(false);
1758
1836
  const onMouseEnter = useCallback5(() => {
1759
1837
  setHovered(true);
1760
1838
  }, []);
@@ -1762,7 +1840,7 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1762
1840
  setHovered(false);
1763
1841
  }, []);
1764
1842
  const isFocused = keyboardSelectedRate === rate;
1765
- const actualStyle = useMemo5(() => {
1843
+ const actualStyle = useMemo6(() => {
1766
1844
  return {
1767
1845
  ...rateDiv,
1768
1846
  backgroundColor: hovered || isFocused ? "#eee" : "transparent"
@@ -1775,9 +1853,9 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1775
1853
  style: actualStyle,
1776
1854
  onClick,
1777
1855
  children: [
1778
- /* @__PURE__ */ jsx9("div", {
1856
+ /* @__PURE__ */ jsx10("div", {
1779
1857
  style: checkmarkContainer,
1780
- children: rate === selectedRate ? /* @__PURE__ */ jsx9(Checkmark, {}) : null
1858
+ children: rate === selectedRate ? /* @__PURE__ */ jsx10(Checkmark, {}) : null
1781
1859
  }),
1782
1860
  formatPlaybackRate(rate),
1783
1861
  "x"
@@ -1785,8 +1863,8 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1785
1863
  }, rate);
1786
1864
  };
1787
1865
  var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1788
- const { setPlaybackRate, playbackRate } = Internals8.usePlaybackRate();
1789
- const [keyboardSelectedRate, setKeyboardSelectedRate] = useState8(playbackRate);
1866
+ const { setPlaybackRate, playbackRate } = Internals10.usePlaybackRate();
1867
+ const [keyboardSelectedRate, setKeyboardSelectedRate] = useState7(playbackRate);
1790
1868
  useEffect9(() => {
1791
1869
  const listener = (e) => {
1792
1870
  e.preventDefault();
@@ -1829,7 +1907,7 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1829
1907
  setPlaybackRate(rate);
1830
1908
  setIsComponentVisible(false);
1831
1909
  }, [setIsComponentVisible, setPlaybackRate]);
1832
- const playbackPopup = useMemo5(() => {
1910
+ const playbackPopup = useMemo6(() => {
1833
1911
  return {
1834
1912
  position: "absolute",
1835
1913
  right: 0,
@@ -1843,10 +1921,10 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1843
1921
  textAlign: "left"
1844
1922
  };
1845
1923
  }, [canvasSize.height]);
1846
- return /* @__PURE__ */ jsx9("div", {
1924
+ return /* @__PURE__ */ jsx10("div", {
1847
1925
  style: playbackPopup,
1848
1926
  children: playbackRates.map((rate) => {
1849
- return /* @__PURE__ */ jsx9(PlaybackrateOption, {
1927
+ return /* @__PURE__ */ jsx10(PlaybackrateOption, {
1850
1928
  selectedRate: playbackRate,
1851
1929
  onSelect,
1852
1930
  rate,
@@ -1887,13 +1965,13 @@ var button = {
1887
1965
  };
1888
1966
  var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1889
1967
  const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false);
1890
- const { playbackRate } = Internals8.usePlaybackRate();
1968
+ const { playbackRate } = Internals10.usePlaybackRate();
1891
1969
  const onClick = useCallback5((e) => {
1892
1970
  e.stopPropagation();
1893
1971
  e.preventDefault();
1894
1972
  setIsComponentVisible((prevIsComponentVisible) => !prevIsComponentVisible);
1895
1973
  }, [setIsComponentVisible]);
1896
- return /* @__PURE__ */ jsx9("div", {
1974
+ return /* @__PURE__ */ jsx10("div", {
1897
1975
  ref,
1898
1976
  children: /* @__PURE__ */ jsxs5("button", {
1899
1977
  type: "button",
@@ -1908,7 +1986,7 @@ var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1908
1986
  "x"
1909
1987
  ]
1910
1988
  }),
1911
- isComponentVisible && /* @__PURE__ */ jsx9(PlaybackPopup, {
1989
+ isComponentVisible && /* @__PURE__ */ jsx10(PlaybackPopup, {
1912
1990
  canvasSize,
1913
1991
  playbackRates,
1914
1992
  setIsComponentVisible
@@ -1919,9 +1997,9 @@ var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1919
1997
  };
1920
1998
 
1921
1999
  // src/PlayerSeekBar.tsx
1922
- import { useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo6, useRef as useRef7, useState as useState9 } from "react";
1923
- import { Internals as Internals9, interpolate } from "remotion";
1924
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
2000
+ import { useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo7, useRef as useRef8, useState as useState8 } from "react";
2001
+ import { Internals as Internals11, interpolate } from "remotion";
2002
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1925
2003
  var getFrameFromX = (clientX, durationInFrames, width) => {
1926
2004
  const pos = clientX;
1927
2005
  const frame = Math.round(interpolate(pos, [0, width], [0, durationInFrames - 1], {
@@ -1957,15 +2035,15 @@ var findBodyInWhichDivIsLocated = (div) => {
1957
2035
  return current;
1958
2036
  };
1959
2037
  var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFrame }) => {
1960
- const containerRef = useRef7(null);
2038
+ const containerRef = useRef8(null);
1961
2039
  const barHovered = useHoverState(containerRef, false);
1962
2040
  const size = useElementSize(containerRef, {
1963
2041
  triggerOnWindowResize: true,
1964
2042
  shouldApplyCssTransforms: true
1965
2043
  });
1966
- const { seek, play, pause, playing } = usePlayer();
1967
- const frame = Internals9.Timeline.useTimelinePosition();
1968
- const [dragging, setDragging] = useState9({
2044
+ const { seek, play, pause, isPlaying } = usePlayerMethods();
2045
+ const frame = Internals11.Timeline.useTimelinePosition();
2046
+ const [dragging, setDragging] = useState8({
1969
2047
  dragging: false
1970
2048
  });
1971
2049
  const width = size?.width ?? 0;
@@ -1975,14 +2053,15 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
1975
2053
  }
1976
2054
  const posLeft = containerRef.current?.getBoundingClientRect().left;
1977
2055
  const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, width);
2056
+ const wasPlaying = isPlaying();
1978
2057
  pause();
1979
2058
  seek(_frame);
1980
2059
  setDragging({
1981
2060
  dragging: true,
1982
- wasPlaying: playing
2061
+ wasPlaying
1983
2062
  });
1984
2063
  onSeekStart();
1985
- }, [durationInFrames, width, pause, seek, playing, onSeekStart]);
2064
+ }, [durationInFrames, width, isPlaying, pause, seek, onSeekStart]);
1986
2065
  const onPointerMove = useCallback6((e) => {
1987
2066
  if (!size) {
1988
2067
  throw new Error("Player has no size");
@@ -2020,7 +2099,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2020
2099
  body.removeEventListener("pointerup", onPointerUp);
2021
2100
  };
2022
2101
  }, [dragging.dragging, onPointerMove, onPointerUp]);
2023
- const knobStyle = useMemo6(() => {
2102
+ const knobStyle = useMemo7(() => {
2024
2103
  return {
2025
2104
  height: KNOB_SIZE2,
2026
2105
  width: KNOB_SIZE2,
@@ -2033,7 +2112,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2033
2112
  opacity: Number(barHovered || dragging.dragging)
2034
2113
  };
2035
2114
  }, [barHovered, dragging.dragging, durationInFrames, frame, width]);
2036
- const fillStyle = useMemo6(() => {
2115
+ const fillStyle = useMemo7(() => {
2037
2116
  return {
2038
2117
  height: BAR_HEIGHT2,
2039
2118
  backgroundColor: "rgba(255, 255, 255, 1)",
@@ -2042,7 +2121,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2042
2121
  borderRadius: BAR_HEIGHT2 / 2
2043
2122
  };
2044
2123
  }, [durationInFrames, frame, inFrame, width]);
2045
- const active = useMemo6(() => {
2124
+ const active = useMemo7(() => {
2046
2125
  return {
2047
2126
  height: BAR_HEIGHT2,
2048
2127
  backgroundColor: "rgba(255, 255, 255, 0.25)",
@@ -2060,15 +2139,15 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2060
2139
  /* @__PURE__ */ jsxs6("div", {
2061
2140
  style: barBackground,
2062
2141
  children: [
2063
- /* @__PURE__ */ jsx10("div", {
2142
+ /* @__PURE__ */ jsx11("div", {
2064
2143
  style: active
2065
2144
  }),
2066
- /* @__PURE__ */ jsx10("div", {
2145
+ /* @__PURE__ */ jsx11("div", {
2067
2146
  style: fillStyle
2068
2147
  })
2069
2148
  ]
2070
2149
  }),
2071
- /* @__PURE__ */ jsx10("div", {
2150
+ /* @__PURE__ */ jsx11("div", {
2072
2151
  style: knobStyle
2073
2152
  })
2074
2153
  ]
@@ -2076,8 +2155,8 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2076
2155
  };
2077
2156
 
2078
2157
  // src/PlayerTimeLabel.tsx
2079
- import { useMemo as useMemo7 } from "react";
2080
- import { Internals as Internals10 } from "remotion";
2158
+ import { useMemo as useMemo8 } from "react";
2159
+ import { Internals as Internals12 } from "remotion";
2081
2160
 
2082
2161
  // src/format-time.ts
2083
2162
  var formatTime = (timeInSeconds) => {
@@ -2089,8 +2168,8 @@ var formatTime = (timeInSeconds) => {
2089
2168
  // src/PlayerTimeLabel.tsx
2090
2169
  import { jsxs as jsxs7 } from "react/jsx-runtime";
2091
2170
  var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
2092
- const frame = Internals10.Timeline.useTimelinePosition();
2093
- const timeLabel = useMemo7(() => {
2171
+ const frame = Internals12.Timeline.useTimelinePosition();
2172
+ const timeLabel = useMemo8(() => {
2094
2173
  return {
2095
2174
  color: "white",
2096
2175
  fontFamily: "sans-serif",
@@ -2113,14 +2192,14 @@ var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
2113
2192
  };
2114
2193
 
2115
2194
  // src/use-video-controls-resize.ts
2116
- import { useMemo as useMemo8 } from "react";
2195
+ import { useMemo as useMemo9 } from "react";
2117
2196
  var X_SPACER = 10;
2118
2197
  var X_PADDING = 12;
2119
2198
  var useVideoControlsResize = ({
2120
2199
  allowFullscreen: allowFullScreen,
2121
2200
  playerWidth
2122
2201
  }) => {
2123
- const resizeInfo = useMemo8(() => {
2202
+ const resizeInfo = useMemo9(() => {
2124
2203
  const playPauseIconSize = ICON_SIZE;
2125
2204
  const volumeIconSize = ICON_SIZE;
2126
2205
  const _fullscreenIconSize = allowFullScreen ? fullscreenIconSize : 0;
@@ -2140,7 +2219,7 @@ var useVideoControlsResize = ({
2140
2219
  };
2141
2220
 
2142
2221
  // src/PlayerControls.tsx
2143
- import { jsx as jsx11, jsxs as jsxs8, Fragment as Fragment2 } from "react/jsx-runtime";
2222
+ import { jsx as jsx12, jsxs as jsxs8, Fragment as Fragment2 } from "react/jsx-runtime";
2144
2223
  var gradientSteps = [
2145
2224
  0,
2146
2225
  0.013,
@@ -2249,14 +2328,14 @@ var Controls = ({
2249
2328
  toggle,
2250
2329
  renderCustomControls
2251
2330
  }) => {
2252
- const playButtonRef = useRef8(null);
2253
- const [supportsFullscreen, setSupportsFullscreen] = useState10(false);
2331
+ const playButtonRef = useRef9(null);
2332
+ const [supportsFullscreen, setSupportsFullscreen] = useState9(false);
2254
2333
  const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
2255
2334
  const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
2256
2335
  allowFullscreen,
2257
2336
  playerWidth: canvasSize?.width ?? 0
2258
2337
  });
2259
- const [shouldShowInitially, setInitiallyShowControls] = useState10(() => {
2338
+ const [shouldShowInitially, setInitiallyShowControls] = useState9(() => {
2260
2339
  if (typeof initiallyShowControls === "boolean") {
2261
2340
  return initiallyShowControls;
2262
2341
  }
@@ -2277,7 +2356,7 @@ var Controls = ({
2277
2356
  }
2278
2357
  throw new TypeError("initiallyShowControls must be a number or a boolean");
2279
2358
  });
2280
- const containerCss = useMemo9(() => {
2359
+ const containerCss = useMemo10(() => {
2281
2360
  const shouldShow = hovered || !playing || shouldShowInitially || alwaysShowControls;
2282
2361
  return {
2283
2362
  ...containerStyle2,
@@ -2306,7 +2385,7 @@ var Controls = ({
2306
2385
  clearInterval(timeout);
2307
2386
  };
2308
2387
  }, [shouldShowInitially]);
2309
- const playbackRates = useMemo9(() => {
2388
+ const playbackRates = useMemo10(() => {
2310
2389
  if (showPlaybackRateControl === true) {
2311
2390
  return [0.5, 0.8, 1, 1.2, 1.5, 1.8, 2, 2.5, 3];
2312
2391
  }
@@ -2324,8 +2403,8 @@ var Controls = ({
2324
2403
  return null;
2325
2404
  }, [showPlaybackRateControl]);
2326
2405
  const customControlsElement = renderCustomControls ? renderCustomControls() : null;
2327
- const ref = useRef8(null);
2328
- const flexRef = useRef8(null);
2406
+ const ref = useRef9(null);
2407
+ const flexRef = useRef9(null);
2329
2408
  const onPointerDownIfContainer = useCallback7((e) => {
2330
2409
  if (e.target === ref.current || e.target === flexRef.current) {
2331
2410
  onPointerDown?.(e);
@@ -2349,82 +2428,82 @@ var Controls = ({
2349
2428
  /* @__PURE__ */ jsxs8("div", {
2350
2429
  style: leftPartStyle,
2351
2430
  children: [
2352
- /* @__PURE__ */ jsx11("button", {
2431
+ /* @__PURE__ */ jsx12("button", {
2353
2432
  ref: playButtonRef,
2354
2433
  type: "button",
2355
2434
  style: playerButtonStyle,
2356
2435
  onClick: toggle,
2357
2436
  "aria-label": playing ? "Pause video" : "Play video",
2358
2437
  title: playing ? "Pause video" : "Play video",
2359
- children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
2438
+ children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx12(DefaultPlayPauseButton, {
2360
2439
  buffering,
2361
2440
  playing
2362
2441
  }) : renderPlayPauseButton({
2363
2442
  playing,
2364
2443
  isBuffering: buffering
2365
- }) ?? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
2444
+ }) ?? /* @__PURE__ */ jsx12(DefaultPlayPauseButton, {
2366
2445
  buffering,
2367
2446
  playing
2368
2447
  })
2369
2448
  }),
2370
2449
  showVolumeControls ? /* @__PURE__ */ jsxs8(Fragment2, {
2371
2450
  children: [
2372
- /* @__PURE__ */ jsx11("div", {
2451
+ /* @__PURE__ */ jsx12("div", {
2373
2452
  style: xSpacer
2374
2453
  }),
2375
- /* @__PURE__ */ jsx11(MediaVolumeSlider, {
2454
+ /* @__PURE__ */ jsx12(MediaVolumeSlider, {
2376
2455
  renderMuteButton,
2377
2456
  renderVolumeSlider,
2378
2457
  displayVerticalVolumeSlider
2379
2458
  })
2380
2459
  ]
2381
2460
  }) : null,
2382
- /* @__PURE__ */ jsx11("div", {
2461
+ /* @__PURE__ */ jsx12("div", {
2383
2462
  style: xSpacer
2384
2463
  }),
2385
- /* @__PURE__ */ jsx11(PlayerTimeLabel, {
2464
+ /* @__PURE__ */ jsx12(PlayerTimeLabel, {
2386
2465
  durationInFrames,
2387
2466
  fps,
2388
2467
  maxTimeLabelWidth
2389
2468
  }),
2390
- /* @__PURE__ */ jsx11("div", {
2469
+ /* @__PURE__ */ jsx12("div", {
2391
2470
  style: xSpacer
2392
2471
  })
2393
2472
  ]
2394
2473
  }),
2395
- /* @__PURE__ */ jsx11("div", {
2474
+ /* @__PURE__ */ jsx12("div", {
2396
2475
  style: flex1
2397
2476
  }),
2398
2477
  customControlsElement,
2399
- customControlsElement && playbackRates && canvasSize ? /* @__PURE__ */ jsx11("div", {
2478
+ customControlsElement && playbackRates && canvasSize ? /* @__PURE__ */ jsx12("div", {
2400
2479
  style: xSpacer
2401
2480
  }) : null,
2402
- playbackRates && canvasSize && /* @__PURE__ */ jsx11(PlaybackrateControl, {
2481
+ playbackRates && canvasSize && /* @__PURE__ */ jsx12(PlaybackrateControl, {
2403
2482
  canvasSize,
2404
2483
  playbackRates
2405
2484
  }),
2406
- playbackRates && supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("div", {
2485
+ playbackRates && supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx12("div", {
2407
2486
  style: xSpacer
2408
2487
  }) : null,
2409
- /* @__PURE__ */ jsx11("div", {
2488
+ /* @__PURE__ */ jsx12("div", {
2410
2489
  style: fullscreen,
2411
- children: supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("button", {
2490
+ children: supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx12("button", {
2412
2491
  type: "button",
2413
2492
  "aria-label": isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
2414
2493
  title: isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
2415
2494
  style: playerButtonStyle,
2416
2495
  onClick: isFullscreen ? onExitFullscreenButtonClick : onFullscreenButtonClick,
2417
- children: renderFullscreenButton === null ? /* @__PURE__ */ jsx11(FullscreenIcon, {
2496
+ children: renderFullscreenButton === null ? /* @__PURE__ */ jsx12(FullscreenIcon, {
2418
2497
  isFullscreen
2419
2498
  }) : renderFullscreenButton({ isFullscreen })
2420
2499
  }) : null
2421
2500
  })
2422
2501
  ]
2423
2502
  }),
2424
- /* @__PURE__ */ jsx11("div", {
2503
+ /* @__PURE__ */ jsx12("div", {
2425
2504
  style: ySpacer
2426
2505
  }),
2427
- /* @__PURE__ */ jsx11(PlayerSeekBar, {
2506
+ /* @__PURE__ */ jsx12(PlayerSeekBar, {
2428
2507
  onSeekEnd,
2429
2508
  onSeekStart,
2430
2509
  durationInFrames,
@@ -2439,7 +2518,7 @@ var Controls = ({
2439
2518
  var IS_NODE = typeof document === "undefined";
2440
2519
 
2441
2520
  // src/utils/use-click-prevention-on-double-click.ts
2442
- import { useCallback as useCallback9, useMemo as useMemo11 } from "react";
2521
+ import { useCallback as useCallback9, useMemo as useMemo12 } from "react";
2443
2522
 
2444
2523
  // src/utils/cancellable-promise.ts
2445
2524
  var cancellablePromise = (promise) => {
@@ -2467,9 +2546,9 @@ var cancellablePromise = (promise) => {
2467
2546
  var delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
2468
2547
 
2469
2548
  // src/utils/use-cancellable-promises.ts
2470
- import { useCallback as useCallback8, useMemo as useMemo10, useRef as useRef9 } from "react";
2549
+ import { useCallback as useCallback8, useMemo as useMemo11, useRef as useRef10 } from "react";
2471
2550
  var useCancellablePromises = () => {
2472
- const pendingPromises = useRef9([]);
2551
+ const pendingPromises = useRef10([]);
2473
2552
  const appendPendingPromise = useCallback8((promise) => {
2474
2553
  pendingPromises.current = [...pendingPromises.current, promise];
2475
2554
  }, []);
@@ -2477,7 +2556,7 @@ var useCancellablePromises = () => {
2477
2556
  pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
2478
2557
  }, []);
2479
2558
  const clearPendingPromises = useCallback8(() => pendingPromises.current.map((p) => p.cancel()), []);
2480
- const api = useMemo10(() => ({
2559
+ const api = useMemo11(() => ({
2481
2560
  appendPendingPromise,
2482
2561
  removePendingPromise,
2483
2562
  clearPendingPromises
@@ -2519,7 +2598,7 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
2519
2598
  api.clearPendingPromises();
2520
2599
  onDoubleClick();
2521
2600
  }, [api, onDoubleClick]);
2522
- const returnValue = useMemo11(() => {
2601
+ const returnValue = useMemo12(() => {
2523
2602
  if (!doubleClickToFullscreen) {
2524
2603
  return { handlePointerDown: onClick, handleDoubleClick: () => {
2525
2604
  return;
@@ -2531,8 +2610,8 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
2531
2610
  };
2532
2611
 
2533
2612
  // src/PlayerUI.tsx
2534
- import { jsx as jsx12, jsxs as jsxs9, Fragment as Fragment3 } from "react/jsx-runtime";
2535
- var reactVersion = React10.version.split(".")[0];
2613
+ import { jsx as jsx13, jsxs as jsxs9, Fragment as Fragment3 } from "react/jsx-runtime";
2614
+ var reactVersion = React11.version.split(".")[0];
2536
2615
  if (reactVersion === "0") {
2537
2616
  throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
2538
2617
  }
@@ -2577,26 +2656,35 @@ var PlayerUI = ({
2577
2656
  overrideInternalClassName,
2578
2657
  noSuspense
2579
2658
  }, ref) => {
2580
- const config = Internals11.useUnsafeVideoConfig();
2581
- const video = Internals11.useVideo();
2582
- const container = useRef10(null);
2659
+ const config = Internals13.useUnsafeVideoConfig();
2660
+ const video = Internals13.useVideo();
2661
+ const container = useRef11(null);
2583
2662
  const canvasSize = useElementSize(container, {
2584
2663
  triggerOnWindowResize: false,
2585
2664
  shouldApplyCssTransforms: false
2586
2665
  });
2587
- const [hasPausedToResume, setHasPausedToResume] = useState11(false);
2588
- const [shouldAutoplay, setShouldAutoPlay] = useState11(autoPlay);
2589
- const [isFullscreen, setIsFullscreen] = useState11(() => false);
2590
- const [seeking, setSeeking] = useState11(false);
2591
- const supportsFullScreen = useMemo12(() => {
2666
+ const [hasPausedToResume, setHasPausedToResume] = useState10(false);
2667
+ const [shouldAutoplay, setShouldAutoPlay] = useState10(autoPlay);
2668
+ const [isFullscreen, setIsFullscreen] = useState10(() => false);
2669
+ const [seeking, setSeeking] = useState10(false);
2670
+ const [hasPlayed, setHasPlayed] = useState10(false);
2671
+ const supportsFullScreen = useMemo13(() => {
2592
2672
  if (typeof document === "undefined") {
2593
2673
  return false;
2594
2674
  }
2595
2675
  return Boolean(document.fullscreenEnabled || document.webkitFullscreenEnabled);
2596
2676
  }, []);
2597
- const player = usePlayer();
2598
- const playerToggle = player.toggle;
2599
- const { playerMuted, mediaVolume } = useContext5(Internals11.MediaVolumeContext);
2677
+ const player = usePlayerMethods();
2678
+ const [playing] = Internals13.Timeline.usePlayingState();
2679
+ const frame = Internals13.Timeline.useTimelinePosition();
2680
+ const play = useCallback10((e) => {
2681
+ if (player.isPlaying()) {
2682
+ return;
2683
+ }
2684
+ setHasPlayed(true);
2685
+ player.play(e);
2686
+ }, [player]);
2687
+ const { playerMuted, mediaVolume } = useContext5(Internals13.MediaVolumeContext);
2600
2688
  useEffect12(() => {
2601
2689
  player.emitter.dispatchVolumeChange(mediaVolume);
2602
2690
  }, [player.emitter, mediaVolume]);
@@ -2617,11 +2705,11 @@ var PlayerUI = ({
2617
2705
  muted: isMuted
2618
2706
  });
2619
2707
  useEffect12(() => {
2620
- if (hasPausedToResume && !player.playing) {
2708
+ if (hasPausedToResume && !playing) {
2621
2709
  setHasPausedToResume(false);
2622
- player.play();
2710
+ play();
2623
2711
  }
2624
- }, [hasPausedToResume, player]);
2712
+ }, [hasPausedToResume, play, playing]);
2625
2713
  useEffect12(() => {
2626
2714
  const { current } = container;
2627
2715
  if (!current) {
@@ -2639,8 +2727,12 @@ var PlayerUI = ({
2639
2727
  };
2640
2728
  }, []);
2641
2729
  const toggle = useCallback10((e) => {
2642
- playerToggle(e);
2643
- }, [playerToggle]);
2730
+ if (player.isPlaying()) {
2731
+ player.pause();
2732
+ } else {
2733
+ play(e);
2734
+ }
2735
+ }, [play, player]);
2644
2736
  const requestFullscreen = useCallback10(() => {
2645
2737
  if (!allowFullscreen) {
2646
2738
  throw new Error("allowFullscreen is false");
@@ -2689,7 +2781,7 @@ var PlayerUI = ({
2689
2781
  };
2690
2782
  }, [player.emitter]);
2691
2783
  const durationInFrames = config?.durationInFrames ?? 1;
2692
- const layout = useMemo12(() => {
2784
+ const layout = useMemo13(() => {
2693
2785
  if (!config || !canvasSize) {
2694
2786
  return null;
2695
2787
  }
@@ -2701,7 +2793,7 @@ var PlayerUI = ({
2701
2793
  });
2702
2794
  }, [canvasSize, config]);
2703
2795
  const scale = layout?.scale ?? 1;
2704
- const initialScaleIgnored = useRef10(false);
2796
+ const initialScaleIgnored = useRef11(false);
2705
2797
  useEffect12(() => {
2706
2798
  if (!initialScaleIgnored.current) {
2707
2799
  initialScaleIgnored.current = true;
@@ -2709,8 +2801,8 @@ var PlayerUI = ({
2709
2801
  }
2710
2802
  player.emitter.dispatchScaleChange(scale);
2711
2803
  }, [player.emitter, scale]);
2712
- const { setMediaVolume, setPlayerMuted } = useContext5(Internals11.SetMediaVolumeContext);
2713
- const [showBufferIndicator, setShowBufferState] = useState11(false);
2804
+ const { setMediaVolume, setPlayerMuted } = useContext5(Internals13.SetMediaVolumeContext);
2805
+ const [showBufferIndicator, setShowBufferState] = useState10(false);
2714
2806
  useEffect12(() => {
2715
2807
  let timeout = null;
2716
2808
  let stopped = false;
@@ -2751,7 +2843,7 @@ var PlayerUI = ({
2751
2843
  }, [bufferStateDelayInMilliseconds, player.emitter]);
2752
2844
  useImperativeHandle(ref, () => {
2753
2845
  const methods = {
2754
- play: player.play,
2846
+ play,
2755
2847
  pause: () => {
2756
2848
  setHasPausedToResume(false);
2757
2849
  player.pause();
@@ -2821,6 +2913,7 @@ var PlayerUI = ({
2821
2913
  isMuted,
2822
2914
  mediaVolume,
2823
2915
  player,
2916
+ play,
2824
2917
  requestFullscreen,
2825
2918
  setPlayerMuted,
2826
2919
  setMediaVolume,
@@ -2828,7 +2921,7 @@ var PlayerUI = ({
2828
2921
  scale
2829
2922
  ]);
2830
2923
  const VideoComponent = video ? video.component : null;
2831
- const outerStyle = useMemo12(() => {
2924
+ const outerStyle = useMemo13(() => {
2832
2925
  return calculateOuterStyle({
2833
2926
  canvasSize,
2834
2927
  config,
@@ -2837,10 +2930,10 @@ var PlayerUI = ({
2837
2930
  layout
2838
2931
  });
2839
2932
  }, [canvasSize, config, layout, overflowVisible, style2]);
2840
- const outer = useMemo12(() => {
2933
+ const outer = useMemo13(() => {
2841
2934
  return calculateOuter({ config, layout, scale, overflowVisible });
2842
2935
  }, [config, layout, overflowVisible, scale]);
2843
- const containerStyle3 = useMemo12(() => {
2936
+ const containerStyle3 = useMemo13(() => {
2844
2937
  return calculateContainerStyle({
2845
2938
  config,
2846
2939
  layout,
@@ -2885,18 +2978,18 @@ var PlayerUI = ({
2885
2978
  const { handlePointerDown, handleDoubleClick } = useClickPreventionOnDoubleClick(onSingleClick, onDoubleClick, doubleClickToFullscreen && allowFullscreen && supportsFullScreen);
2886
2979
  useEffect12(() => {
2887
2980
  if (shouldAutoplay) {
2888
- player.play();
2981
+ play();
2889
2982
  setShouldAutoPlay(false);
2890
2983
  }
2891
- }, [shouldAutoplay, player]);
2892
- const loadingMarkup = useMemo12(() => {
2984
+ }, [play, shouldAutoplay]);
2985
+ const loadingMarkup = useMemo13(() => {
2893
2986
  return renderLoading ? renderLoading({
2894
2987
  height: outerStyle.height,
2895
2988
  width: outerStyle.width,
2896
2989
  isBuffering: showBufferIndicator
2897
2990
  }) : null;
2898
2991
  }, [outerStyle.height, outerStyle.width, renderLoading, showBufferIndicator]);
2899
- const currentScale = useMemo12(() => {
2992
+ const currentScale = useMemo13(() => {
2900
2993
  return {
2901
2994
  type: "scale",
2902
2995
  scale
@@ -2915,8 +3008,8 @@ var PlayerUI = ({
2915
3008
  }
2916
3009
  const shouldShowPoster = poster && [
2917
3010
  showPosterWhenPaused && !player.isPlaying() && !seeking,
2918
- showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
2919
- showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
3011
+ showPosterWhenEnded && frame === durationInFrames - 1 && !player.isPlaying(),
3012
+ showPosterWhenUnplayed && !hasPlayed && !player.isPlaying(),
2920
3013
  showPosterWhenBuffering && showBufferIndicator && player.isPlaying(),
2921
3014
  showPosterWhenBufferingAndPaused && showBufferIndicator && !player.isPlaying()
2922
3015
  ].some(Boolean);
@@ -2932,18 +3025,18 @@ var PlayerUI = ({
2932
3025
  style: containerStyle3,
2933
3026
  className: playerCssClassname(overrideInternalClassName),
2934
3027
  children: [
2935
- VideoComponent ? /* @__PURE__ */ jsx12(ErrorBoundary, {
3028
+ VideoComponent ? /* @__PURE__ */ jsx13(ErrorBoundary, {
2936
3029
  onError,
2937
3030
  errorFallback,
2938
- children: /* @__PURE__ */ jsx12(Internals11.CurrentScaleContext.Provider, {
3031
+ children: /* @__PURE__ */ jsx13(Internals13.CurrentScaleContext.Provider, {
2939
3032
  value: currentScale,
2940
- children: /* @__PURE__ */ jsx12(VideoComponent, {
3033
+ children: /* @__PURE__ */ jsx13(VideoComponent, {
2941
3034
  ...video?.props ?? {},
2942
3035
  ...inputProps ?? {}
2943
3036
  })
2944
3037
  })
2945
3038
  }) : null,
2946
- shouldShowPoster && posterFillMode === "composition-size" ? /* @__PURE__ */ jsx12("div", {
3039
+ shouldShowPoster && posterFillMode === "composition-size" ? /* @__PURE__ */ jsx13("div", {
2947
3040
  style: {
2948
3041
  ...outerWithoutScale,
2949
3042
  width: config.width,
@@ -2955,19 +3048,19 @@ var PlayerUI = ({
2955
3048
  }) : null
2956
3049
  ]
2957
3050
  }),
2958
- /* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {})
3051
+ /* @__PURE__ */ jsx13(RenderWarningIfBlacklist, {})
2959
3052
  ]
2960
3053
  }),
2961
- shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx12("div", {
3054
+ shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx13("div", {
2962
3055
  style: outer,
2963
3056
  onPointerDown: clickToPlay ? handlePointerDown : undefined,
2964
3057
  onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
2965
3058
  children: poster
2966
3059
  }) : null,
2967
- controls ? /* @__PURE__ */ jsx12(Controls, {
3060
+ controls ? /* @__PURE__ */ jsx13(Controls, {
2968
3061
  fps: config.fps,
2969
- playing: player.playing,
2970
- toggle: player.toggle,
3062
+ playing,
3063
+ toggle,
2971
3064
  durationInFrames: config.durationInFrames,
2972
3065
  containerRef: container,
2973
3066
  onFullscreenButtonClick,
@@ -2997,18 +3090,18 @@ var PlayerUI = ({
2997
3090
  ]
2998
3091
  });
2999
3092
  if (noSuspense || IS_NODE && !doesReactVersionSupportSuspense) {
3000
- return /* @__PURE__ */ jsx12("div", {
3093
+ return /* @__PURE__ */ jsx13("div", {
3001
3094
  ref: container,
3002
3095
  style: outerStyle,
3003
3096
  className: className2,
3004
3097
  children: content
3005
3098
  });
3006
3099
  }
3007
- return /* @__PURE__ */ jsx12("div", {
3100
+ return /* @__PURE__ */ jsx13("div", {
3008
3101
  ref: container,
3009
3102
  style: outerStyle,
3010
3103
  className: className2,
3011
- children: /* @__PURE__ */ jsx12(Suspense, {
3104
+ children: /* @__PURE__ */ jsx13(Suspense, {
3012
3105
  fallback: loadingMarkup,
3013
3106
  children: content
3014
3107
  })
@@ -3017,11 +3110,11 @@ var PlayerUI = ({
3017
3110
  var PlayerUI_default = forwardRef(PlayerUI);
3018
3111
 
3019
3112
  // src/SharedPlayerContext.tsx
3020
- import { useCallback as useCallback11, useMemo as useMemo13, useRef as useRef11, useState as useState12 } from "react";
3021
- import { Internals as Internals13 } from "remotion";
3113
+ import { useCallback as useCallback11, useMemo as useMemo14, useRef as useRef12, useState as useState11 } from "react";
3114
+ import { Internals as Internals15 } from "remotion";
3022
3115
 
3023
3116
  // src/volume-persistence.ts
3024
- import { Internals as Internals12 } from "remotion";
3117
+ import { Internals as Internals14 } from "remotion";
3025
3118
  var DEFAULT_VOLUME_PERSISTENCE_KEY = "remotion.volumePreference";
3026
3119
  var persistVolume = (volume, logLevel, volumePersistenceKey) => {
3027
3120
  if (typeof window === "undefined") {
@@ -3030,7 +3123,7 @@ var persistVolume = (volume, logLevel, volumePersistenceKey) => {
3030
3123
  try {
3031
3124
  window.localStorage.setItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTENCE_KEY, String(volume));
3032
3125
  } catch (e) {
3033
- Internals12.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
3126
+ Internals14.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
3034
3127
  }
3035
3128
  };
3036
3129
  var getPreferredVolume = (volumePersistenceKey) => {
@@ -3046,7 +3139,7 @@ var getPreferredVolume = (volumePersistenceKey) => {
3046
3139
  };
3047
3140
 
3048
3141
  // src/SharedPlayerContext.tsx
3049
- import { jsx as jsx13 } from "react/jsx-runtime";
3142
+ import { jsx as jsx14 } from "react/jsx-runtime";
3050
3143
  var PLAYER_COMP_ID = "player-comp";
3051
3144
  var SharedPlayerContexts = ({
3052
3145
  children,
@@ -3068,7 +3161,7 @@ var SharedPlayerContexts = ({
3068
3161
  audioEnabled
3069
3162
  }) => {
3070
3163
  const persistVolumeToStorage = initialVolume === undefined;
3071
- const compositionManagerContext = useMemo13(() => {
3164
+ const compositionManagerContext = useMemo14(() => {
3072
3165
  const context = {
3073
3166
  compositions: [
3074
3167
  {
@@ -3111,15 +3204,15 @@ var SharedPlayerContexts = ({
3111
3204
  fps,
3112
3205
  inputProps
3113
3206
  ]);
3114
- const [playerMuted, setPlayerMuted] = useState12(() => initiallyMuted);
3115
- const [mediaVolume, setMediaVolume] = useState12(() => persistVolumeToStorage ? getPreferredVolume(volumePersistenceKey ?? null) : initialVolume);
3116
- const mediaVolumeContextValue = useMemo13(() => {
3207
+ const [playerMuted, setPlayerMuted] = useState11(() => initiallyMuted);
3208
+ const [mediaVolume, setMediaVolume] = useState11(() => persistVolumeToStorage ? getPreferredVolume(volumePersistenceKey ?? null) : initialVolume);
3209
+ const mediaVolumeContextValue = useMemo14(() => {
3117
3210
  return {
3118
3211
  playerMuted,
3119
3212
  mediaVolume
3120
3213
  };
3121
3214
  }, [playerMuted, mediaVolume]);
3122
- const audioContextWasCreated = useRef11(false);
3215
+ const audioContextWasCreated = useRef12(false);
3123
3216
  const shouldCreateAudioContext = audioContextWasCreated.current || audioEnabled && !playerMuted && mediaVolume > 0;
3124
3217
  audioContextWasCreated.current = shouldCreateAudioContext;
3125
3218
  const setMediaVolumeAndPersist = useCallback11((vol) => {
@@ -3128,19 +3221,19 @@ var SharedPlayerContexts = ({
3128
3221
  persistVolume(vol, logLevel, volumePersistenceKey ?? null);
3129
3222
  }
3130
3223
  }, [persistVolumeToStorage, logLevel, volumePersistenceKey]);
3131
- const setMediaVolumeContextValue = useMemo13(() => {
3224
+ const setMediaVolumeContextValue = useMemo14(() => {
3132
3225
  return {
3133
3226
  setPlayerMuted,
3134
3227
  setMediaVolume: setMediaVolumeAndPersist
3135
3228
  };
3136
3229
  }, [setMediaVolumeAndPersist]);
3137
- const logLevelContext = useMemo13(() => {
3230
+ const logLevelContext = useMemo14(() => {
3138
3231
  return {
3139
3232
  logLevel,
3140
3233
  mountTime: Date.now()
3141
3234
  };
3142
3235
  }, [logLevel]);
3143
- const env = useMemo13(() => {
3236
+ const env = useMemo14(() => {
3144
3237
  return {
3145
3238
  isPlayer: true,
3146
3239
  isRendering: false,
@@ -3149,33 +3242,45 @@ var SharedPlayerContexts = ({
3149
3242
  isReadOnlyStudio: false
3150
3243
  };
3151
3244
  }, []);
3152
- return /* @__PURE__ */ jsx13(Internals13.RemotionEnvironmentContext.Provider, {
3245
+ const frameRef = useRef12(timelineContext.frame);
3246
+ frameRef.current = timelineContext.frame;
3247
+ const timelineImperativeContextValue = useMemo14(() => {
3248
+ return {
3249
+ frameRef,
3250
+ imperativePlaying: timelineContext.imperativePlaying,
3251
+ audioAndVideoTags: timelineContext.audioAndVideoTags
3252
+ };
3253
+ }, [timelineContext.audioAndVideoTags, timelineContext.imperativePlaying]);
3254
+ return /* @__PURE__ */ jsx14(Internals15.RemotionEnvironmentContext.Provider, {
3153
3255
  value: env,
3154
- children: /* @__PURE__ */ jsx13(Internals13.LogLevelContext.Provider, {
3256
+ children: /* @__PURE__ */ jsx14(Internals15.LogLevelContext.Provider, {
3155
3257
  value: logLevelContext,
3156
- children: /* @__PURE__ */ jsx13(Internals13.CanUseRemotionHooksProvider, {
3157
- children: /* @__PURE__ */ jsx13(Internals13.AbsoluteTimeContext.Provider, {
3258
+ children: /* @__PURE__ */ jsx14(Internals15.CanUseRemotionHooksProvider, {
3259
+ children: /* @__PURE__ */ jsx14(Internals15.AbsoluteTimeContext.Provider, {
3158
3260
  value: timelineContext,
3159
- children: /* @__PURE__ */ jsx13(Internals13.PlaybackRateContext.Provider, {
3261
+ children: /* @__PURE__ */ jsx14(Internals15.PlaybackRateContext.Provider, {
3160
3262
  value: playbackRateContext,
3161
- children: /* @__PURE__ */ jsx13(Internals13.TimelineContext.Provider, {
3162
- value: timelineContext,
3163
- children: /* @__PURE__ */ jsx13(Internals13.CompositionManager.Provider, {
3164
- value: compositionManagerContext,
3165
- children: /* @__PURE__ */ jsx13(Internals13.PrefetchProvider, {
3166
- children: /* @__PURE__ */ jsx13(Internals13.DurationsContextProvider, {
3167
- children: /* @__PURE__ */ jsx13(Internals13.MediaVolumeContext.Provider, {
3168
- value: mediaVolumeContextValue,
3169
- children: /* @__PURE__ */ jsx13(Internals13.SetMediaVolumeContext.Provider, {
3170
- value: setMediaVolumeContextValue,
3171
- children: /* @__PURE__ */ jsx13(Internals13.BufferingProvider, {
3172
- children: /* @__PURE__ */ jsx13(Internals13.SharedAudioContextProvider, {
3173
- audioLatencyHint,
3174
- audioEnabled: shouldCreateAudioContext,
3175
- previewSampleRate: sampleRate,
3176
- children: /* @__PURE__ */ jsx13(Internals13.SharedAudioTagsContextProvider, {
3177
- numberOfAudioTags: numberOfSharedAudioTags,
3178
- children
3263
+ children: /* @__PURE__ */ jsx14(CoreTimelineImperativeContextProvider, {
3264
+ value: timelineImperativeContextValue,
3265
+ children: /* @__PURE__ */ jsx14(Internals15.TimelineContext.Provider, {
3266
+ value: timelineContext,
3267
+ children: /* @__PURE__ */ jsx14(Internals15.CompositionManager.Provider, {
3268
+ value: compositionManagerContext,
3269
+ children: /* @__PURE__ */ jsx14(Internals15.PrefetchProvider, {
3270
+ children: /* @__PURE__ */ jsx14(Internals15.DurationsContextProvider, {
3271
+ children: /* @__PURE__ */ jsx14(Internals15.MediaVolumeContext.Provider, {
3272
+ value: mediaVolumeContextValue,
3273
+ children: /* @__PURE__ */ jsx14(Internals15.SetMediaVolumeContext.Provider, {
3274
+ value: setMediaVolumeContextValue,
3275
+ children: /* @__PURE__ */ jsx14(Internals15.BufferingProvider, {
3276
+ children: /* @__PURE__ */ jsx14(Internals15.SharedAudioContextProvider, {
3277
+ audioLatencyHint,
3278
+ audioEnabled: shouldCreateAudioContext,
3279
+ previewSampleRate: sampleRate,
3280
+ children: /* @__PURE__ */ jsx14(Internals15.SharedAudioTagsContextProvider, {
3281
+ numberOfAudioTags: numberOfSharedAudioTags,
3282
+ children
3283
+ })
3179
3284
  })
3180
3285
  })
3181
3286
  })
@@ -3193,7 +3298,7 @@ var SharedPlayerContexts = ({
3193
3298
  };
3194
3299
 
3195
3300
  // src/use-remotion-license-acknowledge.ts
3196
- import { Internals as Internals14 } from "remotion";
3301
+ import { Internals as Internals16 } from "remotion";
3197
3302
  var warningShown = false;
3198
3303
  var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
3199
3304
  if (acknowledge) {
@@ -3203,7 +3308,7 @@ var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
3203
3308
  return;
3204
3309
  }
3205
3310
  warningShown = true;
3206
- 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.");
3311
+ Internals16.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.");
3207
3312
  };
3208
3313
 
3209
3314
  // src/utils/validate-in-out-frame.ts
@@ -3304,7 +3409,7 @@ var validateDurationInFrames = NoReactInternals.validateDurationInFrames;
3304
3409
  var validateDefaultAndInputProps = NoReactInternals.validateDefaultAndInputProps;
3305
3410
 
3306
3411
  // src/Player.tsx
3307
- import { jsx as jsx14 } from "react/jsx-runtime";
3412
+ import { jsx as jsx15 } from "react/jsx-runtime";
3308
3413
  var componentOrNullIfLazy = (props) => {
3309
3414
  if ("component" in props) {
3310
3415
  return props.component;
@@ -3378,21 +3483,21 @@ var PlayerFn = ({
3378
3483
  if (componentForValidation === Composition) {
3379
3484
  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.`);
3380
3485
  }
3381
- useState13(() => acknowledgeRemotionLicenseMessage(Boolean(acknowledgeRemotionLicense), logLevel));
3382
- const component = Internals15.useLazyComponent({
3486
+ useState12(() => acknowledgeRemotionLicenseMessage(Boolean(acknowledgeRemotionLicense), logLevel));
3487
+ const component = Internals17.useLazyComponent({
3383
3488
  compProps: componentProps,
3384
3489
  componentName: "Player",
3385
3490
  noSuspense: Boolean(noSuspense)
3386
3491
  });
3387
3492
  validateInitialFrame({ initialFrame, durationInFrames });
3388
- const [frame, setFrame] = useState13(() => ({
3493
+ const [frame, setFrame] = useState12(() => ({
3389
3494
  [PLAYER_COMP_ID]: initialFrame ?? 0
3390
3495
  }));
3391
- const [playing, setPlaying] = useState13(false);
3392
- const rootRef = useRef12(null);
3393
- const audioAndVideoTags = useRef12([]);
3394
- const imperativePlaying = useRef12(false);
3395
- const [currentPlaybackRate, setCurrentPlaybackRate] = useState13(playbackRate);
3496
+ const [playing, setPlaying] = useState12(false);
3497
+ const rootRef = useRef13(null);
3498
+ const audioAndVideoTags = useRef13([]);
3499
+ const imperativePlaying = useRef13(false);
3500
+ const [currentPlaybackRate, setCurrentPlaybackRate] = useState12(playbackRate);
3396
3501
  if (typeof compositionHeight !== "number") {
3397
3502
  throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
3398
3503
  }
@@ -3453,15 +3558,15 @@ var PlayerFn = ({
3453
3558
  setCurrentPlaybackRate(playbackRate);
3454
3559
  }, [playbackRate]);
3455
3560
  useImperativeHandle2(ref, () => rootRef.current, []);
3456
- useState13(() => {
3457
- Internals15.playbackLogging({
3561
+ useState12(() => {
3562
+ Internals17.playbackLogging({
3458
3563
  logLevel,
3459
3564
  message: `[player] Mounting <Player>. User agent = ${typeof navigator === "undefined" ? "server" : navigator.userAgent}`,
3460
3565
  tag: "player",
3461
3566
  mountTime: Date.now()
3462
3567
  });
3463
3568
  });
3464
- const timelineContextValue = useMemo14(() => {
3569
+ const timelineContextValue = useMemo15(() => {
3465
3570
  return {
3466
3571
  frame,
3467
3572
  playing,
@@ -3469,13 +3574,13 @@ var PlayerFn = ({
3469
3574
  audioAndVideoTags
3470
3575
  };
3471
3576
  }, [frame, playing]);
3472
- const playbackRateContextValue = useMemo14(() => {
3577
+ const playbackRateContextValue = useMemo15(() => {
3473
3578
  return {
3474
3579
  playbackRate: currentPlaybackRate,
3475
3580
  setPlaybackRate: setCurrentPlaybackRate
3476
3581
  };
3477
3582
  }, [currentPlaybackRate]);
3478
- const setTimelineContextValue = useMemo14(() => {
3583
+ const setTimelineContextValue = useMemo15(() => {
3479
3584
  return {
3480
3585
  setFrame,
3481
3586
  setPlaying
@@ -3483,17 +3588,17 @@ var PlayerFn = ({
3483
3588
  }, [setFrame]);
3484
3589
  if (typeof window !== "undefined") {
3485
3590
  useLayoutEffect3(() => {
3486
- Internals15.CSSUtils.injectCSS(Internals15.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
3591
+ Internals17.CSSUtils.injectCSS(Internals17.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
3487
3592
  }, [overrideInternalClassName]);
3488
3593
  }
3489
- const actualInputProps = useMemo14(() => inputProps ?? {}, [inputProps]);
3490
- const browserMediaControlsBehavior = useMemo14(() => {
3594
+ const actualInputProps = useMemo15(() => inputProps ?? {}, [inputProps]);
3595
+ const browserMediaControlsBehavior = useMemo15(() => {
3491
3596
  return passedBrowserMediaControlsBehavior ?? {
3492
3597
  mode: "prevent-media-session"
3493
3598
  };
3494
3599
  }, [passedBrowserMediaControlsBehavior]);
3495
- return /* @__PURE__ */ jsx14(Internals15.IsPlayerContextProvider, {
3496
- children: /* @__PURE__ */ jsx14(SharedPlayerContexts, {
3600
+ return /* @__PURE__ */ jsx15(Internals17.IsPlayerContextProvider, {
3601
+ children: /* @__PURE__ */ jsx15(SharedPlayerContexts, {
3497
3602
  timelineContext: timelineContextValue,
3498
3603
  playbackRateContext: playbackRateContextValue,
3499
3604
  component,
@@ -3510,11 +3615,11 @@ var PlayerFn = ({
3510
3615
  initialVolume,
3511
3616
  inputProps: actualInputProps,
3512
3617
  audioEnabled: true,
3513
- children: /* @__PURE__ */ jsx14(Internals15.SetTimelineContext.Provider, {
3618
+ children: /* @__PURE__ */ jsx15(Internals17.SetTimelineContext.Provider, {
3514
3619
  value: setTimelineContextValue,
3515
- children: /* @__PURE__ */ jsx14(PlayerEmitterProvider, {
3620
+ children: /* @__PURE__ */ jsx15(PlayerEmitterProvider, {
3516
3621
  currentPlaybackRate,
3517
- children: /* @__PURE__ */ jsx14(PlayerUI_default, {
3622
+ children: /* @__PURE__ */ jsx15(PlayerUI_default, {
3518
3623
  ref: rootRef,
3519
3624
  posterFillMode,
3520
3625
  renderLoading,
@@ -3567,31 +3672,31 @@ import {
3567
3672
  forwardRef as forwardRef4,
3568
3673
  useImperativeHandle as useImperativeHandle4,
3569
3674
  useLayoutEffect as useLayoutEffect4,
3570
- useMemo as useMemo17,
3571
- useRef as useRef14,
3572
- useState as useState14
3675
+ useMemo as useMemo18,
3676
+ useRef as useRef15,
3677
+ useState as useState13
3573
3678
  } from "react";
3574
- import { Internals as Internals17 } from "remotion";
3679
+ import { Internals as Internals19 } from "remotion";
3575
3680
 
3576
3681
  // src/ThumbnailUI.tsx
3577
- import React13, {
3682
+ import React14, {
3578
3683
  forwardRef as forwardRef3,
3579
3684
  Suspense as Suspense2,
3580
3685
  useCallback as useCallback12,
3581
3686
  useImperativeHandle as useImperativeHandle3,
3582
- useMemo as useMemo16,
3583
- useRef as useRef13
3687
+ useMemo as useMemo17,
3688
+ useRef as useRef14
3584
3689
  } from "react";
3585
- import { Internals as Internals16 } from "remotion";
3690
+ import { Internals as Internals18 } from "remotion";
3586
3691
 
3587
3692
  // src/use-thumbnail.ts
3588
- import { useContext as useContext6, useMemo as useMemo15 } from "react";
3693
+ import { useContext as useContext6, useMemo as useMemo16 } from "react";
3589
3694
  var useThumbnail = () => {
3590
3695
  const emitter = useContext6(ThumbnailEmitterContext);
3591
3696
  if (!emitter) {
3592
3697
  throw new TypeError("Expected Player event emitter context");
3593
3698
  }
3594
- const returnValue = useMemo15(() => {
3699
+ const returnValue = useMemo16(() => {
3595
3700
  return {
3596
3701
  emitter
3597
3702
  };
@@ -3600,8 +3705,8 @@ var useThumbnail = () => {
3600
3705
  };
3601
3706
 
3602
3707
  // src/ThumbnailUI.tsx
3603
- import { jsx as jsx15 } from "react/jsx-runtime";
3604
- var reactVersion2 = React13.version.split(".")[0];
3708
+ import { jsx as jsx16 } from "react/jsx-runtime";
3709
+ var reactVersion2 = React14.version.split(".")[0];
3605
3710
  if (reactVersion2 === "0") {
3606
3711
  throw new Error(`Version ${reactVersion2} of "react" is not supported by Remotion`);
3607
3712
  }
@@ -3616,14 +3721,14 @@ var ThumbnailUI = ({
3616
3721
  noSuspense,
3617
3722
  overrideInternalClassName
3618
3723
  }, ref) => {
3619
- const config = Internals16.useUnsafeVideoConfig();
3620
- const video = Internals16.useVideo();
3621
- const container = useRef13(null);
3724
+ const config = Internals18.useUnsafeVideoConfig();
3725
+ const video = Internals18.useVideo();
3726
+ const container = useRef14(null);
3622
3727
  const canvasSize = useElementSize(container, {
3623
3728
  triggerOnWindowResize: false,
3624
3729
  shouldApplyCssTransforms: false
3625
3730
  });
3626
- const layout = useMemo16(() => {
3731
+ const layout = useMemo17(() => {
3627
3732
  if (!config || !canvasSize) {
3628
3733
  return null;
3629
3734
  }
@@ -3645,7 +3750,7 @@ var ThumbnailUI = ({
3645
3750
  return Object.assign(thumbnail.emitter, methods);
3646
3751
  }, [scale, thumbnail.emitter]);
3647
3752
  const VideoComponent = video ? video.component : null;
3648
- const outerStyle = useMemo16(() => {
3753
+ const outerStyle = useMemo17(() => {
3649
3754
  return calculateOuterStyle({
3650
3755
  config,
3651
3756
  style: style2,
@@ -3654,10 +3759,10 @@ var ThumbnailUI = ({
3654
3759
  layout
3655
3760
  });
3656
3761
  }, [canvasSize, config, layout, overflowVisible, style2]);
3657
- const outer = useMemo16(() => {
3762
+ const outer = useMemo17(() => {
3658
3763
  return calculateOuter({ config, layout, scale, overflowVisible });
3659
3764
  }, [config, layout, overflowVisible, scale]);
3660
- const containerStyle3 = useMemo16(() => {
3765
+ const containerStyle3 = useMemo17(() => {
3661
3766
  return calculateContainerStyle({
3662
3767
  config,
3663
3768
  layout,
@@ -3668,14 +3773,14 @@ var ThumbnailUI = ({
3668
3773
  const onError = useCallback12((error) => {
3669
3774
  thumbnail.emitter.dispatchError(error);
3670
3775
  }, [thumbnail.emitter]);
3671
- const loadingMarkup = useMemo16(() => {
3776
+ const loadingMarkup = useMemo17(() => {
3672
3777
  return renderLoading ? renderLoading({
3673
3778
  height: outerStyle.height,
3674
3779
  width: outerStyle.width,
3675
3780
  isBuffering: false
3676
3781
  }) : null;
3677
3782
  }, [outerStyle.height, outerStyle.width, renderLoading]);
3678
- const currentScaleContext = useMemo16(() => {
3783
+ const currentScaleContext = useMemo17(() => {
3679
3784
  return {
3680
3785
  type: "scale",
3681
3786
  scale
@@ -3684,17 +3789,17 @@ var ThumbnailUI = ({
3684
3789
  if (!config) {
3685
3790
  return null;
3686
3791
  }
3687
- const content = /* @__PURE__ */ jsx15("div", {
3792
+ const content = /* @__PURE__ */ jsx16("div", {
3688
3793
  style: outer,
3689
- children: /* @__PURE__ */ jsx15("div", {
3794
+ children: /* @__PURE__ */ jsx16("div", {
3690
3795
  style: containerStyle3,
3691
3796
  className: playerCssClassname(overrideInternalClassName),
3692
- children: VideoComponent ? /* @__PURE__ */ jsx15(ErrorBoundary, {
3797
+ children: VideoComponent ? /* @__PURE__ */ jsx16(ErrorBoundary, {
3693
3798
  onError,
3694
3799
  errorFallback,
3695
- children: /* @__PURE__ */ jsx15(Internals16.CurrentScaleContext.Provider, {
3800
+ children: /* @__PURE__ */ jsx16(Internals18.CurrentScaleContext.Provider, {
3696
3801
  value: currentScaleContext,
3697
- children: /* @__PURE__ */ jsx15(VideoComponent, {
3802
+ children: /* @__PURE__ */ jsx16(VideoComponent, {
3698
3803
  ...video?.props ?? {},
3699
3804
  ...inputProps ?? {}
3700
3805
  })
@@ -3703,18 +3808,18 @@ var ThumbnailUI = ({
3703
3808
  })
3704
3809
  });
3705
3810
  if (noSuspense || IS_NODE && !doesReactVersionSupportSuspense2) {
3706
- return /* @__PURE__ */ jsx15("div", {
3811
+ return /* @__PURE__ */ jsx16("div", {
3707
3812
  ref: container,
3708
3813
  style: outerStyle,
3709
3814
  className: className2,
3710
3815
  children: content
3711
3816
  });
3712
3817
  }
3713
- return /* @__PURE__ */ jsx15("div", {
3818
+ return /* @__PURE__ */ jsx16("div", {
3714
3819
  ref: container,
3715
3820
  style: outerStyle,
3716
3821
  className: className2,
3717
- children: /* @__PURE__ */ jsx15(Suspense2, {
3822
+ children: /* @__PURE__ */ jsx16(Suspense2, {
3718
3823
  fallback: loadingMarkup,
3719
3824
  children: content
3720
3825
  })
@@ -3723,7 +3828,7 @@ var ThumbnailUI = ({
3723
3828
  var ThumbnailUI_default = forwardRef3(ThumbnailUI);
3724
3829
 
3725
3830
  // src/Thumbnail.tsx
3726
- import { jsx as jsx16 } from "react/jsx-runtime";
3831
+ import { jsx as jsx17 } from "react/jsx-runtime";
3727
3832
  var ThumbnailFn = ({
3728
3833
  frameToDisplay,
3729
3834
  style: style2,
@@ -3746,21 +3851,21 @@ var ThumbnailFn = ({
3746
3851
  window.remotion_isPlayer = true;
3747
3852
  }, []);
3748
3853
  }
3749
- const rootRef = useRef14(null);
3750
- const timelineState = useMemo17(() => {
3854
+ const rootRef = useRef15(null);
3855
+ const imperativePlaying = useRef15(false);
3856
+ const audioAndVideoTags = useRef15([]);
3857
+ const timelineState = useMemo18(() => {
3751
3858
  const value = {
3752
3859
  playing: false,
3753
3860
  frame: {
3754
3861
  [PLAYER_COMP_ID]: frameToDisplay
3755
3862
  },
3756
- imperativePlaying: {
3757
- current: false
3758
- },
3759
- audioAndVideoTags: { current: [] }
3863
+ imperativePlaying,
3864
+ audioAndVideoTags
3760
3865
  };
3761
3866
  return value;
3762
3867
  }, [frameToDisplay]);
3763
- const playbackRateContext = useMemo17(() => {
3868
+ const playbackRateContext = useMemo18(() => {
3764
3869
  return {
3765
3870
  playbackRate: 1,
3766
3871
  setPlaybackRate: () => {
@@ -3769,17 +3874,17 @@ var ThumbnailFn = ({
3769
3874
  };
3770
3875
  }, []);
3771
3876
  useImperativeHandle4(ref, () => rootRef.current, []);
3772
- const Component = Internals17.useLazyComponent({
3877
+ const Component = Internals19.useLazyComponent({
3773
3878
  compProps: componentProps,
3774
3879
  componentName: "Thumbnail",
3775
3880
  noSuspense: Boolean(noSuspense)
3776
3881
  });
3777
- const [emitter] = useState14(() => new ThumbnailEmitter);
3778
- const passedInputProps = useMemo17(() => {
3882
+ const [emitter] = useState13(() => new ThumbnailEmitter);
3883
+ const passedInputProps = useMemo18(() => {
3779
3884
  return inputProps ?? {};
3780
3885
  }, [inputProps]);
3781
- return /* @__PURE__ */ jsx16(Internals17.IsPlayerContextProvider, {
3782
- children: /* @__PURE__ */ jsx16(SharedPlayerContexts, {
3886
+ return /* @__PURE__ */ jsx17(Internals19.IsPlayerContextProvider, {
3887
+ children: /* @__PURE__ */ jsx17(SharedPlayerContexts, {
3783
3888
  timelineContext: timelineState,
3784
3889
  playbackRateContext,
3785
3890
  component: Component,
@@ -3794,9 +3899,9 @@ var ThumbnailFn = ({
3794
3899
  sampleRate: 48000,
3795
3900
  inputProps: passedInputProps,
3796
3901
  audioEnabled: false,
3797
- children: /* @__PURE__ */ jsx16(ThumbnailEmitterContext.Provider, {
3902
+ children: /* @__PURE__ */ jsx17(ThumbnailEmitterContext.Provider, {
3798
3903
  value: emitter,
3799
- children: /* @__PURE__ */ jsx16(ThumbnailUI_default, {
3904
+ children: /* @__PURE__ */ jsx17(ThumbnailUI_default, {
3800
3905
  ref: rootRef,
3801
3906
  className: className2,
3802
3907
  errorFallback,
@@ -3818,7 +3923,7 @@ var Thumbnail = forward2(ThumbnailFn);
3818
3923
  var PlayerInternals = {
3819
3924
  PlayerEventEmitterContext,
3820
3925
  PlayerEmitter,
3821
- usePlayer,
3926
+ usePlayerMethods,
3822
3927
  usePlayback,
3823
3928
  useElementSize,
3824
3929
  calculateCanvasTransformation,