@remotion/player 4.0.232 → 4.0.234
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.
- package/dist/cjs/Player.d.ts +1 -0
- package/dist/cjs/Player.js +4 -4
- package/dist/cjs/PlayerControls.d.ts +2 -2
- package/dist/cjs/PlayerControls.js +8 -20
- package/dist/cjs/PlayerSeekBar.js +5 -5
- package/dist/cjs/PlayerTimeLabel.d.ts +6 -0
- package/dist/cjs/PlayerTimeLabel.js +22 -0
- package/dist/cjs/PlayerUI.d.ts +1 -0
- package/dist/cjs/PlayerUI.js +16 -17
- package/dist/cjs/Thumbnail.d.ts +1 -0
- package/dist/cjs/Thumbnail.js +2 -2
- package/dist/cjs/ThumbnailUI.d.ts +1 -0
- package/dist/cjs/ThumbnailUI.js +2 -2
- package/dist/cjs/error-boundary.d.ts +1 -1
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/license-blacklist.d.ts +3 -0
- package/dist/cjs/license-blacklist.js +86 -0
- package/dist/cjs/player-css-classname.d.ts +1 -1
- package/dist/cjs/player-css-classname.js +5 -2
- package/dist/cjs/use-frame-imperative.d.ts +2 -0
- package/dist/cjs/use-frame-imperative.js +15 -0
- package/dist/cjs/use-playback.d.ts +3 -2
- package/dist/cjs/use-playback.js +8 -8
- package/dist/cjs/use-player.d.ts +1 -4
- package/dist/cjs/use-player.js +22 -9
- package/dist/esm/index.mjs +477 -358
- package/package.json +3 -3
- package/LICENSE.md +0 -49
package/dist/esm/index.mjs
CHANGED
|
@@ -60,40 +60,40 @@ var FullscreenIcon = ({
|
|
|
60
60
|
children: [
|
|
61
61
|
/* @__PURE__ */ jsx("path", {
|
|
62
62
|
d: `
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
\t\t\t\tM ${out} ${inset}
|
|
64
|
+
\t\t\t\tL ${middleInset} ${middleInset}
|
|
65
|
+
\t\t\t\tL ${inset} ${out}
|
|
66
|
+
\t\t\t\t`,
|
|
67
67
|
stroke: "#fff",
|
|
68
68
|
strokeWidth,
|
|
69
69
|
fill: "none"
|
|
70
70
|
}),
|
|
71
71
|
/* @__PURE__ */ jsx("path", {
|
|
72
72
|
d: `
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
\t\t\t\tM ${viewSize - out} ${inset}
|
|
74
|
+
\t\t\t\tL ${viewSize - middleInset} ${middleInset}
|
|
75
|
+
\t\t\t\tL ${viewSize - inset} ${out}
|
|
76
|
+
\t\t\t\t`,
|
|
77
77
|
stroke: "#fff",
|
|
78
78
|
strokeWidth,
|
|
79
79
|
fill: "none"
|
|
80
80
|
}),
|
|
81
81
|
/* @__PURE__ */ jsx("path", {
|
|
82
82
|
d: `
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
\t\t\t\tM ${out} ${viewSize - inset}
|
|
84
|
+
\t\t\t\tL ${middleInset} ${viewSize - middleInset}
|
|
85
|
+
\t\t\t\tL ${inset} ${viewSize - out}
|
|
86
|
+
\t\t\t\t`,
|
|
87
87
|
stroke: "#fff",
|
|
88
88
|
strokeWidth,
|
|
89
89
|
fill: "none"
|
|
90
90
|
}),
|
|
91
91
|
/* @__PURE__ */ jsx("path", {
|
|
92
92
|
d: `
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
\t\t\t\tM ${viewSize - out} ${viewSize - inset}
|
|
94
|
+
\t\t\t\tL ${viewSize - middleInset} ${viewSize - middleInset}
|
|
95
|
+
\t\t\t\tL ${viewSize - inset} ${viewSize - out}
|
|
96
|
+
\t\t\t\t`,
|
|
97
97
|
stroke: "#fff",
|
|
98
98
|
strokeWidth,
|
|
99
99
|
fill: "none"
|
|
@@ -149,7 +149,7 @@ var BufferingIndicator = ({ type }) => {
|
|
|
149
149
|
/* @__PURE__ */ jsx2("style", {
|
|
150
150
|
type: "text/css",
|
|
151
151
|
children: `
|
|
152
|
-
|
|
152
|
+
\t\t\t\t@keyframes ${remotionBufferingAnimation} {
|
|
153
153
|
0% {
|
|
154
154
|
rotate: 0deg;
|
|
155
155
|
}
|
|
@@ -161,7 +161,7 @@ var BufferingIndicator = ({ type }) => {
|
|
|
161
161
|
.${className} {
|
|
162
162
|
animation: ${remotionBufferingAnimation} 1s linear infinite;
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
\t\t\t`
|
|
165
165
|
}),
|
|
166
166
|
/* @__PURE__ */ jsx2("div", {
|
|
167
167
|
style,
|
|
@@ -476,6 +476,19 @@ var PlayerEmitterProvider = ({ children, currentPlaybackRate }) => {
|
|
|
476
476
|
});
|
|
477
477
|
};
|
|
478
478
|
|
|
479
|
+
// src/use-frame-imperative.ts
|
|
480
|
+
import { useCallback, useRef } from "react";
|
|
481
|
+
import { Internals as Internals4 } from "remotion";
|
|
482
|
+
var useFrameImperative = () => {
|
|
483
|
+
const frame = Internals4.Timeline.useTimelinePosition();
|
|
484
|
+
const frameRef = useRef(frame);
|
|
485
|
+
frameRef.current = frame;
|
|
486
|
+
const getCurrentFrame = useCallback(() => {
|
|
487
|
+
return frameRef.current;
|
|
488
|
+
}, []);
|
|
489
|
+
return getCurrentFrame;
|
|
490
|
+
};
|
|
491
|
+
|
|
479
492
|
// src/use-hover-state.ts
|
|
480
493
|
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
481
494
|
var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
|
|
@@ -520,28 +533,28 @@ var useHoverState = (ref, hideControlsWhenPointerDoesntMove) => {
|
|
|
520
533
|
};
|
|
521
534
|
|
|
522
535
|
// src/use-playback.ts
|
|
523
|
-
import { useContext as useContext4, useEffect as useEffect6, useRef as
|
|
524
|
-
import { Internals as
|
|
536
|
+
import { useContext as useContext4, useEffect as useEffect6, useRef as useRef4 } from "react";
|
|
537
|
+
import { Internals as Internals6 } from "remotion";
|
|
525
538
|
|
|
526
539
|
// src/browser-mediasession.ts
|
|
527
540
|
import { useEffect as useEffect4 } from "react";
|
|
528
541
|
|
|
529
542
|
// src/use-player.ts
|
|
530
|
-
import { useCallback, useContext as useContext3, useMemo, useRef, useState as useState3 } from "react";
|
|
531
|
-
import { Internals as
|
|
543
|
+
import { useCallback as useCallback2, useContext as useContext3, useMemo, useRef as useRef2, useState as useState3 } from "react";
|
|
544
|
+
import { Internals as Internals5 } from "remotion";
|
|
532
545
|
var usePlayer = () => {
|
|
533
|
-
const [playing, setPlaying, imperativePlaying] =
|
|
546
|
+
const [playing, setPlaying, imperativePlaying] = Internals5.Timeline.usePlayingState();
|
|
534
547
|
const [hasPlayed, setHasPlayed] = useState3(false);
|
|
535
|
-
const frame =
|
|
536
|
-
const playStart =
|
|
537
|
-
const setFrame =
|
|
538
|
-
const setTimelinePosition =
|
|
539
|
-
const audioContext = useContext3(
|
|
540
|
-
const { audioAndVideoTags } = useContext3(
|
|
541
|
-
const frameRef =
|
|
548
|
+
const frame = Internals5.Timeline.useTimelinePosition();
|
|
549
|
+
const playStart = useRef2(frame);
|
|
550
|
+
const setFrame = Internals5.Timeline.useTimelineSetFrame();
|
|
551
|
+
const setTimelinePosition = Internals5.Timeline.useTimelineSetFrame();
|
|
552
|
+
const audioContext = useContext3(Internals5.SharedAudioContext);
|
|
553
|
+
const { audioAndVideoTags } = useContext3(Internals5.Timeline.TimelineContext);
|
|
554
|
+
const frameRef = useRef2(frame);
|
|
542
555
|
frameRef.current = frame;
|
|
543
|
-
const video =
|
|
544
|
-
const config =
|
|
556
|
+
const video = Internals5.useVideo();
|
|
557
|
+
const config = Internals5.useUnsafeVideoConfig();
|
|
545
558
|
const emitter = useContext3(PlayerEventEmitterContext);
|
|
546
559
|
const lastFrame = (config?.durationInFrames ?? 1) - 1;
|
|
547
560
|
const isLastFrame = frame === lastFrame;
|
|
@@ -549,19 +562,19 @@ var usePlayer = () => {
|
|
|
549
562
|
if (!emitter) {
|
|
550
563
|
throw new TypeError("Expected Player event emitter context");
|
|
551
564
|
}
|
|
552
|
-
const bufferingContext = useContext3(
|
|
565
|
+
const bufferingContext = useContext3(Internals5.BufferingContextReact);
|
|
553
566
|
if (!bufferingContext) {
|
|
554
567
|
throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
|
|
555
568
|
}
|
|
556
569
|
const { buffering } = bufferingContext;
|
|
557
|
-
const seek =
|
|
570
|
+
const seek = useCallback2((newFrame) => {
|
|
558
571
|
if (video?.id) {
|
|
559
572
|
setTimelinePosition((c) => ({ ...c, [video.id]: newFrame }));
|
|
560
573
|
}
|
|
561
574
|
frameRef.current = newFrame;
|
|
562
575
|
emitter.dispatchSeek(newFrame);
|
|
563
576
|
}, [emitter, setTimelinePosition, video?.id]);
|
|
564
|
-
const play =
|
|
577
|
+
const play = useCallback2((e) => {
|
|
565
578
|
if (imperativePlaying.current) {
|
|
566
579
|
return;
|
|
567
580
|
}
|
|
@@ -586,14 +599,14 @@ var usePlayer = () => {
|
|
|
586
599
|
seek,
|
|
587
600
|
audioAndVideoTags
|
|
588
601
|
]);
|
|
589
|
-
const pause =
|
|
602
|
+
const pause = useCallback2(() => {
|
|
590
603
|
if (imperativePlaying.current) {
|
|
591
604
|
imperativePlaying.current = false;
|
|
592
605
|
setPlaying(false);
|
|
593
606
|
emitter.dispatchPause();
|
|
594
607
|
}
|
|
595
608
|
}, [emitter, imperativePlaying, setPlaying]);
|
|
596
|
-
const pauseAndReturnToPlayStart =
|
|
609
|
+
const pauseAndReturnToPlayStart = useCallback2(() => {
|
|
597
610
|
if (imperativePlaying.current) {
|
|
598
611
|
imperativePlaying.current = false;
|
|
599
612
|
frameRef.current = playStart.current;
|
|
@@ -608,7 +621,7 @@ var usePlayer = () => {
|
|
|
608
621
|
}
|
|
609
622
|
}, [config, emitter, imperativePlaying, setPlaying, setTimelinePosition]);
|
|
610
623
|
const videoId = video?.id;
|
|
611
|
-
const frameBack =
|
|
624
|
+
const frameBack = useCallback2((frames) => {
|
|
612
625
|
if (!videoId) {
|
|
613
626
|
return null;
|
|
614
627
|
}
|
|
@@ -623,7 +636,7 @@ var usePlayer = () => {
|
|
|
623
636
|
};
|
|
624
637
|
});
|
|
625
638
|
}, [imperativePlaying, setFrame, videoId]);
|
|
626
|
-
const frameForward =
|
|
639
|
+
const frameForward = useCallback2((frames) => {
|
|
627
640
|
if (!videoId) {
|
|
628
641
|
return null;
|
|
629
642
|
}
|
|
@@ -638,6 +651,14 @@ var usePlayer = () => {
|
|
|
638
651
|
};
|
|
639
652
|
});
|
|
640
653
|
}, [videoId, imperativePlaying, lastFrame, setFrame]);
|
|
654
|
+
const getCurrentFrame = useFrameImperative();
|
|
655
|
+
const toggle = useCallback2((e) => {
|
|
656
|
+
if (imperativePlaying.current) {
|
|
657
|
+
pause();
|
|
658
|
+
} else {
|
|
659
|
+
play(e);
|
|
660
|
+
}
|
|
661
|
+
}, [imperativePlaying, pause, play]);
|
|
641
662
|
const returnValue = useMemo(() => {
|
|
642
663
|
return {
|
|
643
664
|
frameBack,
|
|
@@ -649,27 +670,30 @@ var usePlayer = () => {
|
|
|
649
670
|
pause,
|
|
650
671
|
seek,
|
|
651
672
|
isFirstFrame,
|
|
652
|
-
getCurrentFrame
|
|
673
|
+
getCurrentFrame,
|
|
653
674
|
isPlaying: () => imperativePlaying.current,
|
|
654
675
|
isBuffering: () => buffering.current,
|
|
655
676
|
pauseAndReturnToPlayStart,
|
|
656
677
|
hasPlayed,
|
|
657
|
-
remotionInternal_currentFrameRef: frameRef
|
|
678
|
+
remotionInternal_currentFrameRef: frameRef,
|
|
679
|
+
toggle
|
|
658
680
|
};
|
|
659
681
|
}, [
|
|
682
|
+
buffering,
|
|
683
|
+
emitter,
|
|
660
684
|
frameBack,
|
|
661
685
|
frameForward,
|
|
686
|
+
getCurrentFrame,
|
|
687
|
+
hasPlayed,
|
|
688
|
+
imperativePlaying,
|
|
689
|
+
isFirstFrame,
|
|
662
690
|
isLastFrame,
|
|
663
|
-
emitter,
|
|
664
|
-
playing,
|
|
665
|
-
play,
|
|
666
691
|
pause,
|
|
667
|
-
seek,
|
|
668
|
-
isFirstFrame,
|
|
669
692
|
pauseAndReturnToPlayStart,
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
693
|
+
play,
|
|
694
|
+
playing,
|
|
695
|
+
seek,
|
|
696
|
+
toggle
|
|
673
697
|
]);
|
|
674
698
|
return returnValue;
|
|
675
699
|
};
|
|
@@ -814,7 +838,7 @@ var calculateNextFrame = ({
|
|
|
814
838
|
};
|
|
815
839
|
|
|
816
840
|
// src/is-backgrounded.ts
|
|
817
|
-
import { useEffect as useEffect5, useRef as
|
|
841
|
+
import { useEffect as useEffect5, useRef as useRef3 } from "react";
|
|
818
842
|
var getIsBackgrounded = () => {
|
|
819
843
|
if (typeof document === "undefined") {
|
|
820
844
|
return false;
|
|
@@ -822,7 +846,7 @@ var getIsBackgrounded = () => {
|
|
|
822
846
|
return document.visibilityState === "hidden";
|
|
823
847
|
};
|
|
824
848
|
var useIsBackgrounded = () => {
|
|
825
|
-
const isBackgrounded =
|
|
849
|
+
const isBackgrounded = useRef3(getIsBackgrounded());
|
|
826
850
|
useEffect5(() => {
|
|
827
851
|
const onVisibilityChange = () => {
|
|
828
852
|
isBackgrounded.current = getIsBackgrounded();
|
|
@@ -842,17 +866,17 @@ var usePlayback = ({
|
|
|
842
866
|
moveToBeginningWhenEnded,
|
|
843
867
|
inFrame,
|
|
844
868
|
outFrame,
|
|
845
|
-
|
|
846
|
-
|
|
869
|
+
browserMediaControlsBehavior,
|
|
870
|
+
getCurrentFrame
|
|
847
871
|
}) => {
|
|
848
|
-
const config =
|
|
849
|
-
const frame =
|
|
872
|
+
const config = Internals6.useUnsafeVideoConfig();
|
|
873
|
+
const frame = Internals6.Timeline.useTimelinePosition();
|
|
850
874
|
const { playing, pause, emitter } = usePlayer();
|
|
851
|
-
const setFrame =
|
|
852
|
-
const buffering =
|
|
875
|
+
const setFrame = Internals6.Timeline.useTimelineSetFrame();
|
|
876
|
+
const buffering = useRef4(null);
|
|
853
877
|
const isBackgroundedRef = useIsBackgrounded();
|
|
854
|
-
const lastTimeUpdateEvent =
|
|
855
|
-
const context = useContext4(
|
|
878
|
+
const lastTimeUpdateEvent = useRef4(null);
|
|
879
|
+
const context = useContext4(Internals6.BufferingContextReact);
|
|
856
880
|
if (!context) {
|
|
857
881
|
throw new Error("Missing the buffering context. Most likely you have a Remotion version mismatch.");
|
|
858
882
|
}
|
|
@@ -901,7 +925,7 @@ var usePlayback = ({
|
|
|
901
925
|
const time = performance.now() - startedTime;
|
|
902
926
|
const actualLastFrame = outFrame ?? config.durationInFrames - 1;
|
|
903
927
|
const actualFirstFrame = inFrame ?? 0;
|
|
904
|
-
const currentFrame =
|
|
928
|
+
const currentFrame = getCurrentFrame();
|
|
905
929
|
const { nextFrame, framesToAdvance, hasEnded } = calculateNextFrame({
|
|
906
930
|
time,
|
|
907
931
|
currentFrame,
|
|
@@ -913,7 +937,7 @@ var usePlayback = ({
|
|
|
913
937
|
shouldLoop: loop
|
|
914
938
|
});
|
|
915
939
|
framesAdvanced += framesToAdvance;
|
|
916
|
-
if (nextFrame !==
|
|
940
|
+
if (nextFrame !== getCurrentFrame() && (!hasEnded || moveToBeginningWhenEnded)) {
|
|
917
941
|
setFrame((c) => ({ ...c, [config.id]: nextFrame }));
|
|
918
942
|
}
|
|
919
943
|
if (hasEnded) {
|
|
@@ -973,27 +997,27 @@ var usePlayback = ({
|
|
|
973
997
|
outFrame,
|
|
974
998
|
moveToBeginningWhenEnded,
|
|
975
999
|
isBackgroundedRef,
|
|
976
|
-
|
|
1000
|
+
getCurrentFrame,
|
|
977
1001
|
buffering,
|
|
978
1002
|
context
|
|
979
1003
|
]);
|
|
980
1004
|
useEffect6(() => {
|
|
981
1005
|
const interval = setInterval(() => {
|
|
982
|
-
if (lastTimeUpdateEvent.current ===
|
|
1006
|
+
if (lastTimeUpdateEvent.current === getCurrentFrame()) {
|
|
983
1007
|
return;
|
|
984
1008
|
}
|
|
985
|
-
emitter.dispatchTimeUpdate({ frame:
|
|
986
|
-
lastTimeUpdateEvent.current =
|
|
1009
|
+
emitter.dispatchTimeUpdate({ frame: getCurrentFrame() });
|
|
1010
|
+
lastTimeUpdateEvent.current = getCurrentFrame();
|
|
987
1011
|
}, 250);
|
|
988
1012
|
return () => clearInterval(interval);
|
|
989
|
-
}, [emitter,
|
|
1013
|
+
}, [emitter, getCurrentFrame]);
|
|
990
1014
|
useEffect6(() => {
|
|
991
1015
|
emitter.dispatchFrameUpdate({ frame });
|
|
992
1016
|
}, [emitter, frame]);
|
|
993
1017
|
};
|
|
994
1018
|
|
|
995
1019
|
// src/utils/use-element-size.ts
|
|
996
|
-
import { useCallback as
|
|
1020
|
+
import { useCallback as useCallback3, useEffect as useEffect7, useMemo as useMemo2, useState as useState4 } from "react";
|
|
997
1021
|
var elementSizeHooks = [];
|
|
998
1022
|
var updateAllElementsSizes = () => {
|
|
999
1023
|
for (const listener of elementSizeHooks) {
|
|
@@ -1046,7 +1070,7 @@ var useElementSize = (ref, options) => {
|
|
|
1046
1070
|
});
|
|
1047
1071
|
});
|
|
1048
1072
|
}, [options.shouldApplyCssTransforms]);
|
|
1049
|
-
const updateSize =
|
|
1073
|
+
const updateSize = useCallback3(() => {
|
|
1050
1074
|
if (!ref.current) {
|
|
1051
1075
|
return;
|
|
1052
1076
|
}
|
|
@@ -1112,32 +1136,31 @@ var useElementSize = (ref, options) => {
|
|
|
1112
1136
|
// src/Player.tsx
|
|
1113
1137
|
import {
|
|
1114
1138
|
forwardRef as forwardRef2,
|
|
1115
|
-
useEffect as
|
|
1139
|
+
useEffect as useEffect14,
|
|
1116
1140
|
useImperativeHandle as useImperativeHandle2,
|
|
1117
1141
|
useLayoutEffect,
|
|
1118
|
-
useMemo as
|
|
1119
|
-
useRef as
|
|
1142
|
+
useMemo as useMemo14,
|
|
1143
|
+
useRef as useRef11,
|
|
1120
1144
|
useState as useState13
|
|
1121
1145
|
} from "react";
|
|
1122
|
-
import { Composition, Internals as
|
|
1146
|
+
import { Composition, Internals as Internals13 } from "remotion";
|
|
1123
1147
|
|
|
1124
1148
|
// src/PlayerUI.tsx
|
|
1125
|
-
import
|
|
1149
|
+
import React10, {
|
|
1126
1150
|
Suspense,
|
|
1127
1151
|
forwardRef,
|
|
1128
|
-
useCallback as
|
|
1152
|
+
useCallback as useCallback11,
|
|
1129
1153
|
useContext as useContext6,
|
|
1130
|
-
useEffect as
|
|
1154
|
+
useEffect as useEffect13,
|
|
1131
1155
|
useImperativeHandle,
|
|
1132
|
-
useMemo as
|
|
1133
|
-
useRef as
|
|
1156
|
+
useMemo as useMemo12,
|
|
1157
|
+
useRef as useRef10,
|
|
1134
1158
|
useState as useState11
|
|
1135
1159
|
} from "react";
|
|
1136
|
-
import { Internals as
|
|
1160
|
+
import { Internals as Internals11 } from "remotion";
|
|
1137
1161
|
|
|
1138
1162
|
// src/PlayerControls.tsx
|
|
1139
|
-
import { useCallback as
|
|
1140
|
-
import { Internals as Internals9 } from "remotion";
|
|
1163
|
+
import { useCallback as useCallback8, useEffect as useEffect11, useMemo as useMemo9, useRef as useRef8, useState as useState10 } from "react";
|
|
1141
1164
|
|
|
1142
1165
|
// src/DefaultPlayPauseButton.tsx
|
|
1143
1166
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -1154,11 +1177,11 @@ var DefaultPlayPauseButton = ({ playing, buffering }) => {
|
|
|
1154
1177
|
};
|
|
1155
1178
|
|
|
1156
1179
|
// src/MediaVolumeSlider.tsx
|
|
1157
|
-
import { useCallback as
|
|
1158
|
-
import { Internals as
|
|
1180
|
+
import { useCallback as useCallback5, useMemo as useMemo4, useRef as useRef5, useState as useState6 } from "react";
|
|
1181
|
+
import { Internals as Internals7 } from "remotion";
|
|
1159
1182
|
|
|
1160
1183
|
// src/render-volume-slider.tsx
|
|
1161
|
-
import React3, { useCallback as
|
|
1184
|
+
import React3, { useCallback as useCallback4, useMemo as useMemo3, useState as useState5 } from "react";
|
|
1162
1185
|
import { random } from "remotion";
|
|
1163
1186
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1164
1187
|
var KNOB_SIZE = 12;
|
|
@@ -1192,7 +1215,7 @@ var DefaultVolumeSlider = ({
|
|
|
1192
1215
|
}, [isVertical]);
|
|
1193
1216
|
const randomId = typeof React3.useId === "undefined" ? "volume-slider" : React3.useId();
|
|
1194
1217
|
const [randomClass] = useState5(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
|
|
1195
|
-
const onVolumeChange =
|
|
1218
|
+
const onVolumeChange = useCallback4((e) => {
|
|
1196
1219
|
setVolume(parseFloat(e.target.value));
|
|
1197
1220
|
}, [setVolume]);
|
|
1198
1221
|
const inputStyle = useMemo3(() => {
|
|
@@ -1204,9 +1227,9 @@ var DefaultVolumeSlider = ({
|
|
|
1204
1227
|
height: BAR_HEIGHT,
|
|
1205
1228
|
width: VOLUME_SLIDER_WIDTH,
|
|
1206
1229
|
backgroundImage: `linear-gradient(
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1230
|
+
\t\t\t\tto right,
|
|
1231
|
+
\t\t\t\twhite ${volume * 100}%, rgba(255, 255, 255, 0) ${volume * 100}%
|
|
1232
|
+
\t\t\t)`
|
|
1210
1233
|
};
|
|
1211
1234
|
if (isVertical) {
|
|
1212
1235
|
return {
|
|
@@ -1217,23 +1240,23 @@ var DefaultVolumeSlider = ({
|
|
|
1217
1240
|
return commonStyle;
|
|
1218
1241
|
}, [isVertical, volume]);
|
|
1219
1242
|
const sliderStyle = `
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1243
|
+
\t.${randomClass}::-webkit-slider-thumb {
|
|
1244
|
+
\t\t-webkit-appearance: none;
|
|
1245
|
+
\t\tbackground-color: white;
|
|
1246
|
+
\t\tborder-radius: ${KNOB_SIZE / 2}px;
|
|
1247
|
+
\t\tbox-shadow: 0 0 2px black;
|
|
1248
|
+
\t\theight: ${KNOB_SIZE}px;
|
|
1249
|
+
\t\twidth: ${KNOB_SIZE}px;
|
|
1250
|
+
\t}
|
|
1228
1251
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1252
|
+
\t.${randomClass}::-moz-range-thumb {
|
|
1253
|
+
\t\t-webkit-appearance: none;
|
|
1254
|
+
\t\tbackground-color: white;
|
|
1255
|
+
\t\tborder-radius: ${KNOB_SIZE / 2}px;
|
|
1256
|
+
\t\tbox-shadow: 0 0 2px black;
|
|
1257
|
+
\t\theight: ${KNOB_SIZE}px;
|
|
1258
|
+
\t\twidth: ${KNOB_SIZE}px;
|
|
1259
|
+
\t}
|
|
1237
1260
|
`;
|
|
1238
1261
|
return /* @__PURE__ */ jsxs3("div", {
|
|
1239
1262
|
style: sliderContainer,
|
|
@@ -1269,13 +1292,13 @@ var renderDefaultVolumeSlider = (props) => {
|
|
|
1269
1292
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1270
1293
|
var VOLUME_SLIDER_WIDTH = 100;
|
|
1271
1294
|
var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, renderVolumeSlider }) => {
|
|
1272
|
-
const [mediaMuted, setMediaMuted] =
|
|
1273
|
-
const [mediaVolume, setMediaVolume] =
|
|
1295
|
+
const [mediaMuted, setMediaMuted] = Internals7.useMediaMutedState();
|
|
1296
|
+
const [mediaVolume, setMediaVolume] = Internals7.useMediaVolumeState();
|
|
1274
1297
|
const [focused, setFocused] = useState6(false);
|
|
1275
|
-
const parentDivRef =
|
|
1276
|
-
const inputRef =
|
|
1298
|
+
const parentDivRef = useRef5(null);
|
|
1299
|
+
const inputRef = useRef5(null);
|
|
1277
1300
|
const hover = useHoverState(parentDivRef, false);
|
|
1278
|
-
const onBlur =
|
|
1301
|
+
const onBlur = useCallback5(() => {
|
|
1279
1302
|
setTimeout(() => {
|
|
1280
1303
|
if (inputRef.current && document.activeElement !== inputRef.current) {
|
|
1281
1304
|
setFocused(false);
|
|
@@ -1283,7 +1306,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
|
|
|
1283
1306
|
}, 10);
|
|
1284
1307
|
}, []);
|
|
1285
1308
|
const isVolume0 = mediaVolume === 0;
|
|
1286
|
-
const onClick =
|
|
1309
|
+
const onClick = useCallback5(() => {
|
|
1287
1310
|
if (isVolume0) {
|
|
1288
1311
|
setMediaVolume(1);
|
|
1289
1312
|
setMediaMuted(false);
|
|
@@ -1314,7 +1337,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
|
|
|
1314
1337
|
padding: 0
|
|
1315
1338
|
};
|
|
1316
1339
|
}, []);
|
|
1317
|
-
const renderDefaultMuteButton =
|
|
1340
|
+
const renderDefaultMuteButton = useCallback5(({ muted, volume }) => {
|
|
1318
1341
|
const isMutedOrZero = muted || volume === 0;
|
|
1319
1342
|
return /* @__PURE__ */ jsx6("button", {
|
|
1320
1343
|
"aria-label": isMutedOrZero ? "Unmute sound" : "Mute sound",
|
|
@@ -1331,7 +1354,7 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
|
|
|
1331
1354
|
return renderMuteButton ? renderMuteButton({ muted: mediaMuted, volume: mediaVolume }) : renderDefaultMuteButton({ muted: mediaMuted, volume: mediaVolume });
|
|
1332
1355
|
}, [mediaMuted, mediaVolume, renderDefaultMuteButton, renderMuteButton]);
|
|
1333
1356
|
const volumeSlider = useMemo4(() => {
|
|
1334
|
-
return (focused || hover) && !mediaMuted && !
|
|
1357
|
+
return (focused || hover) && !mediaMuted && !Internals7.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
|
|
1335
1358
|
isVertical: displayVerticalVolumeSlider,
|
|
1336
1359
|
volume: mediaVolume,
|
|
1337
1360
|
onBlur: () => setFocused(false),
|
|
@@ -1359,19 +1382,19 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider, renderMuteButton, render
|
|
|
1359
1382
|
|
|
1360
1383
|
// src/PlaybackrateControl.tsx
|
|
1361
1384
|
import {
|
|
1362
|
-
useCallback as
|
|
1385
|
+
useCallback as useCallback6,
|
|
1363
1386
|
useContext as useContext5,
|
|
1364
1387
|
useEffect as useEffect9,
|
|
1365
1388
|
useMemo as useMemo5,
|
|
1366
1389
|
useState as useState8
|
|
1367
1390
|
} from "react";
|
|
1368
|
-
import { Internals as
|
|
1391
|
+
import { Internals as Internals8 } from "remotion";
|
|
1369
1392
|
|
|
1370
1393
|
// src/utils/use-component-visible.ts
|
|
1371
|
-
import { useEffect as useEffect8, useRef as
|
|
1394
|
+
import { useEffect as useEffect8, useRef as useRef6, useState as useState7 } from "react";
|
|
1372
1395
|
function useComponentVisible(initialIsVisible) {
|
|
1373
1396
|
const [isComponentVisible, setIsComponentVisible] = useState7(initialIsVisible);
|
|
1374
|
-
const ref =
|
|
1397
|
+
const ref = useRef6(null);
|
|
1375
1398
|
useEffect8(() => {
|
|
1376
1399
|
const handleClickOutside = (event) => {
|
|
1377
1400
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
@@ -1417,16 +1440,16 @@ var Checkmark = () => /* @__PURE__ */ jsx7("svg", {
|
|
|
1417
1440
|
})
|
|
1418
1441
|
});
|
|
1419
1442
|
var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }) => {
|
|
1420
|
-
const onClick =
|
|
1443
|
+
const onClick = useCallback6((e) => {
|
|
1421
1444
|
e.stopPropagation();
|
|
1422
1445
|
e.preventDefault();
|
|
1423
1446
|
onSelect(rate);
|
|
1424
1447
|
}, [onSelect, rate]);
|
|
1425
1448
|
const [hovered, setHovered] = useState8(false);
|
|
1426
|
-
const onMouseEnter =
|
|
1449
|
+
const onMouseEnter = useCallback6(() => {
|
|
1427
1450
|
setHovered(true);
|
|
1428
1451
|
}, []);
|
|
1429
|
-
const onMouseLeave =
|
|
1452
|
+
const onMouseLeave = useCallback6(() => {
|
|
1430
1453
|
setHovered(false);
|
|
1431
1454
|
}, []);
|
|
1432
1455
|
const isFocused = keyboardSelectedRate === rate;
|
|
@@ -1453,7 +1476,7 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
|
|
|
1453
1476
|
}, rate);
|
|
1454
1477
|
};
|
|
1455
1478
|
var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
1456
|
-
const { setPlaybackRate, playbackRate } = useContext5(
|
|
1479
|
+
const { setPlaybackRate, playbackRate } = useContext5(Internals8.Timeline.TimelineContext);
|
|
1457
1480
|
const [keyboardSelectedRate, setKeyboardSelectedRate] = useState8(playbackRate);
|
|
1458
1481
|
useEffect9(() => {
|
|
1459
1482
|
const listener = (e) => {
|
|
@@ -1493,7 +1516,7 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
|
1493
1516
|
setPlaybackRate,
|
|
1494
1517
|
setIsComponentVisible
|
|
1495
1518
|
]);
|
|
1496
|
-
const onSelect =
|
|
1519
|
+
const onSelect = useCallback6((rate) => {
|
|
1497
1520
|
setPlaybackRate(rate);
|
|
1498
1521
|
setIsComponentVisible(false);
|
|
1499
1522
|
}, [setIsComponentVisible, setPlaybackRate]);
|
|
@@ -1555,8 +1578,8 @@ var button = {
|
|
|
1555
1578
|
};
|
|
1556
1579
|
var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
|
|
1557
1580
|
const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false);
|
|
1558
|
-
const { playbackRate } = useContext5(
|
|
1559
|
-
const onClick =
|
|
1581
|
+
const { playbackRate } = useContext5(Internals8.Timeline.TimelineContext);
|
|
1582
|
+
const onClick = useCallback6((e) => {
|
|
1560
1583
|
e.stopPropagation();
|
|
1561
1584
|
e.preventDefault();
|
|
1562
1585
|
setIsComponentVisible((prevIsComponentVisible) => !prevIsComponentVisible);
|
|
@@ -1587,8 +1610,8 @@ var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
|
|
|
1587
1610
|
};
|
|
1588
1611
|
|
|
1589
1612
|
// src/PlayerSeekBar.tsx
|
|
1590
|
-
import { useCallback as
|
|
1591
|
-
import { Internals as
|
|
1613
|
+
import { useCallback as useCallback7, useEffect as useEffect10, useMemo as useMemo6, useRef as useRef7, useState as useState9 } from "react";
|
|
1614
|
+
import { Internals as Internals9, interpolate } from "remotion";
|
|
1592
1615
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1593
1616
|
var getFrameFromX = (clientX, durationInFrames, width) => {
|
|
1594
1617
|
const pos = clientX;
|
|
@@ -1625,19 +1648,19 @@ var findBodyInWhichDivIsLocated = (div) => {
|
|
|
1625
1648
|
return current;
|
|
1626
1649
|
};
|
|
1627
1650
|
var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFrame }) => {
|
|
1628
|
-
const containerRef =
|
|
1651
|
+
const containerRef = useRef7(null);
|
|
1629
1652
|
const barHovered = useHoverState(containerRef, false);
|
|
1630
1653
|
const size = useElementSize(containerRef, {
|
|
1631
1654
|
triggerOnWindowResize: true,
|
|
1632
1655
|
shouldApplyCssTransforms: true
|
|
1633
1656
|
});
|
|
1634
1657
|
const { seek, play, pause, playing } = usePlayer();
|
|
1635
|
-
const frame =
|
|
1658
|
+
const frame = Internals9.Timeline.useTimelinePosition();
|
|
1636
1659
|
const [dragging, setDragging] = useState9({
|
|
1637
1660
|
dragging: false
|
|
1638
1661
|
});
|
|
1639
1662
|
const width = size?.width ?? 0;
|
|
1640
|
-
const onPointerDown =
|
|
1663
|
+
const onPointerDown = useCallback7((e) => {
|
|
1641
1664
|
if (e.button !== 0) {
|
|
1642
1665
|
return;
|
|
1643
1666
|
}
|
|
@@ -1651,7 +1674,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1651
1674
|
});
|
|
1652
1675
|
onSeekStart();
|
|
1653
1676
|
}, [durationInFrames, width, pause, seek, playing, onSeekStart]);
|
|
1654
|
-
const onPointerMove =
|
|
1677
|
+
const onPointerMove = useCallback7((e) => {
|
|
1655
1678
|
if (!size) {
|
|
1656
1679
|
throw new Error("Player has no size");
|
|
1657
1680
|
}
|
|
@@ -1662,7 +1685,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1662
1685
|
const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, size.width);
|
|
1663
1686
|
seek(_frame);
|
|
1664
1687
|
}, [dragging.dragging, durationInFrames, seek, size]);
|
|
1665
|
-
const onPointerUp =
|
|
1688
|
+
const onPointerUp = useCallback7(() => {
|
|
1666
1689
|
setDragging({
|
|
1667
1690
|
dragging: false
|
|
1668
1691
|
});
|
|
@@ -1698,18 +1721,18 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1698
1721
|
backgroundColor: "white",
|
|
1699
1722
|
left: Math.max(0, frame / Math.max(1, durationInFrames - 1) * width - KNOB_SIZE2 / 2),
|
|
1700
1723
|
boxShadow: "0 0 2px black",
|
|
1701
|
-
opacity: Number(barHovered)
|
|
1724
|
+
opacity: Number(barHovered || dragging.dragging)
|
|
1702
1725
|
};
|
|
1703
|
-
}, [barHovered, durationInFrames, frame, width]);
|
|
1726
|
+
}, [barHovered, dragging.dragging, durationInFrames, frame, width]);
|
|
1704
1727
|
const fillStyle = useMemo6(() => {
|
|
1705
1728
|
return {
|
|
1706
1729
|
height: BAR_HEIGHT2,
|
|
1707
1730
|
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
1708
|
-
width: (frame - (inFrame ?? 0)) / (durationInFrames - 1) *
|
|
1709
|
-
marginLeft: (inFrame ?? 0) / (durationInFrames - 1) *
|
|
1731
|
+
width: (frame - (inFrame ?? 0)) / (durationInFrames - 1) * width,
|
|
1732
|
+
marginLeft: (inFrame ?? 0) / (durationInFrames - 1) * width,
|
|
1710
1733
|
borderRadius: BAR_HEIGHT2 / 2
|
|
1711
1734
|
};
|
|
1712
|
-
}, [durationInFrames, frame, inFrame]);
|
|
1735
|
+
}, [durationInFrames, frame, inFrame, width]);
|
|
1713
1736
|
const active = useMemo6(() => {
|
|
1714
1737
|
return {
|
|
1715
1738
|
height: BAR_HEIGHT2,
|
|
@@ -1743,6 +1766,10 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1743
1766
|
});
|
|
1744
1767
|
};
|
|
1745
1768
|
|
|
1769
|
+
// src/PlayerTimeLabel.tsx
|
|
1770
|
+
import { useMemo as useMemo7 } from "react";
|
|
1771
|
+
import { Internals as Internals10 } from "remotion";
|
|
1772
|
+
|
|
1746
1773
|
// src/format-time.ts
|
|
1747
1774
|
var formatTime = (timeInSeconds) => {
|
|
1748
1775
|
const minutes = Math.floor(timeInSeconds / 60);
|
|
@@ -1750,15 +1777,39 @@ var formatTime = (timeInSeconds) => {
|
|
|
1750
1777
|
return `${String(minutes)}:${String(seconds).padStart(2, "0")}`;
|
|
1751
1778
|
};
|
|
1752
1779
|
|
|
1780
|
+
// src/PlayerTimeLabel.tsx
|
|
1781
|
+
import { jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1782
|
+
var PlayerTimeLabel = ({ durationInFrames, maxTimeLabelWidth, fps }) => {
|
|
1783
|
+
const frame = Internals10.Timeline.useTimelinePosition();
|
|
1784
|
+
const timeLabel = useMemo7(() => {
|
|
1785
|
+
return {
|
|
1786
|
+
color: "white",
|
|
1787
|
+
fontFamily: "sans-serif",
|
|
1788
|
+
fontSize: 14,
|
|
1789
|
+
maxWidth: maxTimeLabelWidth === null ? undefined : maxTimeLabelWidth,
|
|
1790
|
+
overflow: "hidden",
|
|
1791
|
+
textOverflow: "ellipsis"
|
|
1792
|
+
};
|
|
1793
|
+
}, [maxTimeLabelWidth]);
|
|
1794
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
1795
|
+
style: timeLabel,
|
|
1796
|
+
children: [
|
|
1797
|
+
formatTime(frame / fps),
|
|
1798
|
+
" / ",
|
|
1799
|
+
formatTime(durationInFrames / fps)
|
|
1800
|
+
]
|
|
1801
|
+
});
|
|
1802
|
+
};
|
|
1803
|
+
|
|
1753
1804
|
// src/use-video-controls-resize.ts
|
|
1754
|
-
import { useMemo as
|
|
1805
|
+
import { useMemo as useMemo8 } from "react";
|
|
1755
1806
|
var X_SPACER = 10;
|
|
1756
1807
|
var X_PADDING = 12;
|
|
1757
1808
|
var useVideoControlsResize = ({
|
|
1758
1809
|
allowFullscreen: allowFullScreen,
|
|
1759
1810
|
playerWidth
|
|
1760
1811
|
}) => {
|
|
1761
|
-
const resizeInfo =
|
|
1812
|
+
const resizeInfo = useMemo8(() => {
|
|
1762
1813
|
const playPauseIconSize = ICON_SIZE;
|
|
1763
1814
|
const volumeIconSize = ICON_SIZE;
|
|
1764
1815
|
const _fullscreenIconSize = allowFullScreen ? fullscreenIconSize : 0;
|
|
@@ -1778,7 +1829,7 @@ var useVideoControlsResize = ({
|
|
|
1778
1829
|
};
|
|
1779
1830
|
|
|
1780
1831
|
// src/PlayerControls.tsx
|
|
1781
|
-
import { jsx as jsx9, jsxs as
|
|
1832
|
+
import { jsx as jsx9, jsxs as jsxs8, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
1782
1833
|
var gradientSteps = [
|
|
1783
1834
|
0,
|
|
1784
1835
|
0.013,
|
|
@@ -1861,7 +1912,6 @@ var Controls = ({
|
|
|
1861
1912
|
durationInFrames,
|
|
1862
1913
|
isFullscreen,
|
|
1863
1914
|
fps,
|
|
1864
|
-
player,
|
|
1865
1915
|
showVolumeControls,
|
|
1866
1916
|
onFullscreenButtonClick,
|
|
1867
1917
|
allowFullscreen,
|
|
@@ -1883,10 +1933,11 @@ var Controls = ({
|
|
|
1883
1933
|
onPointerDown,
|
|
1884
1934
|
onDoubleClick,
|
|
1885
1935
|
renderMuteButton,
|
|
1886
|
-
renderVolumeSlider
|
|
1936
|
+
renderVolumeSlider,
|
|
1937
|
+
playing,
|
|
1938
|
+
toggle
|
|
1887
1939
|
}) => {
|
|
1888
|
-
const playButtonRef =
|
|
1889
|
-
const frame = Internals9.Timeline.useTimelinePosition();
|
|
1940
|
+
const playButtonRef = useRef8(null);
|
|
1890
1941
|
const [supportsFullscreen, setSupportsFullscreen] = useState10(false);
|
|
1891
1942
|
const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
|
|
1892
1943
|
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
|
|
@@ -1914,20 +1965,20 @@ var Controls = ({
|
|
|
1914
1965
|
}
|
|
1915
1966
|
throw new TypeError("initiallyShowControls must be a number or a boolean");
|
|
1916
1967
|
});
|
|
1917
|
-
const containerCss =
|
|
1918
|
-
const shouldShow = hovered || !
|
|
1968
|
+
const containerCss = useMemo9(() => {
|
|
1969
|
+
const shouldShow = hovered || !playing || shouldShowInitially || alwaysShowControls;
|
|
1919
1970
|
return {
|
|
1920
1971
|
...containerStyle2,
|
|
1921
1972
|
opacity: Number(shouldShow)
|
|
1922
1973
|
};
|
|
1923
|
-
}, [hovered, shouldShowInitially,
|
|
1974
|
+
}, [hovered, shouldShowInitially, playing, alwaysShowControls]);
|
|
1924
1975
|
useEffect11(() => {
|
|
1925
1976
|
if (playButtonRef.current && spaceKeyToPlayOrPause) {
|
|
1926
1977
|
playButtonRef.current.focus({
|
|
1927
1978
|
preventScroll: true
|
|
1928
1979
|
});
|
|
1929
1980
|
}
|
|
1930
|
-
}, [
|
|
1981
|
+
}, [playing, spaceKeyToPlayOrPause]);
|
|
1931
1982
|
useEffect11(() => {
|
|
1932
1983
|
setSupportsFullscreen((typeof document !== "undefined" && (document.fullscreenEnabled || document.webkitFullscreenEnabled)) ?? false);
|
|
1933
1984
|
}, []);
|
|
@@ -1943,17 +1994,7 @@ var Controls = ({
|
|
|
1943
1994
|
clearInterval(timeout);
|
|
1944
1995
|
};
|
|
1945
1996
|
}, [shouldShowInitially]);
|
|
1946
|
-
const
|
|
1947
|
-
return {
|
|
1948
|
-
color: "white",
|
|
1949
|
-
fontFamily: "sans-serif",
|
|
1950
|
-
fontSize: 14,
|
|
1951
|
-
maxWidth: maxTimeLabelWidth === null ? undefined : maxTimeLabelWidth,
|
|
1952
|
-
overflow: "hidden",
|
|
1953
|
-
textOverflow: "ellipsis"
|
|
1954
|
-
};
|
|
1955
|
-
}, [maxTimeLabelWidth]);
|
|
1956
|
-
const playbackRates = useMemo8(() => {
|
|
1997
|
+
const playbackRates = useMemo9(() => {
|
|
1957
1998
|
if (showPlaybackRateControl === true) {
|
|
1958
1999
|
return [0.5, 0.8, 1, 1.2, 1.5, 1.8, 2, 2.5, 3];
|
|
1959
2000
|
}
|
|
@@ -1970,50 +2011,50 @@ var Controls = ({
|
|
|
1970
2011
|
}
|
|
1971
2012
|
return null;
|
|
1972
2013
|
}, [showPlaybackRateControl]);
|
|
1973
|
-
const ref =
|
|
1974
|
-
const flexRef =
|
|
1975
|
-
const onPointerDownIfContainer =
|
|
2014
|
+
const ref = useRef8(null);
|
|
2015
|
+
const flexRef = useRef8(null);
|
|
2016
|
+
const onPointerDownIfContainer = useCallback8((e) => {
|
|
1976
2017
|
if (e.target === ref.current || e.target === flexRef.current) {
|
|
1977
2018
|
onPointerDown?.(e);
|
|
1978
2019
|
}
|
|
1979
2020
|
}, [onPointerDown]);
|
|
1980
|
-
const onDoubleClickIfContainer =
|
|
2021
|
+
const onDoubleClickIfContainer = useCallback8((e) => {
|
|
1981
2022
|
if (e.target === ref.current || e.target === flexRef.current) {
|
|
1982
2023
|
onDoubleClick?.(e);
|
|
1983
2024
|
}
|
|
1984
2025
|
}, [onDoubleClick]);
|
|
1985
|
-
return /* @__PURE__ */
|
|
2026
|
+
return /* @__PURE__ */ jsxs8("div", {
|
|
1986
2027
|
ref,
|
|
1987
2028
|
style: containerCss,
|
|
1988
2029
|
onPointerDown: onPointerDownIfContainer,
|
|
1989
2030
|
onDoubleClick: onDoubleClickIfContainer,
|
|
1990
2031
|
children: [
|
|
1991
|
-
/* @__PURE__ */
|
|
2032
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
1992
2033
|
ref: flexRef,
|
|
1993
2034
|
style: controlsRow,
|
|
1994
2035
|
children: [
|
|
1995
|
-
/* @__PURE__ */
|
|
2036
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
1996
2037
|
style: leftPartStyle,
|
|
1997
2038
|
children: [
|
|
1998
2039
|
/* @__PURE__ */ jsx9("button", {
|
|
1999
2040
|
ref: playButtonRef,
|
|
2000
2041
|
type: "button",
|
|
2001
2042
|
style: playerButtonStyle,
|
|
2002
|
-
onClick:
|
|
2003
|
-
"aria-label":
|
|
2004
|
-
title:
|
|
2043
|
+
onClick: toggle,
|
|
2044
|
+
"aria-label": playing ? "Pause video" : "Play video",
|
|
2045
|
+
title: playing ? "Pause video" : "Play video",
|
|
2005
2046
|
children: renderPlayPauseButton === null ? /* @__PURE__ */ jsx9(DefaultPlayPauseButton, {
|
|
2006
2047
|
buffering,
|
|
2007
|
-
playing
|
|
2048
|
+
playing
|
|
2008
2049
|
}) : renderPlayPauseButton({
|
|
2009
|
-
playing
|
|
2050
|
+
playing,
|
|
2010
2051
|
isBuffering: buffering
|
|
2011
2052
|
}) ?? /* @__PURE__ */ jsx9(DefaultPlayPauseButton, {
|
|
2012
2053
|
buffering,
|
|
2013
|
-
playing
|
|
2054
|
+
playing
|
|
2014
2055
|
})
|
|
2015
2056
|
}),
|
|
2016
|
-
showVolumeControls ? /* @__PURE__ */
|
|
2057
|
+
showVolumeControls ? /* @__PURE__ */ jsxs8(Fragment2, {
|
|
2017
2058
|
children: [
|
|
2018
2059
|
/* @__PURE__ */ jsx9("div", {
|
|
2019
2060
|
style: xSpacer
|
|
@@ -2028,13 +2069,10 @@ var Controls = ({
|
|
|
2028
2069
|
/* @__PURE__ */ jsx9("div", {
|
|
2029
2070
|
style: xSpacer
|
|
2030
2071
|
}),
|
|
2031
|
-
/* @__PURE__ */
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
" / ",
|
|
2036
|
-
formatTime(durationInFrames / fps)
|
|
2037
|
-
]
|
|
2072
|
+
/* @__PURE__ */ jsx9(PlayerTimeLabel, {
|
|
2073
|
+
durationInFrames,
|
|
2074
|
+
fps,
|
|
2075
|
+
maxTimeLabelWidth
|
|
2038
2076
|
}),
|
|
2039
2077
|
/* @__PURE__ */ jsx9("div", {
|
|
2040
2078
|
style: xSpacer
|
|
@@ -2081,7 +2119,7 @@ var Controls = ({
|
|
|
2081
2119
|
};
|
|
2082
2120
|
|
|
2083
2121
|
// src/error-boundary.tsx
|
|
2084
|
-
import
|
|
2122
|
+
import React8 from "react";
|
|
2085
2123
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
2086
2124
|
var errorStyle = {
|
|
2087
2125
|
display: "flex",
|
|
@@ -2092,7 +2130,7 @@ var errorStyle = {
|
|
|
2092
2130
|
width: "100%"
|
|
2093
2131
|
};
|
|
2094
2132
|
|
|
2095
|
-
class ErrorBoundary extends
|
|
2133
|
+
class ErrorBoundary extends React8.Component {
|
|
2096
2134
|
state = { hasError: null };
|
|
2097
2135
|
static getDerivedStateFromError(error) {
|
|
2098
2136
|
return { hasError: error };
|
|
@@ -2113,14 +2151,78 @@ class ErrorBoundary extends React7.Component {
|
|
|
2113
2151
|
}
|
|
2114
2152
|
}
|
|
2115
2153
|
|
|
2154
|
+
// src/license-blacklist.tsx
|
|
2155
|
+
import React9, { useEffect as useEffect12 } from "react";
|
|
2156
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2157
|
+
var getHashOfDomain = async () => {
|
|
2158
|
+
if (typeof window === "undefined") {
|
|
2159
|
+
return null;
|
|
2160
|
+
}
|
|
2161
|
+
if (typeof window.crypto === "undefined") {
|
|
2162
|
+
return null;
|
|
2163
|
+
}
|
|
2164
|
+
if (typeof window.crypto.subtle === "undefined") {
|
|
2165
|
+
return null;
|
|
2166
|
+
}
|
|
2167
|
+
try {
|
|
2168
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(window.location.hostname));
|
|
2169
|
+
return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
2170
|
+
} catch {
|
|
2171
|
+
return null;
|
|
2172
|
+
}
|
|
2173
|
+
};
|
|
2174
|
+
var style = {
|
|
2175
|
+
backgroundColor: "red",
|
|
2176
|
+
position: "absolute",
|
|
2177
|
+
padding: 12,
|
|
2178
|
+
fontFamily: "Arial"
|
|
2179
|
+
};
|
|
2180
|
+
var DOMAIN_BLACKLIST = [
|
|
2181
|
+
"28d262b44cc61fa750f1686b16ad0604dabfe193fbc263eec05c89b7ad4c2cd6",
|
|
2182
|
+
"4db1b0a94be33165dfefcb3ba03d04c7a2666dd27c496d3dc9fa41858e94925e",
|
|
2183
|
+
"fbc48530bbf245da790f63675e84e06bab38c3b114fab07eb350025119922bdc",
|
|
2184
|
+
"7baf10a8932757b1b3a22b3fce10a048747ac2f8eaf638603487e3705b07eb83",
|
|
2185
|
+
"8a6c21a598d8c667272b5207c051b85997bf5b45d5fb712378be3f27cd72c6a6",
|
|
2186
|
+
"a2f7aaac9c50a9255e7fc376110c4e0bfe153722dc66ed3c5d3bf2a135f65518"
|
|
2187
|
+
];
|
|
2188
|
+
var ran = false;
|
|
2189
|
+
var RenderWarningIfBlacklist = () => {
|
|
2190
|
+
const [unlicensed, setUnlicensed] = React9.useState(false);
|
|
2191
|
+
useEffect12(() => {
|
|
2192
|
+
if (ran) {
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
ran = true;
|
|
2196
|
+
getHashOfDomain().then((hash) => {
|
|
2197
|
+
if (hash && DOMAIN_BLACKLIST.includes(hash)) {
|
|
2198
|
+
setUnlicensed(true);
|
|
2199
|
+
}
|
|
2200
|
+
}).catch(() => {
|
|
2201
|
+
});
|
|
2202
|
+
}, []);
|
|
2203
|
+
if (!unlicensed) {
|
|
2204
|
+
return null;
|
|
2205
|
+
}
|
|
2206
|
+
return /* @__PURE__ */ jsx11("div", {
|
|
2207
|
+
style,
|
|
2208
|
+
children: /* @__PURE__ */ jsx11("a", {
|
|
2209
|
+
style: { color: "white" },
|
|
2210
|
+
href: "https://github.com/remotion-dev/remotion/pull/4589",
|
|
2211
|
+
children: "Remotion Unlicensed – Contact hi@remotion.dev"
|
|
2212
|
+
})
|
|
2213
|
+
});
|
|
2214
|
+
};
|
|
2215
|
+
|
|
2116
2216
|
// src/player-css-classname.ts
|
|
2117
|
-
var
|
|
2217
|
+
var playerCssClassname = (override) => {
|
|
2218
|
+
return override ?? "__remotion-player";
|
|
2219
|
+
};
|
|
2118
2220
|
|
|
2119
2221
|
// src/utils/is-node.ts
|
|
2120
2222
|
var IS_NODE = typeof document === "undefined";
|
|
2121
2223
|
|
|
2122
2224
|
// src/utils/use-click-prevention-on-double-click.ts
|
|
2123
|
-
import { useCallback as
|
|
2225
|
+
import { useCallback as useCallback10, useMemo as useMemo11 } from "react";
|
|
2124
2226
|
|
|
2125
2227
|
// src/utils/cancellable-promise.ts
|
|
2126
2228
|
var cancellablePromise = (promise) => {
|
|
@@ -2148,17 +2250,17 @@ var cancellablePromise = (promise) => {
|
|
|
2148
2250
|
var delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
|
|
2149
2251
|
|
|
2150
2252
|
// src/utils/use-cancellable-promises.ts
|
|
2151
|
-
import { useCallback as
|
|
2253
|
+
import { useCallback as useCallback9, useMemo as useMemo10, useRef as useRef9 } from "react";
|
|
2152
2254
|
var useCancellablePromises = () => {
|
|
2153
|
-
const pendingPromises =
|
|
2154
|
-
const appendPendingPromise =
|
|
2255
|
+
const pendingPromises = useRef9([]);
|
|
2256
|
+
const appendPendingPromise = useCallback9((promise) => {
|
|
2155
2257
|
pendingPromises.current = [...pendingPromises.current, promise];
|
|
2156
2258
|
}, []);
|
|
2157
|
-
const removePendingPromise =
|
|
2259
|
+
const removePendingPromise = useCallback9((promise) => {
|
|
2158
2260
|
pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
|
|
2159
2261
|
}, []);
|
|
2160
|
-
const clearPendingPromises =
|
|
2161
|
-
const api =
|
|
2262
|
+
const clearPendingPromises = useCallback9(() => pendingPromises.current.map((p) => p.cancel()), []);
|
|
2263
|
+
const api = useMemo10(() => ({
|
|
2162
2264
|
appendPendingPromise,
|
|
2163
2265
|
removePendingPromise,
|
|
2164
2266
|
clearPendingPromises
|
|
@@ -2169,7 +2271,7 @@ var useCancellablePromises = () => {
|
|
|
2169
2271
|
// src/utils/use-click-prevention-on-double-click.ts
|
|
2170
2272
|
var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
|
|
2171
2273
|
const api = useCancellablePromises();
|
|
2172
|
-
const handleClick =
|
|
2274
|
+
const handleClick = useCallback10(async (e) => {
|
|
2173
2275
|
if (e instanceof PointerEvent ? e.pointerType === "touch" : e.nativeEvent.pointerType === "touch") {
|
|
2174
2276
|
onClick(e);
|
|
2175
2277
|
return;
|
|
@@ -2189,18 +2291,18 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
|
|
|
2189
2291
|
}
|
|
2190
2292
|
}
|
|
2191
2293
|
}, [api, onClick]);
|
|
2192
|
-
const handlePointerDown =
|
|
2294
|
+
const handlePointerDown = useCallback10(() => {
|
|
2193
2295
|
document.addEventListener("pointerup", (newEvt) => {
|
|
2194
2296
|
handleClick(newEvt);
|
|
2195
2297
|
}, {
|
|
2196
2298
|
once: true
|
|
2197
2299
|
});
|
|
2198
2300
|
}, [handleClick]);
|
|
2199
|
-
const handleDoubleClick =
|
|
2301
|
+
const handleDoubleClick = useCallback10(() => {
|
|
2200
2302
|
api.clearPendingPromises();
|
|
2201
2303
|
onDoubleClick();
|
|
2202
2304
|
}, [api, onDoubleClick]);
|
|
2203
|
-
const returnValue =
|
|
2305
|
+
const returnValue = useMemo11(() => {
|
|
2204
2306
|
if (!doubleClickToFullscreen) {
|
|
2205
2307
|
return { handlePointerDown: onClick, handleDoubleClick: () => {
|
|
2206
2308
|
return;
|
|
@@ -2212,15 +2314,15 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
|
|
|
2212
2314
|
};
|
|
2213
2315
|
|
|
2214
2316
|
// src/PlayerUI.tsx
|
|
2215
|
-
import { jsx as
|
|
2216
|
-
var reactVersion =
|
|
2317
|
+
import { jsx as jsx12, jsxs as jsxs9, Fragment as Fragment3 } from "react/jsx-runtime";
|
|
2318
|
+
var reactVersion = React10.version.split(".")[0];
|
|
2217
2319
|
if (reactVersion === "0") {
|
|
2218
2320
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
2219
2321
|
}
|
|
2220
2322
|
var doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
2221
2323
|
var PlayerUI = ({
|
|
2222
2324
|
controls,
|
|
2223
|
-
style,
|
|
2325
|
+
style: style2,
|
|
2224
2326
|
loop,
|
|
2225
2327
|
autoPlay,
|
|
2226
2328
|
allowFullscreen,
|
|
@@ -2252,11 +2354,12 @@ var PlayerUI = ({
|
|
|
2252
2354
|
bufferStateDelayInMilliseconds,
|
|
2253
2355
|
hideControlsWhenPointerDoesntMove,
|
|
2254
2356
|
overflowVisible,
|
|
2255
|
-
browserMediaControlsBehavior
|
|
2357
|
+
browserMediaControlsBehavior,
|
|
2358
|
+
overrideInternalClassName
|
|
2256
2359
|
}, ref) => {
|
|
2257
|
-
const config =
|
|
2258
|
-
const video =
|
|
2259
|
-
const container =
|
|
2360
|
+
const config = Internals11.useUnsafeVideoConfig();
|
|
2361
|
+
const video = Internals11.useVideo();
|
|
2362
|
+
const container = useRef10(null);
|
|
2260
2363
|
const canvasSize = useElementSize(container, {
|
|
2261
2364
|
triggerOnWindowResize: false,
|
|
2262
2365
|
shouldApplyCssTransforms: false
|
|
@@ -2265,29 +2368,30 @@ var PlayerUI = ({
|
|
|
2265
2368
|
const [shouldAutoplay, setShouldAutoPlay] = useState11(autoPlay);
|
|
2266
2369
|
const [isFullscreen, setIsFullscreen] = useState11(() => false);
|
|
2267
2370
|
const [seeking, setSeeking] = useState11(false);
|
|
2268
|
-
const supportsFullScreen =
|
|
2371
|
+
const supportsFullScreen = useMemo12(() => {
|
|
2269
2372
|
if (typeof document === "undefined") {
|
|
2270
2373
|
return false;
|
|
2271
2374
|
}
|
|
2272
2375
|
return Boolean(document.fullscreenEnabled || document.webkitFullscreenEnabled);
|
|
2273
2376
|
}, []);
|
|
2274
2377
|
const player = usePlayer();
|
|
2378
|
+
const playerToggle = player.toggle;
|
|
2275
2379
|
usePlayback({
|
|
2276
2380
|
loop,
|
|
2277
2381
|
playbackRate,
|
|
2278
2382
|
moveToBeginningWhenEnded,
|
|
2279
2383
|
inFrame,
|
|
2280
2384
|
outFrame,
|
|
2281
|
-
|
|
2385
|
+
getCurrentFrame: player.getCurrentFrame,
|
|
2282
2386
|
browserMediaControlsBehavior
|
|
2283
2387
|
});
|
|
2284
|
-
|
|
2388
|
+
useEffect13(() => {
|
|
2285
2389
|
if (hasPausedToResume && !player.playing) {
|
|
2286
2390
|
setHasPausedToResume(false);
|
|
2287
2391
|
player.play();
|
|
2288
2392
|
}
|
|
2289
2393
|
}, [hasPausedToResume, player]);
|
|
2290
|
-
|
|
2394
|
+
useEffect13(() => {
|
|
2291
2395
|
const { current } = container;
|
|
2292
2396
|
if (!current) {
|
|
2293
2397
|
return;
|
|
@@ -2303,14 +2407,10 @@ var PlayerUI = ({
|
|
|
2303
2407
|
document.removeEventListener("webkitfullscreenchange", onFullscreenChange);
|
|
2304
2408
|
};
|
|
2305
2409
|
}, []);
|
|
2306
|
-
const toggle =
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
player.play(e);
|
|
2311
|
-
}
|
|
2312
|
-
}, [player]);
|
|
2313
|
-
const requestFullscreen = useCallback10(() => {
|
|
2410
|
+
const toggle = useCallback11((e) => {
|
|
2411
|
+
playerToggle(e);
|
|
2412
|
+
}, [playerToggle]);
|
|
2413
|
+
const requestFullscreen = useCallback11(() => {
|
|
2314
2414
|
if (!allowFullscreen) {
|
|
2315
2415
|
throw new Error("allowFullscreen is false");
|
|
2316
2416
|
}
|
|
@@ -2326,14 +2426,14 @@ var PlayerUI = ({
|
|
|
2326
2426
|
container.current.requestFullscreen();
|
|
2327
2427
|
}
|
|
2328
2428
|
}, [allowFullscreen, supportsFullScreen]);
|
|
2329
|
-
const exitFullscreen =
|
|
2429
|
+
const exitFullscreen = useCallback11(() => {
|
|
2330
2430
|
if (document.webkitExitFullscreen) {
|
|
2331
2431
|
document.webkitExitFullscreen();
|
|
2332
2432
|
} else {
|
|
2333
2433
|
document.exitFullscreen();
|
|
2334
2434
|
}
|
|
2335
2435
|
}, []);
|
|
2336
|
-
|
|
2436
|
+
useEffect13(() => {
|
|
2337
2437
|
const { current } = container;
|
|
2338
2438
|
if (!current) {
|
|
2339
2439
|
return;
|
|
@@ -2358,7 +2458,7 @@ var PlayerUI = ({
|
|
|
2358
2458
|
};
|
|
2359
2459
|
}, [player.emitter]);
|
|
2360
2460
|
const durationInFrames = config?.durationInFrames ?? 1;
|
|
2361
|
-
const layout =
|
|
2461
|
+
const layout = useMemo12(() => {
|
|
2362
2462
|
if (!config || !canvasSize) {
|
|
2363
2463
|
return null;
|
|
2364
2464
|
}
|
|
@@ -2370,27 +2470,27 @@ var PlayerUI = ({
|
|
|
2370
2470
|
});
|
|
2371
2471
|
}, [canvasSize, config]);
|
|
2372
2472
|
const scale = layout?.scale ?? 1;
|
|
2373
|
-
const initialScaleIgnored =
|
|
2374
|
-
|
|
2473
|
+
const initialScaleIgnored = useRef10(false);
|
|
2474
|
+
useEffect13(() => {
|
|
2375
2475
|
if (!initialScaleIgnored.current) {
|
|
2376
2476
|
initialScaleIgnored.current = true;
|
|
2377
2477
|
return;
|
|
2378
2478
|
}
|
|
2379
2479
|
player.emitter.dispatchScaleChange(scale);
|
|
2380
2480
|
}, [player.emitter, scale]);
|
|
2381
|
-
const { setMediaVolume, setMediaMuted } = useContext6(
|
|
2382
|
-
const { mediaMuted, mediaVolume } = useContext6(
|
|
2383
|
-
|
|
2481
|
+
const { setMediaVolume, setMediaMuted } = useContext6(Internals11.SetMediaVolumeContext);
|
|
2482
|
+
const { mediaMuted, mediaVolume } = useContext6(Internals11.MediaVolumeContext);
|
|
2483
|
+
useEffect13(() => {
|
|
2384
2484
|
player.emitter.dispatchVolumeChange(mediaVolume);
|
|
2385
2485
|
}, [player.emitter, mediaVolume]);
|
|
2386
2486
|
const isMuted = mediaMuted || mediaVolume === 0;
|
|
2387
|
-
|
|
2487
|
+
useEffect13(() => {
|
|
2388
2488
|
player.emitter.dispatchMuteChange({
|
|
2389
2489
|
isMuted
|
|
2390
2490
|
});
|
|
2391
2491
|
}, [player.emitter, isMuted]);
|
|
2392
2492
|
const [showBufferIndicator, setShowBufferState] = useState11(false);
|
|
2393
|
-
|
|
2493
|
+
useEffect13(() => {
|
|
2394
2494
|
let timeout = null;
|
|
2395
2495
|
let stopped = false;
|
|
2396
2496
|
const onBuffer = () => {
|
|
@@ -2507,19 +2607,19 @@ var PlayerUI = ({
|
|
|
2507
2607
|
scale
|
|
2508
2608
|
]);
|
|
2509
2609
|
const VideoComponent = video ? video.component : null;
|
|
2510
|
-
const outerStyle =
|
|
2610
|
+
const outerStyle = useMemo12(() => {
|
|
2511
2611
|
return calculateOuterStyle({
|
|
2512
2612
|
canvasSize,
|
|
2513
2613
|
config,
|
|
2514
|
-
style,
|
|
2614
|
+
style: style2,
|
|
2515
2615
|
overflowVisible,
|
|
2516
2616
|
layout
|
|
2517
2617
|
});
|
|
2518
|
-
}, [canvasSize, config, layout, overflowVisible,
|
|
2519
|
-
const outer =
|
|
2618
|
+
}, [canvasSize, config, layout, overflowVisible, style2]);
|
|
2619
|
+
const outer = useMemo12(() => {
|
|
2520
2620
|
return calculateOuter({ config, layout, scale, overflowVisible });
|
|
2521
2621
|
}, [config, layout, overflowVisible, scale]);
|
|
2522
|
-
const containerStyle3 =
|
|
2622
|
+
const containerStyle3 = useMemo12(() => {
|
|
2523
2623
|
return calculateContainerStyle({
|
|
2524
2624
|
canvasSize,
|
|
2525
2625
|
config,
|
|
@@ -2528,32 +2628,34 @@ var PlayerUI = ({
|
|
|
2528
2628
|
overflowVisible
|
|
2529
2629
|
});
|
|
2530
2630
|
}, [canvasSize, config, layout, overflowVisible, scale]);
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2631
|
+
const playerPause = player.pause;
|
|
2632
|
+
const playerDispatchError = player.emitter.dispatchError;
|
|
2633
|
+
const onError = useCallback11((error) => {
|
|
2634
|
+
playerPause();
|
|
2635
|
+
playerDispatchError(error);
|
|
2636
|
+
}, [playerDispatchError, playerPause]);
|
|
2637
|
+
const onFullscreenButtonClick = useCallback11((e) => {
|
|
2536
2638
|
e.stopPropagation();
|
|
2537
2639
|
requestFullscreen();
|
|
2538
2640
|
}, [requestFullscreen]);
|
|
2539
|
-
const onExitFullscreenButtonClick =
|
|
2641
|
+
const onExitFullscreenButtonClick = useCallback11((e) => {
|
|
2540
2642
|
e.stopPropagation();
|
|
2541
2643
|
exitFullscreen();
|
|
2542
2644
|
}, [exitFullscreen]);
|
|
2543
|
-
const onSingleClick =
|
|
2645
|
+
const onSingleClick = useCallback11((e) => {
|
|
2544
2646
|
const rightClick = e instanceof MouseEvent ? e.button === 2 : e.nativeEvent.button;
|
|
2545
2647
|
if (rightClick) {
|
|
2546
2648
|
return;
|
|
2547
2649
|
}
|
|
2548
2650
|
toggle(e);
|
|
2549
2651
|
}, [toggle]);
|
|
2550
|
-
const onSeekStart =
|
|
2652
|
+
const onSeekStart = useCallback11(() => {
|
|
2551
2653
|
setSeeking(true);
|
|
2552
2654
|
}, []);
|
|
2553
|
-
const onSeekEnd =
|
|
2655
|
+
const onSeekEnd = useCallback11(() => {
|
|
2554
2656
|
setSeeking(false);
|
|
2555
2657
|
}, []);
|
|
2556
|
-
const onDoubleClick =
|
|
2658
|
+
const onDoubleClick = useCallback11(() => {
|
|
2557
2659
|
if (isFullscreen) {
|
|
2558
2660
|
exitFullscreen();
|
|
2559
2661
|
} else {
|
|
@@ -2561,20 +2663,20 @@ var PlayerUI = ({
|
|
|
2561
2663
|
}
|
|
2562
2664
|
}, [exitFullscreen, isFullscreen, requestFullscreen]);
|
|
2563
2665
|
const { handlePointerDown, handleDoubleClick } = useClickPreventionOnDoubleClick(onSingleClick, onDoubleClick, doubleClickToFullscreen && allowFullscreen && supportsFullScreen);
|
|
2564
|
-
|
|
2666
|
+
useEffect13(() => {
|
|
2565
2667
|
if (shouldAutoplay) {
|
|
2566
2668
|
player.play();
|
|
2567
2669
|
setShouldAutoPlay(false);
|
|
2568
2670
|
}
|
|
2569
2671
|
}, [shouldAutoplay, player]);
|
|
2570
|
-
const loadingMarkup =
|
|
2672
|
+
const loadingMarkup = useMemo12(() => {
|
|
2571
2673
|
return renderLoading ? renderLoading({
|
|
2572
2674
|
height: outerStyle.height,
|
|
2573
2675
|
width: outerStyle.width,
|
|
2574
2676
|
isBuffering: showBufferIndicator
|
|
2575
2677
|
}) : null;
|
|
2576
2678
|
}, [outerStyle.height, outerStyle.width, renderLoading, showBufferIndicator]);
|
|
2577
|
-
const currentScale =
|
|
2679
|
+
const currentScale = useMemo12(() => {
|
|
2578
2680
|
return {
|
|
2579
2681
|
type: "scale",
|
|
2580
2682
|
scale
|
|
@@ -2598,50 +2700,54 @@ var PlayerUI = ({
|
|
|
2598
2700
|
showPosterWhenBuffering && showBufferIndicator && player.isPlaying()
|
|
2599
2701
|
].some(Boolean);
|
|
2600
2702
|
const { left, top, width, height, ...outerWithoutScale } = outer;
|
|
2601
|
-
const content = /* @__PURE__ */
|
|
2703
|
+
const content = /* @__PURE__ */ jsxs9(Fragment3, {
|
|
2602
2704
|
children: [
|
|
2603
|
-
/* @__PURE__ */
|
|
2705
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
2604
2706
|
style: outer,
|
|
2605
2707
|
onPointerDown: clickToPlay ? handlePointerDown : undefined,
|
|
2606
2708
|
onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
|
|
2607
|
-
children:
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2709
|
+
children: [
|
|
2710
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
2711
|
+
style: containerStyle3,
|
|
2712
|
+
className: playerCssClassname(overrideInternalClassName),
|
|
2713
|
+
children: [
|
|
2714
|
+
VideoComponent ? /* @__PURE__ */ jsx12(ErrorBoundary, {
|
|
2715
|
+
onError,
|
|
2716
|
+
errorFallback,
|
|
2717
|
+
children: /* @__PURE__ */ jsx12(Internals11.CurrentScaleContext.Provider, {
|
|
2718
|
+
value: currentScale,
|
|
2719
|
+
children: /* @__PURE__ */ jsx12(VideoComponent, {
|
|
2720
|
+
...video?.props ?? {},
|
|
2721
|
+
...inputProps ?? {}
|
|
2722
|
+
})
|
|
2619
2723
|
})
|
|
2620
|
-
})
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2724
|
+
}) : null,
|
|
2725
|
+
shouldShowPoster && posterFillMode === "composition-size" ? /* @__PURE__ */ jsx12("div", {
|
|
2726
|
+
style: {
|
|
2727
|
+
...outerWithoutScale,
|
|
2728
|
+
width: config.width,
|
|
2729
|
+
height: config.height
|
|
2730
|
+
},
|
|
2731
|
+
onPointerDown: clickToPlay ? handlePointerDown : undefined,
|
|
2732
|
+
onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
|
|
2733
|
+
children: poster
|
|
2734
|
+
}) : null
|
|
2735
|
+
]
|
|
2736
|
+
}),
|
|
2737
|
+
/* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {})
|
|
2738
|
+
]
|
|
2634
2739
|
}),
|
|
2635
|
-
shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */
|
|
2740
|
+
shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx12("div", {
|
|
2636
2741
|
style: outer,
|
|
2637
2742
|
onPointerDown: clickToPlay ? handlePointerDown : undefined,
|
|
2638
2743
|
onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
|
|
2639
2744
|
children: poster
|
|
2640
2745
|
}) : null,
|
|
2641
|
-
controls ? /* @__PURE__ */
|
|
2746
|
+
controls ? /* @__PURE__ */ jsx12(Controls, {
|
|
2642
2747
|
fps: config.fps,
|
|
2748
|
+
playing: player.playing,
|
|
2749
|
+
toggle: player.toggle,
|
|
2643
2750
|
durationInFrames: config.durationInFrames,
|
|
2644
|
-
player,
|
|
2645
2751
|
containerRef: container,
|
|
2646
2752
|
onFullscreenButtonClick,
|
|
2647
2753
|
isFullscreen,
|
|
@@ -2669,18 +2775,18 @@ var PlayerUI = ({
|
|
|
2669
2775
|
]
|
|
2670
2776
|
});
|
|
2671
2777
|
if (IS_NODE && !doesReactVersionSupportSuspense) {
|
|
2672
|
-
return /* @__PURE__ */
|
|
2778
|
+
return /* @__PURE__ */ jsx12("div", {
|
|
2673
2779
|
ref: container,
|
|
2674
2780
|
style: outerStyle,
|
|
2675
2781
|
className: className2,
|
|
2676
2782
|
children: content
|
|
2677
2783
|
});
|
|
2678
2784
|
}
|
|
2679
|
-
return /* @__PURE__ */
|
|
2785
|
+
return /* @__PURE__ */ jsx12("div", {
|
|
2680
2786
|
ref: container,
|
|
2681
2787
|
style: outerStyle,
|
|
2682
2788
|
className: className2,
|
|
2683
|
-
children: /* @__PURE__ */
|
|
2789
|
+
children: /* @__PURE__ */ jsx12(Suspense, {
|
|
2684
2790
|
fallback: loadingMarkup,
|
|
2685
2791
|
children: content
|
|
2686
2792
|
})
|
|
@@ -2689,8 +2795,8 @@ var PlayerUI = ({
|
|
|
2689
2795
|
var PlayerUI_default = forwardRef(PlayerUI);
|
|
2690
2796
|
|
|
2691
2797
|
// src/SharedPlayerContext.tsx
|
|
2692
|
-
import { useCallback as
|
|
2693
|
-
import { Internals as
|
|
2798
|
+
import { useCallback as useCallback12, useMemo as useMemo13, useState as useState12 } from "react";
|
|
2799
|
+
import { Internals as Internals12 } from "remotion";
|
|
2694
2800
|
|
|
2695
2801
|
// src/volume-persistance.ts
|
|
2696
2802
|
var VOLUME_PERSISTANCE_KEY = "remotion.volumePreference";
|
|
@@ -2717,7 +2823,7 @@ var getPreferredVolume = () => {
|
|
|
2717
2823
|
};
|
|
2718
2824
|
|
|
2719
2825
|
// src/SharedPlayerContext.tsx
|
|
2720
|
-
import { jsx as
|
|
2826
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2721
2827
|
var PLAYER_COMP_ID = "player-comp";
|
|
2722
2828
|
var SharedPlayerContexts = ({
|
|
2723
2829
|
children,
|
|
@@ -2730,7 +2836,7 @@ var SharedPlayerContexts = ({
|
|
|
2730
2836
|
numberOfSharedAudioTags,
|
|
2731
2837
|
initiallyMuted
|
|
2732
2838
|
}) => {
|
|
2733
|
-
const compositionManagerContext =
|
|
2839
|
+
const compositionManagerContext = useMemo13(() => {
|
|
2734
2840
|
const context = {
|
|
2735
2841
|
compositions: [
|
|
2736
2842
|
{
|
|
@@ -2776,38 +2882,38 @@ var SharedPlayerContexts = ({
|
|
|
2776
2882
|
}, [component, durationInFrames, compositionHeight, compositionWidth, fps]);
|
|
2777
2883
|
const [mediaMuted, setMediaMuted] = useState12(() => initiallyMuted);
|
|
2778
2884
|
const [mediaVolume, setMediaVolume] = useState12(() => getPreferredVolume());
|
|
2779
|
-
const mediaVolumeContextValue =
|
|
2885
|
+
const mediaVolumeContextValue = useMemo13(() => {
|
|
2780
2886
|
return {
|
|
2781
2887
|
mediaMuted,
|
|
2782
2888
|
mediaVolume
|
|
2783
2889
|
};
|
|
2784
2890
|
}, [mediaMuted, mediaVolume]);
|
|
2785
|
-
const setMediaVolumeAndPersist =
|
|
2891
|
+
const setMediaVolumeAndPersist = useCallback12((vol) => {
|
|
2786
2892
|
setMediaVolume(vol);
|
|
2787
2893
|
persistVolume(vol);
|
|
2788
2894
|
}, []);
|
|
2789
|
-
const setMediaVolumeContextValue =
|
|
2895
|
+
const setMediaVolumeContextValue = useMemo13(() => {
|
|
2790
2896
|
return {
|
|
2791
2897
|
setMediaMuted,
|
|
2792
2898
|
setMediaVolume: setMediaVolumeAndPersist
|
|
2793
2899
|
};
|
|
2794
2900
|
}, [setMediaVolumeAndPersist]);
|
|
2795
|
-
return /* @__PURE__ */
|
|
2796
|
-
children: /* @__PURE__ */
|
|
2901
|
+
return /* @__PURE__ */ jsx13(Internals12.CanUseRemotionHooksProvider, {
|
|
2902
|
+
children: /* @__PURE__ */ jsx13(Internals12.Timeline.TimelineContext.Provider, {
|
|
2797
2903
|
value: timelineContext,
|
|
2798
|
-
children: /* @__PURE__ */
|
|
2904
|
+
children: /* @__PURE__ */ jsx13(Internals12.CompositionManager.Provider, {
|
|
2799
2905
|
value: compositionManagerContext,
|
|
2800
|
-
children: /* @__PURE__ */
|
|
2801
|
-
children: /* @__PURE__ */
|
|
2802
|
-
children: /* @__PURE__ */
|
|
2803
|
-
children: /* @__PURE__ */
|
|
2906
|
+
children: /* @__PURE__ */ jsx13(Internals12.ResolveCompositionConfig, {
|
|
2907
|
+
children: /* @__PURE__ */ jsx13(Internals12.PrefetchProvider, {
|
|
2908
|
+
children: /* @__PURE__ */ jsx13(Internals12.DurationsContextProvider, {
|
|
2909
|
+
children: /* @__PURE__ */ jsx13(Internals12.MediaVolumeContext.Provider, {
|
|
2804
2910
|
value: mediaVolumeContextValue,
|
|
2805
|
-
children: /* @__PURE__ */
|
|
2911
|
+
children: /* @__PURE__ */ jsx13(Internals12.SetMediaVolumeContext.Provider, {
|
|
2806
2912
|
value: setMediaVolumeContextValue,
|
|
2807
|
-
children: /* @__PURE__ */
|
|
2913
|
+
children: /* @__PURE__ */ jsx13(Internals12.SharedAudioContextProvider, {
|
|
2808
2914
|
numberOfAudioTags: numberOfSharedAudioTags,
|
|
2809
2915
|
component,
|
|
2810
|
-
children: /* @__PURE__ */
|
|
2916
|
+
children: /* @__PURE__ */ jsx13(Internals12.BufferingProvider, {
|
|
2811
2917
|
children
|
|
2812
2918
|
})
|
|
2813
2919
|
})
|
|
@@ -2919,7 +3025,7 @@ var validateDurationInFrames = NoReactInternals.validateDurationInFrames;
|
|
|
2919
3025
|
var validateDefaultAndInputProps = NoReactInternals.validateDefaultAndInputProps;
|
|
2920
3026
|
|
|
2921
3027
|
// src/Player.tsx
|
|
2922
|
-
import { jsx as
|
|
3028
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
2923
3029
|
var componentOrNullIfLazy = (props) => {
|
|
2924
3030
|
if ("component" in props) {
|
|
2925
3031
|
return props.component;
|
|
@@ -2932,7 +3038,7 @@ var PlayerFn = ({
|
|
|
2932
3038
|
compositionWidth,
|
|
2933
3039
|
fps,
|
|
2934
3040
|
inputProps,
|
|
2935
|
-
style,
|
|
3041
|
+
style: style2,
|
|
2936
3042
|
controls = false,
|
|
2937
3043
|
loop = false,
|
|
2938
3044
|
autoPlay = false,
|
|
@@ -2943,7 +3049,7 @@ var PlayerFn = ({
|
|
|
2943
3049
|
spaceKeyToPlayOrPause = true,
|
|
2944
3050
|
moveToBeginningWhenEnded = true,
|
|
2945
3051
|
numberOfSharedAudioTags = 5,
|
|
2946
|
-
errorFallback = () => "
|
|
3052
|
+
errorFallback = () => "⚠️",
|
|
2947
3053
|
playbackRate = 1,
|
|
2948
3054
|
renderLoading,
|
|
2949
3055
|
className: className2,
|
|
@@ -2968,6 +3074,7 @@ var PlayerFn = ({
|
|
|
2968
3074
|
overflowVisible = false,
|
|
2969
3075
|
renderMuteButton,
|
|
2970
3076
|
browserMediaControlsBehavior: passedBrowserMediaControlsBehavior,
|
|
3077
|
+
overrideInternalClassName,
|
|
2971
3078
|
...componentProps
|
|
2972
3079
|
}, ref) => {
|
|
2973
3080
|
if (typeof window !== "undefined") {
|
|
@@ -2985,16 +3092,16 @@ var PlayerFn = ({
|
|
|
2985
3092
|
if (componentForValidation === Composition) {
|
|
2986
3093
|
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.`);
|
|
2987
3094
|
}
|
|
2988
|
-
const component =
|
|
3095
|
+
const component = Internals13.useLazyComponent(componentProps);
|
|
2989
3096
|
validateInitialFrame({ initialFrame, durationInFrames });
|
|
2990
3097
|
const [frame, setFrame] = useState13(() => ({
|
|
2991
3098
|
[PLAYER_COMP_ID]: initialFrame ?? 0
|
|
2992
3099
|
}));
|
|
2993
3100
|
const [playing, setPlaying] = useState13(false);
|
|
2994
3101
|
const [rootId] = useState13("player-comp");
|
|
2995
|
-
const rootRef =
|
|
2996
|
-
const audioAndVideoTags =
|
|
2997
|
-
const imperativePlaying =
|
|
3102
|
+
const rootRef = useRef11(null);
|
|
3103
|
+
const audioAndVideoTags = useRef11([]);
|
|
3104
|
+
const imperativePlaying = useRef11(false);
|
|
2998
3105
|
const [currentPlaybackRate, setCurrentPlaybackRate] = useState13(playbackRate);
|
|
2999
3106
|
if (typeof compositionHeight !== "number") {
|
|
3000
3107
|
throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
|
|
@@ -3043,11 +3150,11 @@ var PlayerFn = ({
|
|
|
3043
3150
|
throw new TypeError(`'numberOfSharedAudioTags' must be an integer but got '${numberOfSharedAudioTags}' instead`);
|
|
3044
3151
|
}
|
|
3045
3152
|
validatePlaybackRate(currentPlaybackRate);
|
|
3046
|
-
|
|
3153
|
+
useEffect14(() => {
|
|
3047
3154
|
setCurrentPlaybackRate(playbackRate);
|
|
3048
3155
|
}, [playbackRate]);
|
|
3049
3156
|
useImperativeHandle2(ref, () => rootRef.current, []);
|
|
3050
|
-
const timelineContextValue =
|
|
3157
|
+
const timelineContextValue = useMemo14(() => {
|
|
3051
3158
|
return {
|
|
3052
3159
|
frame,
|
|
3053
3160
|
playing,
|
|
@@ -3060,7 +3167,7 @@ var PlayerFn = ({
|
|
|
3060
3167
|
audioAndVideoTags
|
|
3061
3168
|
};
|
|
3062
3169
|
}, [frame, currentPlaybackRate, playing, rootId]);
|
|
3063
|
-
const setTimelineContextValue =
|
|
3170
|
+
const setTimelineContextValue = useMemo14(() => {
|
|
3064
3171
|
return {
|
|
3065
3172
|
setFrame,
|
|
3066
3173
|
setPlaying
|
|
@@ -3068,17 +3175,17 @@ var PlayerFn = ({
|
|
|
3068
3175
|
}, [setFrame]);
|
|
3069
3176
|
if (typeof window !== "undefined") {
|
|
3070
3177
|
useLayoutEffect(() => {
|
|
3071
|
-
|
|
3072
|
-
}, []);
|
|
3178
|
+
Internals13.CSSUtils.injectCSS(Internals13.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
|
|
3179
|
+
}, [overrideInternalClassName]);
|
|
3073
3180
|
}
|
|
3074
|
-
const actualInputProps =
|
|
3075
|
-
const browserMediaControlsBehavior =
|
|
3181
|
+
const actualInputProps = useMemo14(() => inputProps ?? {}, [inputProps]);
|
|
3182
|
+
const browserMediaControlsBehavior = useMemo14(() => {
|
|
3076
3183
|
return passedBrowserMediaControlsBehavior ?? {
|
|
3077
3184
|
mode: "prevent-media-session"
|
|
3078
3185
|
};
|
|
3079
3186
|
}, [passedBrowserMediaControlsBehavior]);
|
|
3080
|
-
return /* @__PURE__ */
|
|
3081
|
-
children: /* @__PURE__ */
|
|
3187
|
+
return /* @__PURE__ */ jsx14(Internals13.IsPlayerContextProvider, {
|
|
3188
|
+
children: /* @__PURE__ */ jsx14(SharedPlayerContexts, {
|
|
3082
3189
|
timelineContext: timelineContextValue,
|
|
3083
3190
|
component,
|
|
3084
3191
|
compositionHeight,
|
|
@@ -3087,11 +3194,11 @@ var PlayerFn = ({
|
|
|
3087
3194
|
fps,
|
|
3088
3195
|
numberOfSharedAudioTags,
|
|
3089
3196
|
initiallyMuted,
|
|
3090
|
-
children: /* @__PURE__ */
|
|
3197
|
+
children: /* @__PURE__ */ jsx14(Internals13.Timeline.SetTimelineContext.Provider, {
|
|
3091
3198
|
value: setTimelineContextValue,
|
|
3092
|
-
children: /* @__PURE__ */
|
|
3199
|
+
children: /* @__PURE__ */ jsx14(PlayerEmitterProvider, {
|
|
3093
3200
|
currentPlaybackRate,
|
|
3094
|
-
children: /* @__PURE__ */
|
|
3201
|
+
children: /* @__PURE__ */ jsx14(PlayerUI_default, {
|
|
3095
3202
|
ref: rootRef,
|
|
3096
3203
|
posterFillMode,
|
|
3097
3204
|
renderLoading,
|
|
@@ -3099,7 +3206,7 @@ var PlayerFn = ({
|
|
|
3099
3206
|
loop: Boolean(loop),
|
|
3100
3207
|
controls: Boolean(controls),
|
|
3101
3208
|
errorFallback,
|
|
3102
|
-
style,
|
|
3209
|
+
style: style2,
|
|
3103
3210
|
inputProps: actualInputProps,
|
|
3104
3211
|
allowFullscreen: Boolean(allowFullscreen),
|
|
3105
3212
|
moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded),
|
|
@@ -3126,7 +3233,8 @@ var PlayerFn = ({
|
|
|
3126
3233
|
bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds ?? 300,
|
|
3127
3234
|
hideControlsWhenPointerDoesntMove,
|
|
3128
3235
|
overflowVisible,
|
|
3129
|
-
browserMediaControlsBehavior
|
|
3236
|
+
browserMediaControlsBehavior,
|
|
3237
|
+
overrideInternalClassName: overrideInternalClassName ?? undefined
|
|
3130
3238
|
})
|
|
3131
3239
|
})
|
|
3132
3240
|
})
|
|
@@ -3140,31 +3248,31 @@ import {
|
|
|
3140
3248
|
forwardRef as forwardRef4,
|
|
3141
3249
|
useImperativeHandle as useImperativeHandle4,
|
|
3142
3250
|
useLayoutEffect as useLayoutEffect2,
|
|
3143
|
-
useMemo as
|
|
3144
|
-
useRef as
|
|
3251
|
+
useMemo as useMemo17,
|
|
3252
|
+
useRef as useRef13,
|
|
3145
3253
|
useState as useState14
|
|
3146
3254
|
} from "react";
|
|
3147
|
-
import { Internals as
|
|
3255
|
+
import { Internals as Internals15, random as random2 } from "remotion";
|
|
3148
3256
|
|
|
3149
3257
|
// src/ThumbnailUI.tsx
|
|
3150
|
-
import
|
|
3258
|
+
import React13, {
|
|
3151
3259
|
forwardRef as forwardRef3,
|
|
3152
3260
|
Suspense as Suspense2,
|
|
3153
|
-
useCallback as
|
|
3261
|
+
useCallback as useCallback13,
|
|
3154
3262
|
useImperativeHandle as useImperativeHandle3,
|
|
3155
|
-
useMemo as
|
|
3156
|
-
useRef as
|
|
3263
|
+
useMemo as useMemo16,
|
|
3264
|
+
useRef as useRef12
|
|
3157
3265
|
} from "react";
|
|
3158
|
-
import { Internals as
|
|
3266
|
+
import { Internals as Internals14 } from "remotion";
|
|
3159
3267
|
|
|
3160
3268
|
// src/use-thumbnail.ts
|
|
3161
|
-
import { useContext as useContext7, useMemo as
|
|
3269
|
+
import { useContext as useContext7, useMemo as useMemo15 } from "react";
|
|
3162
3270
|
var useThumbnail = () => {
|
|
3163
3271
|
const emitter = useContext7(ThumbnailEmitterContext);
|
|
3164
3272
|
if (!emitter) {
|
|
3165
3273
|
throw new TypeError("Expected Player event emitter context");
|
|
3166
3274
|
}
|
|
3167
|
-
const returnValue =
|
|
3275
|
+
const returnValue = useMemo15(() => {
|
|
3168
3276
|
return {
|
|
3169
3277
|
emitter
|
|
3170
3278
|
};
|
|
@@ -3173,21 +3281,29 @@ var useThumbnail = () => {
|
|
|
3173
3281
|
};
|
|
3174
3282
|
|
|
3175
3283
|
// src/ThumbnailUI.tsx
|
|
3176
|
-
import { jsx as
|
|
3177
|
-
var reactVersion2 =
|
|
3284
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
3285
|
+
var reactVersion2 = React13.version.split(".")[0];
|
|
3178
3286
|
if (reactVersion2 === "0") {
|
|
3179
3287
|
throw new Error(`Version ${reactVersion2} of "react" is not supported by Remotion`);
|
|
3180
3288
|
}
|
|
3181
3289
|
var doesReactVersionSupportSuspense2 = parseInt(reactVersion2, 10) >= 18;
|
|
3182
|
-
var ThumbnailUI = ({
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3290
|
+
var ThumbnailUI = ({
|
|
3291
|
+
style: style2,
|
|
3292
|
+
inputProps,
|
|
3293
|
+
errorFallback,
|
|
3294
|
+
renderLoading,
|
|
3295
|
+
className: className2,
|
|
3296
|
+
overflowVisible,
|
|
3297
|
+
overrideInternalClassName
|
|
3298
|
+
}, ref) => {
|
|
3299
|
+
const config = Internals14.useUnsafeVideoConfig();
|
|
3300
|
+
const video = Internals14.useVideo();
|
|
3301
|
+
const container = useRef12(null);
|
|
3186
3302
|
const canvasSize = useElementSize(container, {
|
|
3187
3303
|
triggerOnWindowResize: false,
|
|
3188
3304
|
shouldApplyCssTransforms: false
|
|
3189
3305
|
});
|
|
3190
|
-
const layout =
|
|
3306
|
+
const layout = useMemo16(() => {
|
|
3191
3307
|
if (!config || !canvasSize) {
|
|
3192
3308
|
return null;
|
|
3193
3309
|
}
|
|
@@ -3209,19 +3325,19 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3209
3325
|
return Object.assign(thumbnail.emitter, methods);
|
|
3210
3326
|
}, [scale, thumbnail.emitter]);
|
|
3211
3327
|
const VideoComponent = video ? video.component : null;
|
|
3212
|
-
const outerStyle =
|
|
3328
|
+
const outerStyle = useMemo16(() => {
|
|
3213
3329
|
return calculateOuterStyle({
|
|
3214
3330
|
config,
|
|
3215
|
-
style,
|
|
3331
|
+
style: style2,
|
|
3216
3332
|
canvasSize,
|
|
3217
3333
|
overflowVisible,
|
|
3218
3334
|
layout
|
|
3219
3335
|
});
|
|
3220
|
-
}, [canvasSize, config, layout, overflowVisible,
|
|
3221
|
-
const outer =
|
|
3336
|
+
}, [canvasSize, config, layout, overflowVisible, style2]);
|
|
3337
|
+
const outer = useMemo16(() => {
|
|
3222
3338
|
return calculateOuter({ config, layout, scale, overflowVisible });
|
|
3223
3339
|
}, [config, layout, overflowVisible, scale]);
|
|
3224
|
-
const containerStyle3 =
|
|
3340
|
+
const containerStyle3 = useMemo16(() => {
|
|
3225
3341
|
return calculateContainerStyle({
|
|
3226
3342
|
canvasSize,
|
|
3227
3343
|
config,
|
|
@@ -3230,17 +3346,17 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3230
3346
|
overflowVisible
|
|
3231
3347
|
});
|
|
3232
3348
|
}, [canvasSize, config, layout, overflowVisible, scale]);
|
|
3233
|
-
const onError =
|
|
3349
|
+
const onError = useCallback13((error) => {
|
|
3234
3350
|
thumbnail.emitter.dispatchError(error);
|
|
3235
3351
|
}, [thumbnail.emitter]);
|
|
3236
|
-
const loadingMarkup =
|
|
3352
|
+
const loadingMarkup = useMemo16(() => {
|
|
3237
3353
|
return renderLoading ? renderLoading({
|
|
3238
3354
|
height: outerStyle.height,
|
|
3239
3355
|
width: outerStyle.width,
|
|
3240
3356
|
isBuffering: false
|
|
3241
3357
|
}) : null;
|
|
3242
3358
|
}, [outerStyle.height, outerStyle.width, renderLoading]);
|
|
3243
|
-
const currentScaleContext =
|
|
3359
|
+
const currentScaleContext = useMemo16(() => {
|
|
3244
3360
|
return {
|
|
3245
3361
|
type: "scale",
|
|
3246
3362
|
scale
|
|
@@ -3249,17 +3365,17 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3249
3365
|
if (!config) {
|
|
3250
3366
|
return null;
|
|
3251
3367
|
}
|
|
3252
|
-
const content = /* @__PURE__ */
|
|
3368
|
+
const content = /* @__PURE__ */ jsx15("div", {
|
|
3253
3369
|
style: outer,
|
|
3254
|
-
children: /* @__PURE__ */
|
|
3370
|
+
children: /* @__PURE__ */ jsx15("div", {
|
|
3255
3371
|
style: containerStyle3,
|
|
3256
|
-
className:
|
|
3257
|
-
children: VideoComponent ? /* @__PURE__ */
|
|
3372
|
+
className: playerCssClassname(overrideInternalClassName),
|
|
3373
|
+
children: VideoComponent ? /* @__PURE__ */ jsx15(ErrorBoundary, {
|
|
3258
3374
|
onError,
|
|
3259
3375
|
errorFallback,
|
|
3260
|
-
children: /* @__PURE__ */
|
|
3376
|
+
children: /* @__PURE__ */ jsx15(Internals14.CurrentScaleContext.Provider, {
|
|
3261
3377
|
value: currentScaleContext,
|
|
3262
|
-
children: /* @__PURE__ */
|
|
3378
|
+
children: /* @__PURE__ */ jsx15(VideoComponent, {
|
|
3263
3379
|
...video?.props ?? {},
|
|
3264
3380
|
...inputProps ?? {}
|
|
3265
3381
|
})
|
|
@@ -3268,18 +3384,18 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3268
3384
|
})
|
|
3269
3385
|
});
|
|
3270
3386
|
if (IS_NODE && !doesReactVersionSupportSuspense2) {
|
|
3271
|
-
return /* @__PURE__ */
|
|
3387
|
+
return /* @__PURE__ */ jsx15("div", {
|
|
3272
3388
|
ref: container,
|
|
3273
3389
|
style: outerStyle,
|
|
3274
3390
|
className: className2,
|
|
3275
3391
|
children: content
|
|
3276
3392
|
});
|
|
3277
3393
|
}
|
|
3278
|
-
return /* @__PURE__ */
|
|
3394
|
+
return /* @__PURE__ */ jsx15("div", {
|
|
3279
3395
|
ref: container,
|
|
3280
3396
|
style: outerStyle,
|
|
3281
3397
|
className: className2,
|
|
3282
|
-
children: /* @__PURE__ */
|
|
3398
|
+
children: /* @__PURE__ */ jsx15(Suspense2, {
|
|
3283
3399
|
fallback: loadingMarkup,
|
|
3284
3400
|
children: content
|
|
3285
3401
|
})
|
|
@@ -3288,19 +3404,20 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3288
3404
|
var ThumbnailUI_default = forwardRef3(ThumbnailUI);
|
|
3289
3405
|
|
|
3290
3406
|
// src/Thumbnail.tsx
|
|
3291
|
-
import { jsx as
|
|
3407
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
3292
3408
|
var ThumbnailFn = ({
|
|
3293
3409
|
frameToDisplay,
|
|
3294
|
-
style,
|
|
3410
|
+
style: style2,
|
|
3295
3411
|
inputProps,
|
|
3296
3412
|
compositionHeight,
|
|
3297
3413
|
compositionWidth,
|
|
3298
3414
|
durationInFrames,
|
|
3299
3415
|
fps,
|
|
3300
3416
|
className: className2,
|
|
3301
|
-
errorFallback = () => "
|
|
3417
|
+
errorFallback = () => "⚠️",
|
|
3302
3418
|
renderLoading,
|
|
3303
3419
|
overflowVisible = false,
|
|
3420
|
+
overrideInternalClassName,
|
|
3304
3421
|
...componentProps
|
|
3305
3422
|
}, ref) => {
|
|
3306
3423
|
if (typeof window !== "undefined") {
|
|
@@ -3309,8 +3426,8 @@ var ThumbnailFn = ({
|
|
|
3309
3426
|
}, []);
|
|
3310
3427
|
}
|
|
3311
3428
|
const [thumbnailId] = useState14(() => String(random2(null)));
|
|
3312
|
-
const rootRef =
|
|
3313
|
-
const timelineState =
|
|
3429
|
+
const rootRef = useRef13(null);
|
|
3430
|
+
const timelineState = useMemo17(() => {
|
|
3314
3431
|
const value = {
|
|
3315
3432
|
playing: false,
|
|
3316
3433
|
frame: {
|
|
@@ -3329,13 +3446,13 @@ var ThumbnailFn = ({
|
|
|
3329
3446
|
return value;
|
|
3330
3447
|
}, [frameToDisplay, thumbnailId]);
|
|
3331
3448
|
useImperativeHandle4(ref, () => rootRef.current, []);
|
|
3332
|
-
const Component =
|
|
3449
|
+
const Component = Internals15.useLazyComponent(componentProps);
|
|
3333
3450
|
const [emitter] = useState14(() => new ThumbnailEmitter);
|
|
3334
|
-
const passedInputProps =
|
|
3451
|
+
const passedInputProps = useMemo17(() => {
|
|
3335
3452
|
return inputProps ?? {};
|
|
3336
3453
|
}, [inputProps]);
|
|
3337
|
-
return /* @__PURE__ */
|
|
3338
|
-
children: /* @__PURE__ */
|
|
3454
|
+
return /* @__PURE__ */ jsx16(Internals15.IsPlayerContextProvider, {
|
|
3455
|
+
children: /* @__PURE__ */ jsx16(SharedPlayerContexts, {
|
|
3339
3456
|
timelineContext: timelineState,
|
|
3340
3457
|
component: Component,
|
|
3341
3458
|
compositionHeight,
|
|
@@ -3344,16 +3461,17 @@ var ThumbnailFn = ({
|
|
|
3344
3461
|
fps,
|
|
3345
3462
|
numberOfSharedAudioTags: 0,
|
|
3346
3463
|
initiallyMuted: true,
|
|
3347
|
-
children: /* @__PURE__ */
|
|
3464
|
+
children: /* @__PURE__ */ jsx16(ThumbnailEmitterContext.Provider, {
|
|
3348
3465
|
value: emitter,
|
|
3349
|
-
children: /* @__PURE__ */
|
|
3466
|
+
children: /* @__PURE__ */ jsx16(ThumbnailUI_default, {
|
|
3350
3467
|
ref: rootRef,
|
|
3351
3468
|
className: className2,
|
|
3352
3469
|
errorFallback,
|
|
3353
3470
|
inputProps: passedInputProps,
|
|
3354
3471
|
renderLoading,
|
|
3355
|
-
style,
|
|
3356
|
-
overflowVisible
|
|
3472
|
+
style: style2,
|
|
3473
|
+
overflowVisible,
|
|
3474
|
+
overrideInternalClassName
|
|
3357
3475
|
})
|
|
3358
3476
|
})
|
|
3359
3477
|
})
|
|
@@ -3373,7 +3491,8 @@ var PlayerInternals = {
|
|
|
3373
3491
|
useHoverState,
|
|
3374
3492
|
updateAllElementsSizes,
|
|
3375
3493
|
PlayerEmitterProvider,
|
|
3376
|
-
BufferingIndicator
|
|
3494
|
+
BufferingIndicator,
|
|
3495
|
+
useFrameImperative
|
|
3377
3496
|
};
|
|
3378
3497
|
export {
|
|
3379
3498
|
Thumbnail,
|