@remotion/player 4.0.504 → 4.0.506

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 }));
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,16 @@ 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 logLevel = Internals8.useLogLevel();
966
1030
  const isBackgroundedRef = useIsBackgrounded();
967
- const lastTimeUpdateTimestamp = useRef4(0);
968
- const context = useContext4(Internals6.BufferingContextReact);
1031
+ const lastTimeUpdateTimestamp = useRef5(0);
1032
+ const context = useContext4(Internals8.BufferingContextReact);
969
1033
  if (!context) {
970
1034
  throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
971
1035
  }
@@ -1180,7 +1244,7 @@ var usePlayback = ({
1180
1244
  };
1181
1245
 
1182
1246
  // src/utils/use-element-size.ts
1183
- import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useState as useState4 } from "react";
1247
+ import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo3, useState as useState3 } from "react";
1184
1248
  var elementSizeHooks = [];
1185
1249
  var updateAllElementsSizes = () => {
1186
1250
  for (const listener of elementSizeHooks) {
@@ -1197,7 +1261,7 @@ var getElement = (source) => {
1197
1261
  return source;
1198
1262
  };
1199
1263
  var useElementSize = (source, options) => {
1200
- const [size, setSize] = useState4(() => {
1264
+ const [size, setSize] = useState3(() => {
1201
1265
  const element = getElement(source);
1202
1266
  if (!element) {
1203
1267
  return null;
@@ -1217,7 +1281,7 @@ var useElementSize = (source, options) => {
1217
1281
  }
1218
1282
  };
1219
1283
  });
1220
- const observer = useMemo2(() => {
1284
+ const observer = useMemo3(() => {
1221
1285
  if (typeof ResizeObserver === "undefined") {
1222
1286
  return null;
1223
1287
  }
@@ -1309,7 +1373,7 @@ var useElementSize = (source, options) => {
1309
1373
  elementSizeHooks = elementSizeHooks.filter((e) => e !== updateSize);
1310
1374
  };
1311
1375
  }, [updateSize]);
1312
- return useMemo2(() => {
1376
+ return useMemo3(() => {
1313
1377
  if (!size) {
1314
1378
  return null;
1315
1379
  }
@@ -1323,11 +1387,11 @@ import {
1323
1387
  useEffect as useEffect13,
1324
1388
  useImperativeHandle as useImperativeHandle2,
1325
1389
  useLayoutEffect as useLayoutEffect3,
1326
- useMemo as useMemo14,
1327
- useRef as useRef12,
1328
- useState as useState13
1390
+ useMemo as useMemo15,
1391
+ useRef as useRef13,
1392
+ useState as useState12
1329
1393
  } from "react";
1330
- import { Composition, Internals as Internals15 } from "remotion";
1394
+ import { Composition, Internals as Internals17 } from "remotion";
1331
1395
 
1332
1396
  // src/player-css-classname.ts
1333
1397
  var playerCssClassname = (override) => {
@@ -1335,22 +1399,22 @@ var playerCssClassname = (override) => {
1335
1399
  };
1336
1400
 
1337
1401
  // src/PlayerUI.tsx
1338
- import React10, {
1402
+ import React11, {
1339
1403
  Suspense,
1340
1404
  forwardRef,
1341
1405
  useCallback as useCallback10,
1342
1406
  useContext as useContext5,
1343
1407
  useEffect as useEffect12,
1344
1408
  useImperativeHandle,
1345
- useMemo as useMemo12,
1346
- useRef as useRef10,
1347
- useState as useState11
1409
+ useMemo as useMemo13,
1410
+ useRef as useRef11,
1411
+ useState as useState10
1348
1412
  } from "react";
1349
- import { Internals as Internals11 } from "remotion";
1413
+ import { Internals as Internals13 } from "remotion";
1350
1414
 
1351
1415
  // src/error-boundary.tsx
1352
- import React3 from "react";
1353
- import { jsx as jsx4 } from "react/jsx-runtime";
1416
+ import React4 from "react";
1417
+ import { jsx as jsx5 } from "react/jsx-runtime";
1354
1418
  var errorStyle = {
1355
1419
  display: "flex",
1356
1420
  justifyContent: "center",
@@ -1360,7 +1424,7 @@ var errorStyle = {
1360
1424
  width: "100%"
1361
1425
  };
1362
1426
 
1363
- class ErrorBoundary extends React3.Component {
1427
+ class ErrorBoundary extends React4.Component {
1364
1428
  state = { hasError: null };
1365
1429
  static getDerivedStateFromError(error) {
1366
1430
  return { hasError: error };
@@ -1370,7 +1434,7 @@ class ErrorBoundary extends React3.Component {
1370
1434
  }
1371
1435
  render() {
1372
1436
  if (this.state.hasError) {
1373
- return /* @__PURE__ */ jsx4("div", {
1437
+ return /* @__PURE__ */ jsx5("div", {
1374
1438
  style: errorStyle,
1375
1439
  children: this.props.errorFallback({
1376
1440
  error: this.state.hasError
@@ -1382,8 +1446,8 @@ class ErrorBoundary extends React3.Component {
1382
1446
  }
1383
1447
 
1384
1448
  // src/license-blacklist.tsx
1385
- import React4, { useEffect as useEffect7 } from "react";
1386
- import { jsx as jsx5 } from "react/jsx-runtime";
1449
+ import React5, { useEffect as useEffect7 } from "react";
1450
+ import { jsx as jsx6 } from "react/jsx-runtime";
1387
1451
  var getHashOfDomain = async () => {
1388
1452
  if (typeof window === "undefined") {
1389
1453
  return null;
@@ -1417,7 +1481,7 @@ var DOMAIN_BLACKLIST = [
1417
1481
  ];
1418
1482
  var ran = false;
1419
1483
  var RenderWarningIfBlacklist = () => {
1420
- const [unlicensed, setUnlicensed] = React4.useState(false);
1484
+ const [unlicensed, setUnlicensed] = React5.useState(false);
1421
1485
  useEffect7(() => {
1422
1486
  if (ran) {
1423
1487
  return;
@@ -1459,10 +1523,10 @@ var RenderWarningIfBlacklist = () => {
1459
1523
  if (!unlicensed) {
1460
1524
  return null;
1461
1525
  }
1462
- return /* @__PURE__ */ jsx5("div", {
1526
+ return /* @__PURE__ */ jsx6("div", {
1463
1527
  style,
1464
1528
  className: "warning-banner",
1465
- children: /* @__PURE__ */ jsx5("a", {
1529
+ children: /* @__PURE__ */ jsx6("a", {
1466
1530
  style: { color: "white" },
1467
1531
  href: "https://github.com/remotion-dev/remotion/pull/4589",
1468
1532
  children: "Remotion Unlicensed – Contact hi@remotion.dev"
@@ -1471,30 +1535,30 @@ var RenderWarningIfBlacklist = () => {
1471
1535
  };
1472
1536
 
1473
1537
  // src/PlayerControls.tsx
1474
- import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo9, useRef as useRef8, useState as useState10 } from "react";
1538
+ import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo10, useRef as useRef9, useState as useState9 } from "react";
1475
1539
 
1476
1540
  // src/DefaultPlayPauseButton.tsx
1477
- import { jsx as jsx6 } from "react/jsx-runtime";
1541
+ import { jsx as jsx7 } from "react/jsx-runtime";
1478
1542
  var DefaultPlayPauseButton = ({ playing, buffering }) => {
1479
1543
  if (playing && buffering) {
1480
- return /* @__PURE__ */ jsx6(BufferingIndicator, {
1544
+ return /* @__PURE__ */ jsx7(BufferingIndicator, {
1481
1545
  type: "player"
1482
1546
  });
1483
1547
  }
1484
1548
  if (playing) {
1485
- return /* @__PURE__ */ jsx6(PauseIcon, {});
1549
+ return /* @__PURE__ */ jsx7(PauseIcon, {});
1486
1550
  }
1487
- return /* @__PURE__ */ jsx6(PlayIcon, {});
1551
+ return /* @__PURE__ */ jsx7(PlayIcon, {});
1488
1552
  };
1489
1553
 
1490
1554
  // 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";
1555
+ import { useCallback as useCallback4, useMemo as useMemo5, useRef as useRef6, useState as useState5 } from "react";
1556
+ import { Internals as Internals9 } from "remotion";
1493
1557
 
1494
1558
  // src/render-volume-slider.tsx
1495
- import React5, { useCallback as useCallback3, useMemo as useMemo3, useState as useState5 } from "react";
1559
+ import React6, { useCallback as useCallback3, useMemo as useMemo4, useState as useState4 } from "react";
1496
1560
  import { random } from "remotion";
1497
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1561
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
1498
1562
  var KNOB_SIZE = 12;
1499
1563
  var BAR_HEIGHT = 5;
1500
1564
  var DefaultVolumeSlider = ({
@@ -1504,7 +1568,7 @@ var DefaultVolumeSlider = ({
1504
1568
  inputRef,
1505
1569
  setVolume
1506
1570
  }) => {
1507
- const sliderContainer = useMemo3(() => {
1571
+ const sliderContainer = useMemo4(() => {
1508
1572
  const paddingLeft = 5;
1509
1573
  const common = {
1510
1574
  paddingLeft,
@@ -1524,12 +1588,12 @@ var DefaultVolumeSlider = ({
1524
1588
  ...common
1525
1589
  };
1526
1590
  }, [isVertical]);
1527
- const randomId = typeof React5.useId === "undefined" ? "volume-slider" : React5.useId();
1528
- const [randomClass] = useState5(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
1591
+ const randomId = typeof React6.useId === "undefined" ? "volume-slider" : React6.useId();
1592
+ const [randomClass] = useState4(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
1529
1593
  const onVolumeChange = useCallback3((e) => {
1530
1594
  setVolume(parseFloat(e.target.value));
1531
1595
  }, [setVolume]);
1532
- const inputStyle = useMemo3(() => {
1596
+ const inputStyle = useMemo4(() => {
1533
1597
  const commonStyle = {
1534
1598
  WebkitAppearance: "none",
1535
1599
  backgroundColor: "rgba(255, 255, 255, 0.5)",
@@ -1572,12 +1636,12 @@ var DefaultVolumeSlider = ({
1572
1636
  return /* @__PURE__ */ jsxs3("div", {
1573
1637
  style: sliderContainer,
1574
1638
  children: [
1575
- /* @__PURE__ */ jsx7("style", {
1639
+ /* @__PURE__ */ jsx8("style", {
1576
1640
  dangerouslySetInnerHTML: {
1577
1641
  __html: sliderStyle
1578
1642
  }
1579
1643
  }),
1580
- /* @__PURE__ */ jsx7("input", {
1644
+ /* @__PURE__ */ jsx8("input", {
1581
1645
  ref: inputRef,
1582
1646
  "aria-label": "Change volume",
1583
1647
  className: randomClass,
@@ -1594,20 +1658,20 @@ var DefaultVolumeSlider = ({
1594
1658
  });
1595
1659
  };
1596
1660
  var renderDefaultVolumeSlider = (props) => {
1597
- return /* @__PURE__ */ jsx7(DefaultVolumeSlider, {
1661
+ return /* @__PURE__ */ jsx8(DefaultVolumeSlider, {
1598
1662
  ...props
1599
1663
  });
1600
1664
  };
1601
1665
 
1602
1666
  // src/MediaVolumeSlider.tsx
1603
- import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1667
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
1604
1668
  var VOLUME_SLIDER_WIDTH = 100;
1605
1669
  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);
1670
+ const [playerMuted, setPlayerMuted] = Internals9.usePlayerMutedState();
1671
+ const [mediaVolume, setMediaVolume] = Internals9.useMediaVolumeState();
1672
+ const [focused, setFocused] = useState5(false);
1673
+ const parentDivRef = useRef6(null);
1674
+ const inputRef = useRef6(null);
1611
1675
  const hover = useHoverState(parentDivRef, false);
1612
1676
  const onBlur = useCallback4(() => {
1613
1677
  setTimeout(() => {
@@ -1625,7 +1689,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1625
1689
  }
1626
1690
  setPlayerMuted((mute) => !mute);
1627
1691
  }, [isVolume0, setPlayerMuted, setMediaVolume]);
1628
- const parentDivStyle = useMemo4(() => {
1692
+ const parentDivStyle = useMemo5(() => {
1629
1693
  return {
1630
1694
  display: "inline-flex",
1631
1695
  background: "none",
@@ -1636,7 +1700,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1636
1700
  ...displayVerticalVolumeSlider && { position: "relative" }
1637
1701
  };
1638
1702
  }, [displayVerticalVolumeSlider]);
1639
- const volumeContainer = useMemo4(() => {
1703
+ const volumeContainer = useMemo5(() => {
1640
1704
  return {
1641
1705
  display: "inline",
1642
1706
  width: ICON_SIZE,
@@ -1650,7 +1714,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1650
1714
  }, []);
1651
1715
  const renderDefaultMuteButton = useCallback4(({ muted, volume }) => {
1652
1716
  const isMutedOrZero = muted || volume === 0;
1653
- return /* @__PURE__ */ jsx8("button", {
1717
+ return /* @__PURE__ */ jsx9("button", {
1654
1718
  "aria-label": isMutedOrZero ? "Unmute sound" : "Mute sound",
1655
1719
  title: isMutedOrZero ? "Unmute sound" : "Mute sound",
1656
1720
  onClick,
@@ -1658,14 +1722,14 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1658
1722
  onFocus: () => setFocused(true),
1659
1723
  style: volumeContainer,
1660
1724
  type: "button",
1661
- children: isMutedOrZero ? /* @__PURE__ */ jsx8(VolumeOffIcon, {}) : /* @__PURE__ */ jsx8(VolumeOnIcon, {})
1725
+ children: isMutedOrZero ? /* @__PURE__ */ jsx9(VolumeOffIcon, {}) : /* @__PURE__ */ jsx9(VolumeOnIcon, {})
1662
1726
  });
1663
1727
  }, [onBlur, onClick, volumeContainer]);
1664
- const muteButton = useMemo4(() => {
1728
+ const muteButton = useMemo5(() => {
1665
1729
  return renderMuteButton ? renderMuteButton({ muted: playerMuted, volume: mediaVolume }) : renderDefaultMuteButton({ muted: playerMuted, volume: mediaVolume });
1666
1730
  }, [playerMuted, mediaVolume, renderDefaultMuteButton, renderMuteButton]);
1667
- const volumeSlider = useMemo4(() => {
1668
- return (focused || hover) && !playerMuted && !Internals7.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
1731
+ const volumeSlider = useMemo5(() => {
1732
+ return (focused || hover) && !playerMuted && !Internals9.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
1669
1733
  isVertical: displayVerticalVolumeSlider,
1670
1734
  volume: mediaVolume,
1671
1735
  onBlur: () => setFocused(false),
@@ -1692,14 +1756,14 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
1692
1756
  };
1693
1757
 
1694
1758
  // 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";
1759
+ import { useCallback as useCallback5, useEffect as useEffect9, useMemo as useMemo6, useState as useState7 } from "react";
1760
+ import { Internals as Internals10 } from "remotion";
1697
1761
 
1698
1762
  // src/utils/use-component-visible.ts
1699
- import { useEffect as useEffect8, useRef as useRef6, useState as useState7 } from "react";
1763
+ import { useEffect as useEffect8, useRef as useRef7, useState as useState6 } from "react";
1700
1764
  function useComponentVisible(initialIsVisible) {
1701
- const [isComponentVisible, setIsComponentVisible] = useState7(initialIsVisible);
1702
- const ref = useRef6(null);
1765
+ const [isComponentVisible, setIsComponentVisible] = useState6(initialIsVisible);
1766
+ const ref = useRef7(null);
1703
1767
  useEffect8(() => {
1704
1768
  const handleClickOutside = (event) => {
1705
1769
  if (ref.current && !ref.current.contains(event.target)) {
@@ -1715,7 +1779,7 @@ function useComponentVisible(initialIsVisible) {
1715
1779
  }
1716
1780
 
1717
1781
  // src/PlaybackrateControl.tsx
1718
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1782
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1719
1783
  var BOTTOM = 35;
1720
1784
  var THRESHOLD = 70;
1721
1785
  var rateDiv = {
@@ -1736,10 +1800,10 @@ var checkmarkStyle = {
1736
1800
  height: 14,
1737
1801
  color: "black"
1738
1802
  };
1739
- var Checkmark = () => /* @__PURE__ */ jsx9("svg", {
1803
+ var Checkmark = () => /* @__PURE__ */ jsx10("svg", {
1740
1804
  viewBox: "0 0 512 512",
1741
1805
  style: checkmarkStyle,
1742
- children: /* @__PURE__ */ jsx9("path", {
1806
+ children: /* @__PURE__ */ jsx10("path", {
1743
1807
  fill: "currentColor",
1744
1808
  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
1809
  })
@@ -1754,7 +1818,7 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1754
1818
  e.preventDefault();
1755
1819
  onSelect(rate);
1756
1820
  }, [onSelect, rate]);
1757
- const [hovered, setHovered] = useState8(false);
1821
+ const [hovered, setHovered] = useState7(false);
1758
1822
  const onMouseEnter = useCallback5(() => {
1759
1823
  setHovered(true);
1760
1824
  }, []);
@@ -1762,7 +1826,7 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1762
1826
  setHovered(false);
1763
1827
  }, []);
1764
1828
  const isFocused = keyboardSelectedRate === rate;
1765
- const actualStyle = useMemo5(() => {
1829
+ const actualStyle = useMemo6(() => {
1766
1830
  return {
1767
1831
  ...rateDiv,
1768
1832
  backgroundColor: hovered || isFocused ? "#eee" : "transparent"
@@ -1775,9 +1839,9 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1775
1839
  style: actualStyle,
1776
1840
  onClick,
1777
1841
  children: [
1778
- /* @__PURE__ */ jsx9("div", {
1842
+ /* @__PURE__ */ jsx10("div", {
1779
1843
  style: checkmarkContainer,
1780
- children: rate === selectedRate ? /* @__PURE__ */ jsx9(Checkmark, {}) : null
1844
+ children: rate === selectedRate ? /* @__PURE__ */ jsx10(Checkmark, {}) : null
1781
1845
  }),
1782
1846
  formatPlaybackRate(rate),
1783
1847
  "x"
@@ -1785,8 +1849,8 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
1785
1849
  }, rate);
1786
1850
  };
1787
1851
  var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1788
- const { setPlaybackRate, playbackRate } = Internals8.usePlaybackRate();
1789
- const [keyboardSelectedRate, setKeyboardSelectedRate] = useState8(playbackRate);
1852
+ const { setPlaybackRate, playbackRate } = Internals10.usePlaybackRate();
1853
+ const [keyboardSelectedRate, setKeyboardSelectedRate] = useState7(playbackRate);
1790
1854
  useEffect9(() => {
1791
1855
  const listener = (e) => {
1792
1856
  e.preventDefault();
@@ -1829,7 +1893,7 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1829
1893
  setPlaybackRate(rate);
1830
1894
  setIsComponentVisible(false);
1831
1895
  }, [setIsComponentVisible, setPlaybackRate]);
1832
- const playbackPopup = useMemo5(() => {
1896
+ const playbackPopup = useMemo6(() => {
1833
1897
  return {
1834
1898
  position: "absolute",
1835
1899
  right: 0,
@@ -1843,10 +1907,10 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
1843
1907
  textAlign: "left"
1844
1908
  };
1845
1909
  }, [canvasSize.height]);
1846
- return /* @__PURE__ */ jsx9("div", {
1910
+ return /* @__PURE__ */ jsx10("div", {
1847
1911
  style: playbackPopup,
1848
1912
  children: playbackRates.map((rate) => {
1849
- return /* @__PURE__ */ jsx9(PlaybackrateOption, {
1913
+ return /* @__PURE__ */ jsx10(PlaybackrateOption, {
1850
1914
  selectedRate: playbackRate,
1851
1915
  onSelect,
1852
1916
  rate,
@@ -1887,13 +1951,13 @@ var button = {
1887
1951
  };
1888
1952
  var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1889
1953
  const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false);
1890
- const { playbackRate } = Internals8.usePlaybackRate();
1954
+ const { playbackRate } = Internals10.usePlaybackRate();
1891
1955
  const onClick = useCallback5((e) => {
1892
1956
  e.stopPropagation();
1893
1957
  e.preventDefault();
1894
1958
  setIsComponentVisible((prevIsComponentVisible) => !prevIsComponentVisible);
1895
1959
  }, [setIsComponentVisible]);
1896
- return /* @__PURE__ */ jsx9("div", {
1960
+ return /* @__PURE__ */ jsx10("div", {
1897
1961
  ref,
1898
1962
  children: /* @__PURE__ */ jsxs5("button", {
1899
1963
  type: "button",
@@ -1908,7 +1972,7 @@ var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1908
1972
  "x"
1909
1973
  ]
1910
1974
  }),
1911
- isComponentVisible && /* @__PURE__ */ jsx9(PlaybackPopup, {
1975
+ isComponentVisible && /* @__PURE__ */ jsx10(PlaybackPopup, {
1912
1976
  canvasSize,
1913
1977
  playbackRates,
1914
1978
  setIsComponentVisible
@@ -1919,9 +1983,9 @@ var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
1919
1983
  };
1920
1984
 
1921
1985
  // 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";
1986
+ import { useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo7, useRef as useRef8, useState as useState8 } from "react";
1987
+ import { Internals as Internals11, interpolate } from "remotion";
1988
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1925
1989
  var getFrameFromX = (clientX, durationInFrames, width) => {
1926
1990
  const pos = clientX;
1927
1991
  const frame = Math.round(interpolate(pos, [0, width], [0, durationInFrames - 1], {
@@ -1957,15 +2021,15 @@ var findBodyInWhichDivIsLocated = (div) => {
1957
2021
  return current;
1958
2022
  };
1959
2023
  var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFrame }) => {
1960
- const containerRef = useRef7(null);
2024
+ const containerRef = useRef8(null);
1961
2025
  const barHovered = useHoverState(containerRef, false);
1962
2026
  const size = useElementSize(containerRef, {
1963
2027
  triggerOnWindowResize: true,
1964
2028
  shouldApplyCssTransforms: true
1965
2029
  });
1966
- const { seek, play, pause, playing } = usePlayer();
1967
- const frame = Internals9.Timeline.useTimelinePosition();
1968
- const [dragging, setDragging] = useState9({
2030
+ const { seek, play, pause, isPlaying } = usePlayerMethods();
2031
+ const frame = Internals11.Timeline.useTimelinePosition();
2032
+ const [dragging, setDragging] = useState8({
1969
2033
  dragging: false
1970
2034
  });
1971
2035
  const width = size?.width ?? 0;
@@ -1975,14 +2039,15 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
1975
2039
  }
1976
2040
  const posLeft = containerRef.current?.getBoundingClientRect().left;
1977
2041
  const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, width);
2042
+ const wasPlaying = isPlaying();
1978
2043
  pause();
1979
2044
  seek(_frame);
1980
2045
  setDragging({
1981
2046
  dragging: true,
1982
- wasPlaying: playing
2047
+ wasPlaying
1983
2048
  });
1984
2049
  onSeekStart();
1985
- }, [durationInFrames, width, pause, seek, playing, onSeekStart]);
2050
+ }, [durationInFrames, width, isPlaying, pause, seek, onSeekStart]);
1986
2051
  const onPointerMove = useCallback6((e) => {
1987
2052
  if (!size) {
1988
2053
  throw new Error("Player has no size");
@@ -2020,7 +2085,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2020
2085
  body.removeEventListener("pointerup", onPointerUp);
2021
2086
  };
2022
2087
  }, [dragging.dragging, onPointerMove, onPointerUp]);
2023
- const knobStyle = useMemo6(() => {
2088
+ const knobStyle = useMemo7(() => {
2024
2089
  return {
2025
2090
  height: KNOB_SIZE2,
2026
2091
  width: KNOB_SIZE2,
@@ -2033,7 +2098,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2033
2098
  opacity: Number(barHovered || dragging.dragging)
2034
2099
  };
2035
2100
  }, [barHovered, dragging.dragging, durationInFrames, frame, width]);
2036
- const fillStyle = useMemo6(() => {
2101
+ const fillStyle = useMemo7(() => {
2037
2102
  return {
2038
2103
  height: BAR_HEIGHT2,
2039
2104
  backgroundColor: "rgba(255, 255, 255, 1)",
@@ -2042,7 +2107,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2042
2107
  borderRadius: BAR_HEIGHT2 / 2
2043
2108
  };
2044
2109
  }, [durationInFrames, frame, inFrame, width]);
2045
- const active = useMemo6(() => {
2110
+ const active = useMemo7(() => {
2046
2111
  return {
2047
2112
  height: BAR_HEIGHT2,
2048
2113
  backgroundColor: "rgba(255, 255, 255, 0.25)",
@@ -2060,15 +2125,15 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2060
2125
  /* @__PURE__ */ jsxs6("div", {
2061
2126
  style: barBackground,
2062
2127
  children: [
2063
- /* @__PURE__ */ jsx10("div", {
2128
+ /* @__PURE__ */ jsx11("div", {
2064
2129
  style: active
2065
2130
  }),
2066
- /* @__PURE__ */ jsx10("div", {
2131
+ /* @__PURE__ */ jsx11("div", {
2067
2132
  style: fillStyle
2068
2133
  })
2069
2134
  ]
2070
2135
  }),
2071
- /* @__PURE__ */ jsx10("div", {
2136
+ /* @__PURE__ */ jsx11("div", {
2072
2137
  style: knobStyle
2073
2138
  })
2074
2139
  ]
@@ -2076,8 +2141,8 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
2076
2141
  };
2077
2142
 
2078
2143
  // src/PlayerTimeLabel.tsx
2079
- import { useMemo as useMemo7 } from "react";
2080
- import { Internals as Internals10 } from "remotion";
2144
+ import { useMemo as useMemo8 } from "react";
2145
+ import { Internals as Internals12 } from "remotion";
2081
2146
 
2082
2147
  // src/format-time.ts
2083
2148
  var formatTime = (timeInSeconds) => {
@@ -2089,8 +2154,8 @@ var formatTime = (timeInSeconds) => {
2089
2154
  // src/PlayerTimeLabel.tsx
2090
2155
  import { jsxs as jsxs7 } from "react/jsx-runtime";
2091
2156
  var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
2092
- const frame = Internals10.Timeline.useTimelinePosition();
2093
- const timeLabel = useMemo7(() => {
2157
+ const frame = Internals12.Timeline.useTimelinePosition();
2158
+ const timeLabel = useMemo8(() => {
2094
2159
  return {
2095
2160
  color: "white",
2096
2161
  fontFamily: "sans-serif",
@@ -2113,14 +2178,14 @@ var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
2113
2178
  };
2114
2179
 
2115
2180
  // src/use-video-controls-resize.ts
2116
- import { useMemo as useMemo8 } from "react";
2181
+ import { useMemo as useMemo9 } from "react";
2117
2182
  var X_SPACER = 10;
2118
2183
  var X_PADDING = 12;
2119
2184
  var useVideoControlsResize = ({
2120
2185
  allowFullscreen: allowFullScreen,
2121
2186
  playerWidth
2122
2187
  }) => {
2123
- const resizeInfo = useMemo8(() => {
2188
+ const resizeInfo = useMemo9(() => {
2124
2189
  const playPauseIconSize = ICON_SIZE;
2125
2190
  const volumeIconSize = ICON_SIZE;
2126
2191
  const _fullscreenIconSize = allowFullScreen ? fullscreenIconSize : 0;
@@ -2140,7 +2205,7 @@ var useVideoControlsResize = ({
2140
2205
  };
2141
2206
 
2142
2207
  // src/PlayerControls.tsx
2143
- import { jsx as jsx11, jsxs as jsxs8, Fragment as Fragment2 } from "react/jsx-runtime";
2208
+ import { jsx as jsx12, jsxs as jsxs8, Fragment as Fragment2 } from "react/jsx-runtime";
2144
2209
  var gradientSteps = [
2145
2210
  0,
2146
2211
  0.013,
@@ -2249,14 +2314,14 @@ var Controls = ({
2249
2314
  toggle,
2250
2315
  renderCustomControls
2251
2316
  }) => {
2252
- const playButtonRef = useRef8(null);
2253
- const [supportsFullscreen, setSupportsFullscreen] = useState10(false);
2317
+ const playButtonRef = useRef9(null);
2318
+ const [supportsFullscreen, setSupportsFullscreen] = useState9(false);
2254
2319
  const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
2255
2320
  const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
2256
2321
  allowFullscreen,
2257
2322
  playerWidth: canvasSize?.width ?? 0
2258
2323
  });
2259
- const [shouldShowInitially, setInitiallyShowControls] = useState10(() => {
2324
+ const [shouldShowInitially, setInitiallyShowControls] = useState9(() => {
2260
2325
  if (typeof initiallyShowControls === "boolean") {
2261
2326
  return initiallyShowControls;
2262
2327
  }
@@ -2277,7 +2342,7 @@ var Controls = ({
2277
2342
  }
2278
2343
  throw new TypeError("initiallyShowControls must be a number or a boolean");
2279
2344
  });
2280
- const containerCss = useMemo9(() => {
2345
+ const containerCss = useMemo10(() => {
2281
2346
  const shouldShow = hovered || !playing || shouldShowInitially || alwaysShowControls;
2282
2347
  return {
2283
2348
  ...containerStyle2,
@@ -2306,7 +2371,7 @@ var Controls = ({
2306
2371
  clearInterval(timeout);
2307
2372
  };
2308
2373
  }, [shouldShowInitially]);
2309
- const playbackRates = useMemo9(() => {
2374
+ const playbackRates = useMemo10(() => {
2310
2375
  if (showPlaybackRateControl === true) {
2311
2376
  return [0.5, 0.8, 1, 1.2, 1.5, 1.8, 2, 2.5, 3];
2312
2377
  }
@@ -2324,8 +2389,8 @@ var Controls = ({
2324
2389
  return null;
2325
2390
  }, [showPlaybackRateControl]);
2326
2391
  const customControlsElement = renderCustomControls ? renderCustomControls() : null;
2327
- const ref = useRef8(null);
2328
- const flexRef = useRef8(null);
2392
+ const ref = useRef9(null);
2393
+ const flexRef = useRef9(null);
2329
2394
  const onPointerDownIfContainer = useCallback7((e) => {
2330
2395
  if (e.target === ref.current || e.target === flexRef.current) {
2331
2396
  onPointerDown?.(e);
@@ -2349,82 +2414,82 @@ var Controls = ({
2349
2414
  /* @__PURE__ */ jsxs8("div", {
2350
2415
  style: leftPartStyle,
2351
2416
  children: [
2352
- /* @__PURE__ */ jsx11("button", {
2417
+ /* @__PURE__ */ jsx12("button", {
2353
2418
  ref: playButtonRef,
2354
2419
  type: "button",
2355
2420
  style: playerButtonStyle,
2356
2421
  onClick: toggle,
2357
2422
  "aria-label": playing ? "Pause video" : "Play video",
2358
2423
  title: playing ? "Pause video" : "Play video",
2359
- children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
2424
+ children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx12(DefaultPlayPauseButton, {
2360
2425
  buffering,
2361
2426
  playing
2362
2427
  }) : renderPlayPauseButton({
2363
2428
  playing,
2364
2429
  isBuffering: buffering
2365
- }) ?? /* @__PURE__ */ jsx11(DefaultPlayPauseButton, {
2430
+ }) ?? /* @__PURE__ */ jsx12(DefaultPlayPauseButton, {
2366
2431
  buffering,
2367
2432
  playing
2368
2433
  })
2369
2434
  }),
2370
2435
  showVolumeControls ? /* @__PURE__ */ jsxs8(Fragment2, {
2371
2436
  children: [
2372
- /* @__PURE__ */ jsx11("div", {
2437
+ /* @__PURE__ */ jsx12("div", {
2373
2438
  style: xSpacer
2374
2439
  }),
2375
- /* @__PURE__ */ jsx11(MediaVolumeSlider, {
2440
+ /* @__PURE__ */ jsx12(MediaVolumeSlider, {
2376
2441
  renderMuteButton,
2377
2442
  renderVolumeSlider,
2378
2443
  displayVerticalVolumeSlider
2379
2444
  })
2380
2445
  ]
2381
2446
  }) : null,
2382
- /* @__PURE__ */ jsx11("div", {
2447
+ /* @__PURE__ */ jsx12("div", {
2383
2448
  style: xSpacer
2384
2449
  }),
2385
- /* @__PURE__ */ jsx11(PlayerTimeLabel, {
2450
+ /* @__PURE__ */ jsx12(PlayerTimeLabel, {
2386
2451
  durationInFrames,
2387
2452
  fps,
2388
2453
  maxTimeLabelWidth
2389
2454
  }),
2390
- /* @__PURE__ */ jsx11("div", {
2455
+ /* @__PURE__ */ jsx12("div", {
2391
2456
  style: xSpacer
2392
2457
  })
2393
2458
  ]
2394
2459
  }),
2395
- /* @__PURE__ */ jsx11("div", {
2460
+ /* @__PURE__ */ jsx12("div", {
2396
2461
  style: flex1
2397
2462
  }),
2398
2463
  customControlsElement,
2399
- customControlsElement && playbackRates && canvasSize ? /* @__PURE__ */ jsx11("div", {
2464
+ customControlsElement && playbackRates && canvasSize ? /* @__PURE__ */ jsx12("div", {
2400
2465
  style: xSpacer
2401
2466
  }) : null,
2402
- playbackRates && canvasSize && /* @__PURE__ */ jsx11(PlaybackrateControl, {
2467
+ playbackRates && canvasSize && /* @__PURE__ */ jsx12(PlaybackrateControl, {
2403
2468
  canvasSize,
2404
2469
  playbackRates
2405
2470
  }),
2406
- playbackRates && supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("div", {
2471
+ playbackRates && supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx12("div", {
2407
2472
  style: xSpacer
2408
2473
  }) : null,
2409
- /* @__PURE__ */ jsx11("div", {
2474
+ /* @__PURE__ */ jsx12("div", {
2410
2475
  style: fullscreen,
2411
- children: supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx11("button", {
2476
+ children: supportsFullscreen && allowFullscreen ? /* @__PURE__ */ jsx12("button", {
2412
2477
  type: "button",
2413
2478
  "aria-label": isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
2414
2479
  title: isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
2415
2480
  style: playerButtonStyle,
2416
2481
  onClick: isFullscreen ? onExitFullscreenButtonClick : onFullscreenButtonClick,
2417
- children: renderFullscreenButton === null ? /* @__PURE__ */ jsx11(FullscreenIcon, {
2482
+ children: renderFullscreenButton === null ? /* @__PURE__ */ jsx12(FullscreenIcon, {
2418
2483
  isFullscreen
2419
2484
  }) : renderFullscreenButton({ isFullscreen })
2420
2485
  }) : null
2421
2486
  })
2422
2487
  ]
2423
2488
  }),
2424
- /* @__PURE__ */ jsx11("div", {
2489
+ /* @__PURE__ */ jsx12("div", {
2425
2490
  style: ySpacer
2426
2491
  }),
2427
- /* @__PURE__ */ jsx11(PlayerSeekBar, {
2492
+ /* @__PURE__ */ jsx12(PlayerSeekBar, {
2428
2493
  onSeekEnd,
2429
2494
  onSeekStart,
2430
2495
  durationInFrames,
@@ -2439,7 +2504,7 @@ var Controls = ({
2439
2504
  var IS_NODE = typeof document === "undefined";
2440
2505
 
2441
2506
  // src/utils/use-click-prevention-on-double-click.ts
2442
- import { useCallback as useCallback9, useMemo as useMemo11 } from "react";
2507
+ import { useCallback as useCallback9, useMemo as useMemo12 } from "react";
2443
2508
 
2444
2509
  // src/utils/cancellable-promise.ts
2445
2510
  var cancellablePromise = (promise) => {
@@ -2467,9 +2532,9 @@ var cancellablePromise = (promise) => {
2467
2532
  var delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
2468
2533
 
2469
2534
  // src/utils/use-cancellable-promises.ts
2470
- import { useCallback as useCallback8, useMemo as useMemo10, useRef as useRef9 } from "react";
2535
+ import { useCallback as useCallback8, useMemo as useMemo11, useRef as useRef10 } from "react";
2471
2536
  var useCancellablePromises = () => {
2472
- const pendingPromises = useRef9([]);
2537
+ const pendingPromises = useRef10([]);
2473
2538
  const appendPendingPromise = useCallback8((promise) => {
2474
2539
  pendingPromises.current = [...pendingPromises.current, promise];
2475
2540
  }, []);
@@ -2477,7 +2542,7 @@ var useCancellablePromises = () => {
2477
2542
  pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
2478
2543
  }, []);
2479
2544
  const clearPendingPromises = useCallback8(() => pendingPromises.current.map((p) => p.cancel()), []);
2480
- const api = useMemo10(() => ({
2545
+ const api = useMemo11(() => ({
2481
2546
  appendPendingPromise,
2482
2547
  removePendingPromise,
2483
2548
  clearPendingPromises
@@ -2519,7 +2584,7 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
2519
2584
  api.clearPendingPromises();
2520
2585
  onDoubleClick();
2521
2586
  }, [api, onDoubleClick]);
2522
- const returnValue = useMemo11(() => {
2587
+ const returnValue = useMemo12(() => {
2523
2588
  if (!doubleClickToFullscreen) {
2524
2589
  return { handlePointerDown: onClick, handleDoubleClick: () => {
2525
2590
  return;
@@ -2531,8 +2596,8 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
2531
2596
  };
2532
2597
 
2533
2598
  // 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];
2599
+ import { jsx as jsx13, jsxs as jsxs9, Fragment as Fragment3 } from "react/jsx-runtime";
2600
+ var reactVersion = React11.version.split(".")[0];
2536
2601
  if (reactVersion === "0") {
2537
2602
  throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
2538
2603
  }
@@ -2577,26 +2642,35 @@ var PlayerUI = ({
2577
2642
  overrideInternalClassName,
2578
2643
  noSuspense
2579
2644
  }, ref) => {
2580
- const config = Internals11.useUnsafeVideoConfig();
2581
- const video = Internals11.useVideo();
2582
- const container = useRef10(null);
2645
+ const config = Internals13.useUnsafeVideoConfig();
2646
+ const video = Internals13.useVideo();
2647
+ const container = useRef11(null);
2583
2648
  const canvasSize = useElementSize(container, {
2584
2649
  triggerOnWindowResize: false,
2585
2650
  shouldApplyCssTransforms: false
2586
2651
  });
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(() => {
2652
+ const [hasPausedToResume, setHasPausedToResume] = useState10(false);
2653
+ const [shouldAutoplay, setShouldAutoPlay] = useState10(autoPlay);
2654
+ const [isFullscreen, setIsFullscreen] = useState10(() => false);
2655
+ const [seeking, setSeeking] = useState10(false);
2656
+ const [hasPlayed, setHasPlayed] = useState10(false);
2657
+ const supportsFullScreen = useMemo13(() => {
2592
2658
  if (typeof document === "undefined") {
2593
2659
  return false;
2594
2660
  }
2595
2661
  return Boolean(document.fullscreenEnabled || document.webkitFullscreenEnabled);
2596
2662
  }, []);
2597
- const player = usePlayer();
2598
- const playerToggle = player.toggle;
2599
- const { playerMuted, mediaVolume } = useContext5(Internals11.MediaVolumeContext);
2663
+ const player = usePlayerMethods();
2664
+ const [playing] = Internals13.Timeline.usePlayingState();
2665
+ const frame = Internals13.Timeline.useTimelinePosition();
2666
+ const play = useCallback10((e) => {
2667
+ if (player.isPlaying()) {
2668
+ return;
2669
+ }
2670
+ setHasPlayed(true);
2671
+ player.play(e);
2672
+ }, [player]);
2673
+ const { playerMuted, mediaVolume } = useContext5(Internals13.MediaVolumeContext);
2600
2674
  useEffect12(() => {
2601
2675
  player.emitter.dispatchVolumeChange(mediaVolume);
2602
2676
  }, [player.emitter, mediaVolume]);
@@ -2617,11 +2691,11 @@ var PlayerUI = ({
2617
2691
  muted: isMuted
2618
2692
  });
2619
2693
  useEffect12(() => {
2620
- if (hasPausedToResume && !player.playing) {
2694
+ if (hasPausedToResume && !playing) {
2621
2695
  setHasPausedToResume(false);
2622
- player.play();
2696
+ play();
2623
2697
  }
2624
- }, [hasPausedToResume, player]);
2698
+ }, [hasPausedToResume, play, playing]);
2625
2699
  useEffect12(() => {
2626
2700
  const { current } = container;
2627
2701
  if (!current) {
@@ -2639,8 +2713,12 @@ var PlayerUI = ({
2639
2713
  };
2640
2714
  }, []);
2641
2715
  const toggle = useCallback10((e) => {
2642
- playerToggle(e);
2643
- }, [playerToggle]);
2716
+ if (player.isPlaying()) {
2717
+ player.pause();
2718
+ } else {
2719
+ play(e);
2720
+ }
2721
+ }, [play, player]);
2644
2722
  const requestFullscreen = useCallback10(() => {
2645
2723
  if (!allowFullscreen) {
2646
2724
  throw new Error("allowFullscreen is false");
@@ -2689,7 +2767,7 @@ var PlayerUI = ({
2689
2767
  };
2690
2768
  }, [player.emitter]);
2691
2769
  const durationInFrames = config?.durationInFrames ?? 1;
2692
- const layout = useMemo12(() => {
2770
+ const layout = useMemo13(() => {
2693
2771
  if (!config || !canvasSize) {
2694
2772
  return null;
2695
2773
  }
@@ -2701,7 +2779,7 @@ var PlayerUI = ({
2701
2779
  });
2702
2780
  }, [canvasSize, config]);
2703
2781
  const scale = layout?.scale ?? 1;
2704
- const initialScaleIgnored = useRef10(false);
2782
+ const initialScaleIgnored = useRef11(false);
2705
2783
  useEffect12(() => {
2706
2784
  if (!initialScaleIgnored.current) {
2707
2785
  initialScaleIgnored.current = true;
@@ -2709,8 +2787,8 @@ var PlayerUI = ({
2709
2787
  }
2710
2788
  player.emitter.dispatchScaleChange(scale);
2711
2789
  }, [player.emitter, scale]);
2712
- const { setMediaVolume, setPlayerMuted } = useContext5(Internals11.SetMediaVolumeContext);
2713
- const [showBufferIndicator, setShowBufferState] = useState11(false);
2790
+ const { setMediaVolume, setPlayerMuted } = useContext5(Internals13.SetMediaVolumeContext);
2791
+ const [showBufferIndicator, setShowBufferState] = useState10(false);
2714
2792
  useEffect12(() => {
2715
2793
  let timeout = null;
2716
2794
  let stopped = false;
@@ -2751,7 +2829,7 @@ var PlayerUI = ({
2751
2829
  }, [bufferStateDelayInMilliseconds, player.emitter]);
2752
2830
  useImperativeHandle(ref, () => {
2753
2831
  const methods = {
2754
- play: player.play,
2832
+ play,
2755
2833
  pause: () => {
2756
2834
  setHasPausedToResume(false);
2757
2835
  player.pause();
@@ -2821,6 +2899,7 @@ var PlayerUI = ({
2821
2899
  isMuted,
2822
2900
  mediaVolume,
2823
2901
  player,
2902
+ play,
2824
2903
  requestFullscreen,
2825
2904
  setPlayerMuted,
2826
2905
  setMediaVolume,
@@ -2828,7 +2907,7 @@ var PlayerUI = ({
2828
2907
  scale
2829
2908
  ]);
2830
2909
  const VideoComponent = video ? video.component : null;
2831
- const outerStyle = useMemo12(() => {
2910
+ const outerStyle = useMemo13(() => {
2832
2911
  return calculateOuterStyle({
2833
2912
  canvasSize,
2834
2913
  config,
@@ -2837,10 +2916,10 @@ var PlayerUI = ({
2837
2916
  layout
2838
2917
  });
2839
2918
  }, [canvasSize, config, layout, overflowVisible, style2]);
2840
- const outer = useMemo12(() => {
2919
+ const outer = useMemo13(() => {
2841
2920
  return calculateOuter({ config, layout, scale, overflowVisible });
2842
2921
  }, [config, layout, overflowVisible, scale]);
2843
- const containerStyle3 = useMemo12(() => {
2922
+ const containerStyle3 = useMemo13(() => {
2844
2923
  return calculateContainerStyle({
2845
2924
  config,
2846
2925
  layout,
@@ -2885,18 +2964,18 @@ var PlayerUI = ({
2885
2964
  const { handlePointerDown, handleDoubleClick } = useClickPreventionOnDoubleClick(onSingleClick, onDoubleClick, doubleClickToFullscreen && allowFullscreen && supportsFullScreen);
2886
2965
  useEffect12(() => {
2887
2966
  if (shouldAutoplay) {
2888
- player.play();
2967
+ play();
2889
2968
  setShouldAutoPlay(false);
2890
2969
  }
2891
- }, [shouldAutoplay, player]);
2892
- const loadingMarkup = useMemo12(() => {
2970
+ }, [play, shouldAutoplay]);
2971
+ const loadingMarkup = useMemo13(() => {
2893
2972
  return renderLoading ? renderLoading({
2894
2973
  height: outerStyle.height,
2895
2974
  width: outerStyle.width,
2896
2975
  isBuffering: showBufferIndicator
2897
2976
  }) : null;
2898
2977
  }, [outerStyle.height, outerStyle.width, renderLoading, showBufferIndicator]);
2899
- const currentScale = useMemo12(() => {
2978
+ const currentScale = useMemo13(() => {
2900
2979
  return {
2901
2980
  type: "scale",
2902
2981
  scale
@@ -2915,8 +2994,8 @@ var PlayerUI = ({
2915
2994
  }
2916
2995
  const shouldShowPoster = poster && [
2917
2996
  showPosterWhenPaused && !player.isPlaying() && !seeking,
2918
- showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
2919
- showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
2997
+ showPosterWhenEnded && frame === durationInFrames - 1 && !player.isPlaying(),
2998
+ showPosterWhenUnplayed && !hasPlayed && !player.isPlaying(),
2920
2999
  showPosterWhenBuffering && showBufferIndicator && player.isPlaying(),
2921
3000
  showPosterWhenBufferingAndPaused && showBufferIndicator && !player.isPlaying()
2922
3001
  ].some(Boolean);
@@ -2932,18 +3011,18 @@ var PlayerUI = ({
2932
3011
  style: containerStyle3,
2933
3012
  className: playerCssClassname(overrideInternalClassName),
2934
3013
  children: [
2935
- VideoComponent ? /* @__PURE__ */ jsx12(ErrorBoundary, {
3014
+ VideoComponent ? /* @__PURE__ */ jsx13(ErrorBoundary, {
2936
3015
  onError,
2937
3016
  errorFallback,
2938
- children: /* @__PURE__ */ jsx12(Internals11.CurrentScaleContext.Provider, {
3017
+ children: /* @__PURE__ */ jsx13(Internals13.CurrentScaleContext.Provider, {
2939
3018
  value: currentScale,
2940
- children: /* @__PURE__ */ jsx12(VideoComponent, {
3019
+ children: /* @__PURE__ */ jsx13(VideoComponent, {
2941
3020
  ...video?.props ?? {},
2942
3021
  ...inputProps ?? {}
2943
3022
  })
2944
3023
  })
2945
3024
  }) : null,
2946
- shouldShowPoster && posterFillMode === "composition-size" ? /* @__PURE__ */ jsx12("div", {
3025
+ shouldShowPoster && posterFillMode === "composition-size" ? /* @__PURE__ */ jsx13("div", {
2947
3026
  style: {
2948
3027
  ...outerWithoutScale,
2949
3028
  width: config.width,
@@ -2955,19 +3034,19 @@ var PlayerUI = ({
2955
3034
  }) : null
2956
3035
  ]
2957
3036
  }),
2958
- /* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {})
3037
+ /* @__PURE__ */ jsx13(RenderWarningIfBlacklist, {})
2959
3038
  ]
2960
3039
  }),
2961
- shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx12("div", {
3040
+ shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx13("div", {
2962
3041
  style: outer,
2963
3042
  onPointerDown: clickToPlay ? handlePointerDown : undefined,
2964
3043
  onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
2965
3044
  children: poster
2966
3045
  }) : null,
2967
- controls ? /* @__PURE__ */ jsx12(Controls, {
3046
+ controls ? /* @__PURE__ */ jsx13(Controls, {
2968
3047
  fps: config.fps,
2969
- playing: player.playing,
2970
- toggle: player.toggle,
3048
+ playing,
3049
+ toggle,
2971
3050
  durationInFrames: config.durationInFrames,
2972
3051
  containerRef: container,
2973
3052
  onFullscreenButtonClick,
@@ -2997,18 +3076,18 @@ var PlayerUI = ({
2997
3076
  ]
2998
3077
  });
2999
3078
  if (noSuspense || IS_NODE && !doesReactVersionSupportSuspense) {
3000
- return /* @__PURE__ */ jsx12("div", {
3079
+ return /* @__PURE__ */ jsx13("div", {
3001
3080
  ref: container,
3002
3081
  style: outerStyle,
3003
3082
  className: className2,
3004
3083
  children: content
3005
3084
  });
3006
3085
  }
3007
- return /* @__PURE__ */ jsx12("div", {
3086
+ return /* @__PURE__ */ jsx13("div", {
3008
3087
  ref: container,
3009
3088
  style: outerStyle,
3010
3089
  className: className2,
3011
- children: /* @__PURE__ */ jsx12(Suspense, {
3090
+ children: /* @__PURE__ */ jsx13(Suspense, {
3012
3091
  fallback: loadingMarkup,
3013
3092
  children: content
3014
3093
  })
@@ -3017,11 +3096,11 @@ var PlayerUI = ({
3017
3096
  var PlayerUI_default = forwardRef(PlayerUI);
3018
3097
 
3019
3098
  // 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";
3099
+ import { useCallback as useCallback11, useMemo as useMemo14, useRef as useRef12, useState as useState11 } from "react";
3100
+ import { Internals as Internals15 } from "remotion";
3022
3101
 
3023
3102
  // src/volume-persistence.ts
3024
- import { Internals as Internals12 } from "remotion";
3103
+ import { Internals as Internals14 } from "remotion";
3025
3104
  var DEFAULT_VOLUME_PERSISTENCE_KEY = "remotion.volumePreference";
3026
3105
  var persistVolume = (volume, logLevel, volumePersistenceKey) => {
3027
3106
  if (typeof window === "undefined") {
@@ -3030,7 +3109,7 @@ var persistVolume = (volume, logLevel, volumePersistenceKey) => {
3030
3109
  try {
3031
3110
  window.localStorage.setItem(volumePersistenceKey ?? DEFAULT_VOLUME_PERSISTENCE_KEY, String(volume));
3032
3111
  } catch (e) {
3033
- Internals12.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
3112
+ Internals14.Log.error({ logLevel, tag: null }, "Could not persist volume", e);
3034
3113
  }
3035
3114
  };
3036
3115
  var getPreferredVolume = (volumePersistenceKey) => {
@@ -3046,7 +3125,7 @@ var getPreferredVolume = (volumePersistenceKey) => {
3046
3125
  };
3047
3126
 
3048
3127
  // src/SharedPlayerContext.tsx
3049
- import { jsx as jsx13 } from "react/jsx-runtime";
3128
+ import { jsx as jsx14 } from "react/jsx-runtime";
3050
3129
  var PLAYER_COMP_ID = "player-comp";
3051
3130
  var SharedPlayerContexts = ({
3052
3131
  children,
@@ -3068,7 +3147,7 @@ var SharedPlayerContexts = ({
3068
3147
  audioEnabled
3069
3148
  }) => {
3070
3149
  const persistVolumeToStorage = initialVolume === undefined;
3071
- const compositionManagerContext = useMemo13(() => {
3150
+ const compositionManagerContext = useMemo14(() => {
3072
3151
  const context = {
3073
3152
  compositions: [
3074
3153
  {
@@ -3111,15 +3190,15 @@ var SharedPlayerContexts = ({
3111
3190
  fps,
3112
3191
  inputProps
3113
3192
  ]);
3114
- const [playerMuted, setPlayerMuted] = useState12(() => initiallyMuted);
3115
- const [mediaVolume, setMediaVolume] = useState12(() => persistVolumeToStorage ? getPreferredVolume(volumePersistenceKey ?? null) : initialVolume);
3116
- const mediaVolumeContextValue = useMemo13(() => {
3193
+ const [playerMuted, setPlayerMuted] = useState11(() => initiallyMuted);
3194
+ const [mediaVolume, setMediaVolume] = useState11(() => persistVolumeToStorage ? getPreferredVolume(volumePersistenceKey ?? null) : initialVolume);
3195
+ const mediaVolumeContextValue = useMemo14(() => {
3117
3196
  return {
3118
3197
  playerMuted,
3119
3198
  mediaVolume
3120
3199
  };
3121
3200
  }, [playerMuted, mediaVolume]);
3122
- const audioContextWasCreated = useRef11(false);
3201
+ const audioContextWasCreated = useRef12(false);
3123
3202
  const shouldCreateAudioContext = audioContextWasCreated.current || audioEnabled && !playerMuted && mediaVolume > 0;
3124
3203
  audioContextWasCreated.current = shouldCreateAudioContext;
3125
3204
  const setMediaVolumeAndPersist = useCallback11((vol) => {
@@ -3128,19 +3207,19 @@ var SharedPlayerContexts = ({
3128
3207
  persistVolume(vol, logLevel, volumePersistenceKey ?? null);
3129
3208
  }
3130
3209
  }, [persistVolumeToStorage, logLevel, volumePersistenceKey]);
3131
- const setMediaVolumeContextValue = useMemo13(() => {
3210
+ const setMediaVolumeContextValue = useMemo14(() => {
3132
3211
  return {
3133
3212
  setPlayerMuted,
3134
3213
  setMediaVolume: setMediaVolumeAndPersist
3135
3214
  };
3136
3215
  }, [setMediaVolumeAndPersist]);
3137
- const logLevelContext = useMemo13(() => {
3216
+ const logLevelContext = useMemo14(() => {
3138
3217
  return {
3139
3218
  logLevel,
3140
3219
  mountTime: Date.now()
3141
3220
  };
3142
3221
  }, [logLevel]);
3143
- const env = useMemo13(() => {
3222
+ const env = useMemo14(() => {
3144
3223
  return {
3145
3224
  isPlayer: true,
3146
3225
  isRendering: false,
@@ -3149,33 +3228,45 @@ var SharedPlayerContexts = ({
3149
3228
  isReadOnlyStudio: false
3150
3229
  };
3151
3230
  }, []);
3152
- return /* @__PURE__ */ jsx13(Internals13.RemotionEnvironmentContext.Provider, {
3231
+ const frameRef = useRef12(timelineContext.frame);
3232
+ frameRef.current = timelineContext.frame;
3233
+ const timelineImperativeContextValue = useMemo14(() => {
3234
+ return {
3235
+ frameRef,
3236
+ imperativePlaying: timelineContext.imperativePlaying,
3237
+ audioAndVideoTags: timelineContext.audioAndVideoTags
3238
+ };
3239
+ }, [timelineContext.audioAndVideoTags, timelineContext.imperativePlaying]);
3240
+ return /* @__PURE__ */ jsx14(Internals15.RemotionEnvironmentContext.Provider, {
3153
3241
  value: env,
3154
- children: /* @__PURE__ */ jsx13(Internals13.LogLevelContext.Provider, {
3242
+ children: /* @__PURE__ */ jsx14(Internals15.LogLevelContext.Provider, {
3155
3243
  value: logLevelContext,
3156
- children: /* @__PURE__ */ jsx13(Internals13.CanUseRemotionHooksProvider, {
3157
- children: /* @__PURE__ */ jsx13(Internals13.AbsoluteTimeContext.Provider, {
3244
+ children: /* @__PURE__ */ jsx14(Internals15.CanUseRemotionHooksProvider, {
3245
+ children: /* @__PURE__ */ jsx14(Internals15.AbsoluteTimeContext.Provider, {
3158
3246
  value: timelineContext,
3159
- children: /* @__PURE__ */ jsx13(Internals13.PlaybackRateContext.Provider, {
3247
+ children: /* @__PURE__ */ jsx14(Internals15.PlaybackRateContext.Provider, {
3160
3248
  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
3249
+ children: /* @__PURE__ */ jsx14(CoreTimelineImperativeContextProvider, {
3250
+ value: timelineImperativeContextValue,
3251
+ children: /* @__PURE__ */ jsx14(Internals15.TimelineContext.Provider, {
3252
+ value: timelineContext,
3253
+ children: /* @__PURE__ */ jsx14(Internals15.CompositionManager.Provider, {
3254
+ value: compositionManagerContext,
3255
+ children: /* @__PURE__ */ jsx14(Internals15.PrefetchProvider, {
3256
+ children: /* @__PURE__ */ jsx14(Internals15.DurationsContextProvider, {
3257
+ children: /* @__PURE__ */ jsx14(Internals15.MediaVolumeContext.Provider, {
3258
+ value: mediaVolumeContextValue,
3259
+ children: /* @__PURE__ */ jsx14(Internals15.SetMediaVolumeContext.Provider, {
3260
+ value: setMediaVolumeContextValue,
3261
+ children: /* @__PURE__ */ jsx14(Internals15.BufferingProvider, {
3262
+ children: /* @__PURE__ */ jsx14(Internals15.SharedAudioContextProvider, {
3263
+ audioLatencyHint,
3264
+ audioEnabled: shouldCreateAudioContext,
3265
+ previewSampleRate: sampleRate,
3266
+ children: /* @__PURE__ */ jsx14(Internals15.SharedAudioTagsContextProvider, {
3267
+ numberOfAudioTags: numberOfSharedAudioTags,
3268
+ children
3269
+ })
3179
3270
  })
3180
3271
  })
3181
3272
  })
@@ -3193,7 +3284,7 @@ var SharedPlayerContexts = ({
3193
3284
  };
3194
3285
 
3195
3286
  // src/use-remotion-license-acknowledge.ts
3196
- import { Internals as Internals14 } from "remotion";
3287
+ import { Internals as Internals16 } from "remotion";
3197
3288
  var warningShown = false;
3198
3289
  var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
3199
3290
  if (acknowledge) {
@@ -3203,7 +3294,7 @@ var acknowledgeRemotionLicenseMessage = (acknowledge, logLevel) => {
3203
3294
  return;
3204
3295
  }
3205
3296
  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.");
3297
+ 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
3298
  };
3208
3299
 
3209
3300
  // src/utils/validate-in-out-frame.ts
@@ -3304,7 +3395,7 @@ var validateDurationInFrames = NoReactInternals.validateDurationInFrames;
3304
3395
  var validateDefaultAndInputProps = NoReactInternals.validateDefaultAndInputProps;
3305
3396
 
3306
3397
  // src/Player.tsx
3307
- import { jsx as jsx14 } from "react/jsx-runtime";
3398
+ import { jsx as jsx15 } from "react/jsx-runtime";
3308
3399
  var componentOrNullIfLazy = (props) => {
3309
3400
  if ("component" in props) {
3310
3401
  return props.component;
@@ -3378,21 +3469,21 @@ var PlayerFn = ({
3378
3469
  if (componentForValidation === Composition) {
3379
3470
  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
3471
  }
3381
- useState13(() => acknowledgeRemotionLicenseMessage(Boolean(acknowledgeRemotionLicense), logLevel));
3382
- const component = Internals15.useLazyComponent({
3472
+ useState12(() => acknowledgeRemotionLicenseMessage(Boolean(acknowledgeRemotionLicense), logLevel));
3473
+ const component = Internals17.useLazyComponent({
3383
3474
  compProps: componentProps,
3384
3475
  componentName: "Player",
3385
3476
  noSuspense: Boolean(noSuspense)
3386
3477
  });
3387
3478
  validateInitialFrame({ initialFrame, durationInFrames });
3388
- const [frame, setFrame] = useState13(() => ({
3479
+ const [frame, setFrame] = useState12(() => ({
3389
3480
  [PLAYER_COMP_ID]: initialFrame ?? 0
3390
3481
  }));
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);
3482
+ const [playing, setPlaying] = useState12(false);
3483
+ const rootRef = useRef13(null);
3484
+ const audioAndVideoTags = useRef13([]);
3485
+ const imperativePlaying = useRef13(false);
3486
+ const [currentPlaybackRate, setCurrentPlaybackRate] = useState12(playbackRate);
3396
3487
  if (typeof compositionHeight !== "number") {
3397
3488
  throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
3398
3489
  }
@@ -3453,15 +3544,15 @@ var PlayerFn = ({
3453
3544
  setCurrentPlaybackRate(playbackRate);
3454
3545
  }, [playbackRate]);
3455
3546
  useImperativeHandle2(ref, () => rootRef.current, []);
3456
- useState13(() => {
3457
- Internals15.playbackLogging({
3547
+ useState12(() => {
3548
+ Internals17.playbackLogging({
3458
3549
  logLevel,
3459
3550
  message: `[player] Mounting <Player>. User agent = ${typeof navigator === "undefined" ? "server" : navigator.userAgent}`,
3460
3551
  tag: "player",
3461
3552
  mountTime: Date.now()
3462
3553
  });
3463
3554
  });
3464
- const timelineContextValue = useMemo14(() => {
3555
+ const timelineContextValue = useMemo15(() => {
3465
3556
  return {
3466
3557
  frame,
3467
3558
  playing,
@@ -3469,13 +3560,13 @@ var PlayerFn = ({
3469
3560
  audioAndVideoTags
3470
3561
  };
3471
3562
  }, [frame, playing]);
3472
- const playbackRateContextValue = useMemo14(() => {
3563
+ const playbackRateContextValue = useMemo15(() => {
3473
3564
  return {
3474
3565
  playbackRate: currentPlaybackRate,
3475
3566
  setPlaybackRate: setCurrentPlaybackRate
3476
3567
  };
3477
3568
  }, [currentPlaybackRate]);
3478
- const setTimelineContextValue = useMemo14(() => {
3569
+ const setTimelineContextValue = useMemo15(() => {
3479
3570
  return {
3480
3571
  setFrame,
3481
3572
  setPlaying
@@ -3483,17 +3574,17 @@ var PlayerFn = ({
3483
3574
  }, [setFrame]);
3484
3575
  if (typeof window !== "undefined") {
3485
3576
  useLayoutEffect3(() => {
3486
- Internals15.CSSUtils.injectCSS(Internals15.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
3577
+ Internals17.CSSUtils.injectCSS(Internals17.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
3487
3578
  }, [overrideInternalClassName]);
3488
3579
  }
3489
- const actualInputProps = useMemo14(() => inputProps ?? {}, [inputProps]);
3490
- const browserMediaControlsBehavior = useMemo14(() => {
3580
+ const actualInputProps = useMemo15(() => inputProps ?? {}, [inputProps]);
3581
+ const browserMediaControlsBehavior = useMemo15(() => {
3491
3582
  return passedBrowserMediaControlsBehavior ?? {
3492
3583
  mode: "prevent-media-session"
3493
3584
  };
3494
3585
  }, [passedBrowserMediaControlsBehavior]);
3495
- return /* @__PURE__ */ jsx14(Internals15.IsPlayerContextProvider, {
3496
- children: /* @__PURE__ */ jsx14(SharedPlayerContexts, {
3586
+ return /* @__PURE__ */ jsx15(Internals17.IsPlayerContextProvider, {
3587
+ children: /* @__PURE__ */ jsx15(SharedPlayerContexts, {
3497
3588
  timelineContext: timelineContextValue,
3498
3589
  playbackRateContext: playbackRateContextValue,
3499
3590
  component,
@@ -3510,11 +3601,11 @@ var PlayerFn = ({
3510
3601
  initialVolume,
3511
3602
  inputProps: actualInputProps,
3512
3603
  audioEnabled: true,
3513
- children: /* @__PURE__ */ jsx14(Internals15.SetTimelineContext.Provider, {
3604
+ children: /* @__PURE__ */ jsx15(Internals17.SetTimelineContext.Provider, {
3514
3605
  value: setTimelineContextValue,
3515
- children: /* @__PURE__ */ jsx14(PlayerEmitterProvider, {
3606
+ children: /* @__PURE__ */ jsx15(PlayerEmitterProvider, {
3516
3607
  currentPlaybackRate,
3517
- children: /* @__PURE__ */ jsx14(PlayerUI_default, {
3608
+ children: /* @__PURE__ */ jsx15(PlayerUI_default, {
3518
3609
  ref: rootRef,
3519
3610
  posterFillMode,
3520
3611
  renderLoading,
@@ -3567,31 +3658,31 @@ import {
3567
3658
  forwardRef as forwardRef4,
3568
3659
  useImperativeHandle as useImperativeHandle4,
3569
3660
  useLayoutEffect as useLayoutEffect4,
3570
- useMemo as useMemo17,
3571
- useRef as useRef14,
3572
- useState as useState14
3661
+ useMemo as useMemo18,
3662
+ useRef as useRef15,
3663
+ useState as useState13
3573
3664
  } from "react";
3574
- import { Internals as Internals17 } from "remotion";
3665
+ import { Internals as Internals19 } from "remotion";
3575
3666
 
3576
3667
  // src/ThumbnailUI.tsx
3577
- import React13, {
3668
+ import React14, {
3578
3669
  forwardRef as forwardRef3,
3579
3670
  Suspense as Suspense2,
3580
3671
  useCallback as useCallback12,
3581
3672
  useImperativeHandle as useImperativeHandle3,
3582
- useMemo as useMemo16,
3583
- useRef as useRef13
3673
+ useMemo as useMemo17,
3674
+ useRef as useRef14
3584
3675
  } from "react";
3585
- import { Internals as Internals16 } from "remotion";
3676
+ import { Internals as Internals18 } from "remotion";
3586
3677
 
3587
3678
  // src/use-thumbnail.ts
3588
- import { useContext as useContext6, useMemo as useMemo15 } from "react";
3679
+ import { useContext as useContext6, useMemo as useMemo16 } from "react";
3589
3680
  var useThumbnail = () => {
3590
3681
  const emitter = useContext6(ThumbnailEmitterContext);
3591
3682
  if (!emitter) {
3592
3683
  throw new TypeError("Expected Player event emitter context");
3593
3684
  }
3594
- const returnValue = useMemo15(() => {
3685
+ const returnValue = useMemo16(() => {
3595
3686
  return {
3596
3687
  emitter
3597
3688
  };
@@ -3600,8 +3691,8 @@ var useThumbnail = () => {
3600
3691
  };
3601
3692
 
3602
3693
  // src/ThumbnailUI.tsx
3603
- import { jsx as jsx15 } from "react/jsx-runtime";
3604
- var reactVersion2 = React13.version.split(".")[0];
3694
+ import { jsx as jsx16 } from "react/jsx-runtime";
3695
+ var reactVersion2 = React14.version.split(".")[0];
3605
3696
  if (reactVersion2 === "0") {
3606
3697
  throw new Error(`Version ${reactVersion2} of "react" is not supported by Remotion`);
3607
3698
  }
@@ -3616,14 +3707,14 @@ var ThumbnailUI = ({
3616
3707
  noSuspense,
3617
3708
  overrideInternalClassName
3618
3709
  }, ref) => {
3619
- const config = Internals16.useUnsafeVideoConfig();
3620
- const video = Internals16.useVideo();
3621
- const container = useRef13(null);
3710
+ const config = Internals18.useUnsafeVideoConfig();
3711
+ const video = Internals18.useVideo();
3712
+ const container = useRef14(null);
3622
3713
  const canvasSize = useElementSize(container, {
3623
3714
  triggerOnWindowResize: false,
3624
3715
  shouldApplyCssTransforms: false
3625
3716
  });
3626
- const layout = useMemo16(() => {
3717
+ const layout = useMemo17(() => {
3627
3718
  if (!config || !canvasSize) {
3628
3719
  return null;
3629
3720
  }
@@ -3645,7 +3736,7 @@ var ThumbnailUI = ({
3645
3736
  return Object.assign(thumbnail.emitter, methods);
3646
3737
  }, [scale, thumbnail.emitter]);
3647
3738
  const VideoComponent = video ? video.component : null;
3648
- const outerStyle = useMemo16(() => {
3739
+ const outerStyle = useMemo17(() => {
3649
3740
  return calculateOuterStyle({
3650
3741
  config,
3651
3742
  style: style2,
@@ -3654,10 +3745,10 @@ var ThumbnailUI = ({
3654
3745
  layout
3655
3746
  });
3656
3747
  }, [canvasSize, config, layout, overflowVisible, style2]);
3657
- const outer = useMemo16(() => {
3748
+ const outer = useMemo17(() => {
3658
3749
  return calculateOuter({ config, layout, scale, overflowVisible });
3659
3750
  }, [config, layout, overflowVisible, scale]);
3660
- const containerStyle3 = useMemo16(() => {
3751
+ const containerStyle3 = useMemo17(() => {
3661
3752
  return calculateContainerStyle({
3662
3753
  config,
3663
3754
  layout,
@@ -3668,14 +3759,14 @@ var ThumbnailUI = ({
3668
3759
  const onError = useCallback12((error) => {
3669
3760
  thumbnail.emitter.dispatchError(error);
3670
3761
  }, [thumbnail.emitter]);
3671
- const loadingMarkup = useMemo16(() => {
3762
+ const loadingMarkup = useMemo17(() => {
3672
3763
  return renderLoading ? renderLoading({
3673
3764
  height: outerStyle.height,
3674
3765
  width: outerStyle.width,
3675
3766
  isBuffering: false
3676
3767
  }) : null;
3677
3768
  }, [outerStyle.height, outerStyle.width, renderLoading]);
3678
- const currentScaleContext = useMemo16(() => {
3769
+ const currentScaleContext = useMemo17(() => {
3679
3770
  return {
3680
3771
  type: "scale",
3681
3772
  scale
@@ -3684,17 +3775,17 @@ var ThumbnailUI = ({
3684
3775
  if (!config) {
3685
3776
  return null;
3686
3777
  }
3687
- const content = /* @__PURE__ */ jsx15("div", {
3778
+ const content = /* @__PURE__ */ jsx16("div", {
3688
3779
  style: outer,
3689
- children: /* @__PURE__ */ jsx15("div", {
3780
+ children: /* @__PURE__ */ jsx16("div", {
3690
3781
  style: containerStyle3,
3691
3782
  className: playerCssClassname(overrideInternalClassName),
3692
- children: VideoComponent ? /* @__PURE__ */ jsx15(ErrorBoundary, {
3783
+ children: VideoComponent ? /* @__PURE__ */ jsx16(ErrorBoundary, {
3693
3784
  onError,
3694
3785
  errorFallback,
3695
- children: /* @__PURE__ */ jsx15(Internals16.CurrentScaleContext.Provider, {
3786
+ children: /* @__PURE__ */ jsx16(Internals18.CurrentScaleContext.Provider, {
3696
3787
  value: currentScaleContext,
3697
- children: /* @__PURE__ */ jsx15(VideoComponent, {
3788
+ children: /* @__PURE__ */ jsx16(VideoComponent, {
3698
3789
  ...video?.props ?? {},
3699
3790
  ...inputProps ?? {}
3700
3791
  })
@@ -3703,18 +3794,18 @@ var ThumbnailUI = ({
3703
3794
  })
3704
3795
  });
3705
3796
  if (noSuspense || IS_NODE && !doesReactVersionSupportSuspense2) {
3706
- return /* @__PURE__ */ jsx15("div", {
3797
+ return /* @__PURE__ */ jsx16("div", {
3707
3798
  ref: container,
3708
3799
  style: outerStyle,
3709
3800
  className: className2,
3710
3801
  children: content
3711
3802
  });
3712
3803
  }
3713
- return /* @__PURE__ */ jsx15("div", {
3804
+ return /* @__PURE__ */ jsx16("div", {
3714
3805
  ref: container,
3715
3806
  style: outerStyle,
3716
3807
  className: className2,
3717
- children: /* @__PURE__ */ jsx15(Suspense2, {
3808
+ children: /* @__PURE__ */ jsx16(Suspense2, {
3718
3809
  fallback: loadingMarkup,
3719
3810
  children: content
3720
3811
  })
@@ -3723,7 +3814,7 @@ var ThumbnailUI = ({
3723
3814
  var ThumbnailUI_default = forwardRef3(ThumbnailUI);
3724
3815
 
3725
3816
  // src/Thumbnail.tsx
3726
- import { jsx as jsx16 } from "react/jsx-runtime";
3817
+ import { jsx as jsx17 } from "react/jsx-runtime";
3727
3818
  var ThumbnailFn = ({
3728
3819
  frameToDisplay,
3729
3820
  style: style2,
@@ -3746,21 +3837,21 @@ var ThumbnailFn = ({
3746
3837
  window.remotion_isPlayer = true;
3747
3838
  }, []);
3748
3839
  }
3749
- const rootRef = useRef14(null);
3750
- const timelineState = useMemo17(() => {
3840
+ const rootRef = useRef15(null);
3841
+ const imperativePlaying = useRef15(false);
3842
+ const audioAndVideoTags = useRef15([]);
3843
+ const timelineState = useMemo18(() => {
3751
3844
  const value = {
3752
3845
  playing: false,
3753
3846
  frame: {
3754
3847
  [PLAYER_COMP_ID]: frameToDisplay
3755
3848
  },
3756
- imperativePlaying: {
3757
- current: false
3758
- },
3759
- audioAndVideoTags: { current: [] }
3849
+ imperativePlaying,
3850
+ audioAndVideoTags
3760
3851
  };
3761
3852
  return value;
3762
3853
  }, [frameToDisplay]);
3763
- const playbackRateContext = useMemo17(() => {
3854
+ const playbackRateContext = useMemo18(() => {
3764
3855
  return {
3765
3856
  playbackRate: 1,
3766
3857
  setPlaybackRate: () => {
@@ -3769,17 +3860,17 @@ var ThumbnailFn = ({
3769
3860
  };
3770
3861
  }, []);
3771
3862
  useImperativeHandle4(ref, () => rootRef.current, []);
3772
- const Component = Internals17.useLazyComponent({
3863
+ const Component = Internals19.useLazyComponent({
3773
3864
  compProps: componentProps,
3774
3865
  componentName: "Thumbnail",
3775
3866
  noSuspense: Boolean(noSuspense)
3776
3867
  });
3777
- const [emitter] = useState14(() => new ThumbnailEmitter);
3778
- const passedInputProps = useMemo17(() => {
3868
+ const [emitter] = useState13(() => new ThumbnailEmitter);
3869
+ const passedInputProps = useMemo18(() => {
3779
3870
  return inputProps ?? {};
3780
3871
  }, [inputProps]);
3781
- return /* @__PURE__ */ jsx16(Internals17.IsPlayerContextProvider, {
3782
- children: /* @__PURE__ */ jsx16(SharedPlayerContexts, {
3872
+ return /* @__PURE__ */ jsx17(Internals19.IsPlayerContextProvider, {
3873
+ children: /* @__PURE__ */ jsx17(SharedPlayerContexts, {
3783
3874
  timelineContext: timelineState,
3784
3875
  playbackRateContext,
3785
3876
  component: Component,
@@ -3794,9 +3885,9 @@ var ThumbnailFn = ({
3794
3885
  sampleRate: 48000,
3795
3886
  inputProps: passedInputProps,
3796
3887
  audioEnabled: false,
3797
- children: /* @__PURE__ */ jsx16(ThumbnailEmitterContext.Provider, {
3888
+ children: /* @__PURE__ */ jsx17(ThumbnailEmitterContext.Provider, {
3798
3889
  value: emitter,
3799
- children: /* @__PURE__ */ jsx16(ThumbnailUI_default, {
3890
+ children: /* @__PURE__ */ jsx17(ThumbnailUI_default, {
3800
3891
  ref: rootRef,
3801
3892
  className: className2,
3802
3893
  errorFallback,
@@ -3818,7 +3909,7 @@ var Thumbnail = forward2(ThumbnailFn);
3818
3909
  var PlayerInternals = {
3819
3910
  PlayerEventEmitterContext,
3820
3911
  PlayerEmitter,
3821
- usePlayer,
3912
+ usePlayerMethods,
3822
3913
  usePlayback,
3823
3914
  useElementSize,
3824
3915
  calculateCanvasTransformation,