@remotion/player 4.0.232 → 4.0.233
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 +12 -14
- 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/index.d.ts +4 -3
- package/dist/cjs/index.js +2 -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 +346 -292
- package/package.json +3 -3
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
|
}
|
|
@@ -1115,29 +1139,28 @@ import {
|
|
|
1115
1139
|
useEffect as useEffect13,
|
|
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 React9, {
|
|
1126
1150
|
Suspense,
|
|
1127
1151
|
forwardRef,
|
|
1128
|
-
useCallback as
|
|
1152
|
+
useCallback as useCallback11,
|
|
1129
1153
|
useContext as useContext6,
|
|
1130
1154
|
useEffect as useEffect12,
|
|
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 };
|
|
@@ -2114,13 +2152,15 @@ class ErrorBoundary extends React7.Component {
|
|
|
2114
2152
|
}
|
|
2115
2153
|
|
|
2116
2154
|
// src/player-css-classname.ts
|
|
2117
|
-
var
|
|
2155
|
+
var playerCssClassname = (override) => {
|
|
2156
|
+
return override ?? "__remotion-player";
|
|
2157
|
+
};
|
|
2118
2158
|
|
|
2119
2159
|
// src/utils/is-node.ts
|
|
2120
2160
|
var IS_NODE = typeof document === "undefined";
|
|
2121
2161
|
|
|
2122
2162
|
// src/utils/use-click-prevention-on-double-click.ts
|
|
2123
|
-
import { useCallback as
|
|
2163
|
+
import { useCallback as useCallback10, useMemo as useMemo11 } from "react";
|
|
2124
2164
|
|
|
2125
2165
|
// src/utils/cancellable-promise.ts
|
|
2126
2166
|
var cancellablePromise = (promise) => {
|
|
@@ -2148,17 +2188,17 @@ var cancellablePromise = (promise) => {
|
|
|
2148
2188
|
var delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
|
|
2149
2189
|
|
|
2150
2190
|
// src/utils/use-cancellable-promises.ts
|
|
2151
|
-
import { useCallback as
|
|
2191
|
+
import { useCallback as useCallback9, useMemo as useMemo10, useRef as useRef9 } from "react";
|
|
2152
2192
|
var useCancellablePromises = () => {
|
|
2153
|
-
const pendingPromises =
|
|
2154
|
-
const appendPendingPromise =
|
|
2193
|
+
const pendingPromises = useRef9([]);
|
|
2194
|
+
const appendPendingPromise = useCallback9((promise) => {
|
|
2155
2195
|
pendingPromises.current = [...pendingPromises.current, promise];
|
|
2156
2196
|
}, []);
|
|
2157
|
-
const removePendingPromise =
|
|
2197
|
+
const removePendingPromise = useCallback9((promise) => {
|
|
2158
2198
|
pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
|
|
2159
2199
|
}, []);
|
|
2160
|
-
const clearPendingPromises =
|
|
2161
|
-
const api =
|
|
2200
|
+
const clearPendingPromises = useCallback9(() => pendingPromises.current.map((p) => p.cancel()), []);
|
|
2201
|
+
const api = useMemo10(() => ({
|
|
2162
2202
|
appendPendingPromise,
|
|
2163
2203
|
removePendingPromise,
|
|
2164
2204
|
clearPendingPromises
|
|
@@ -2169,7 +2209,7 @@ var useCancellablePromises = () => {
|
|
|
2169
2209
|
// src/utils/use-click-prevention-on-double-click.ts
|
|
2170
2210
|
var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
|
|
2171
2211
|
const api = useCancellablePromises();
|
|
2172
|
-
const handleClick =
|
|
2212
|
+
const handleClick = useCallback10(async (e) => {
|
|
2173
2213
|
if (e instanceof PointerEvent ? e.pointerType === "touch" : e.nativeEvent.pointerType === "touch") {
|
|
2174
2214
|
onClick(e);
|
|
2175
2215
|
return;
|
|
@@ -2189,18 +2229,18 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
|
|
|
2189
2229
|
}
|
|
2190
2230
|
}
|
|
2191
2231
|
}, [api, onClick]);
|
|
2192
|
-
const handlePointerDown =
|
|
2232
|
+
const handlePointerDown = useCallback10(() => {
|
|
2193
2233
|
document.addEventListener("pointerup", (newEvt) => {
|
|
2194
2234
|
handleClick(newEvt);
|
|
2195
2235
|
}, {
|
|
2196
2236
|
once: true
|
|
2197
2237
|
});
|
|
2198
2238
|
}, [handleClick]);
|
|
2199
|
-
const handleDoubleClick =
|
|
2239
|
+
const handleDoubleClick = useCallback10(() => {
|
|
2200
2240
|
api.clearPendingPromises();
|
|
2201
2241
|
onDoubleClick();
|
|
2202
2242
|
}, [api, onDoubleClick]);
|
|
2203
|
-
const returnValue =
|
|
2243
|
+
const returnValue = useMemo11(() => {
|
|
2204
2244
|
if (!doubleClickToFullscreen) {
|
|
2205
2245
|
return { handlePointerDown: onClick, handleDoubleClick: () => {
|
|
2206
2246
|
return;
|
|
@@ -2212,8 +2252,8 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
|
|
|
2212
2252
|
};
|
|
2213
2253
|
|
|
2214
2254
|
// src/PlayerUI.tsx
|
|
2215
|
-
import { jsx as jsx11, jsxs as
|
|
2216
|
-
var reactVersion =
|
|
2255
|
+
import { jsx as jsx11, jsxs as jsxs9, Fragment as Fragment3 } from "react/jsx-runtime";
|
|
2256
|
+
var reactVersion = React9.version.split(".")[0];
|
|
2217
2257
|
if (reactVersion === "0") {
|
|
2218
2258
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
2219
2259
|
}
|
|
@@ -2252,11 +2292,12 @@ var PlayerUI = ({
|
|
|
2252
2292
|
bufferStateDelayInMilliseconds,
|
|
2253
2293
|
hideControlsWhenPointerDoesntMove,
|
|
2254
2294
|
overflowVisible,
|
|
2255
|
-
browserMediaControlsBehavior
|
|
2295
|
+
browserMediaControlsBehavior,
|
|
2296
|
+
overrideInternalClassName
|
|
2256
2297
|
}, ref) => {
|
|
2257
|
-
const config =
|
|
2258
|
-
const video =
|
|
2259
|
-
const container =
|
|
2298
|
+
const config = Internals11.useUnsafeVideoConfig();
|
|
2299
|
+
const video = Internals11.useVideo();
|
|
2300
|
+
const container = useRef10(null);
|
|
2260
2301
|
const canvasSize = useElementSize(container, {
|
|
2261
2302
|
triggerOnWindowResize: false,
|
|
2262
2303
|
shouldApplyCssTransforms: false
|
|
@@ -2265,20 +2306,21 @@ var PlayerUI = ({
|
|
|
2265
2306
|
const [shouldAutoplay, setShouldAutoPlay] = useState11(autoPlay);
|
|
2266
2307
|
const [isFullscreen, setIsFullscreen] = useState11(() => false);
|
|
2267
2308
|
const [seeking, setSeeking] = useState11(false);
|
|
2268
|
-
const supportsFullScreen =
|
|
2309
|
+
const supportsFullScreen = useMemo12(() => {
|
|
2269
2310
|
if (typeof document === "undefined") {
|
|
2270
2311
|
return false;
|
|
2271
2312
|
}
|
|
2272
2313
|
return Boolean(document.fullscreenEnabled || document.webkitFullscreenEnabled);
|
|
2273
2314
|
}, []);
|
|
2274
2315
|
const player = usePlayer();
|
|
2316
|
+
const playerToggle = player.toggle;
|
|
2275
2317
|
usePlayback({
|
|
2276
2318
|
loop,
|
|
2277
2319
|
playbackRate,
|
|
2278
2320
|
moveToBeginningWhenEnded,
|
|
2279
2321
|
inFrame,
|
|
2280
2322
|
outFrame,
|
|
2281
|
-
|
|
2323
|
+
getCurrentFrame: player.getCurrentFrame,
|
|
2282
2324
|
browserMediaControlsBehavior
|
|
2283
2325
|
});
|
|
2284
2326
|
useEffect12(() => {
|
|
@@ -2303,14 +2345,10 @@ var PlayerUI = ({
|
|
|
2303
2345
|
document.removeEventListener("webkitfullscreenchange", onFullscreenChange);
|
|
2304
2346
|
};
|
|
2305
2347
|
}, []);
|
|
2306
|
-
const toggle =
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
player.play(e);
|
|
2311
|
-
}
|
|
2312
|
-
}, [player]);
|
|
2313
|
-
const requestFullscreen = useCallback10(() => {
|
|
2348
|
+
const toggle = useCallback11((e) => {
|
|
2349
|
+
playerToggle(e);
|
|
2350
|
+
}, [playerToggle]);
|
|
2351
|
+
const requestFullscreen = useCallback11(() => {
|
|
2314
2352
|
if (!allowFullscreen) {
|
|
2315
2353
|
throw new Error("allowFullscreen is false");
|
|
2316
2354
|
}
|
|
@@ -2326,7 +2364,7 @@ var PlayerUI = ({
|
|
|
2326
2364
|
container.current.requestFullscreen();
|
|
2327
2365
|
}
|
|
2328
2366
|
}, [allowFullscreen, supportsFullScreen]);
|
|
2329
|
-
const exitFullscreen =
|
|
2367
|
+
const exitFullscreen = useCallback11(() => {
|
|
2330
2368
|
if (document.webkitExitFullscreen) {
|
|
2331
2369
|
document.webkitExitFullscreen();
|
|
2332
2370
|
} else {
|
|
@@ -2358,7 +2396,7 @@ var PlayerUI = ({
|
|
|
2358
2396
|
};
|
|
2359
2397
|
}, [player.emitter]);
|
|
2360
2398
|
const durationInFrames = config?.durationInFrames ?? 1;
|
|
2361
|
-
const layout =
|
|
2399
|
+
const layout = useMemo12(() => {
|
|
2362
2400
|
if (!config || !canvasSize) {
|
|
2363
2401
|
return null;
|
|
2364
2402
|
}
|
|
@@ -2370,7 +2408,7 @@ var PlayerUI = ({
|
|
|
2370
2408
|
});
|
|
2371
2409
|
}, [canvasSize, config]);
|
|
2372
2410
|
const scale = layout?.scale ?? 1;
|
|
2373
|
-
const initialScaleIgnored =
|
|
2411
|
+
const initialScaleIgnored = useRef10(false);
|
|
2374
2412
|
useEffect12(() => {
|
|
2375
2413
|
if (!initialScaleIgnored.current) {
|
|
2376
2414
|
initialScaleIgnored.current = true;
|
|
@@ -2378,8 +2416,8 @@ var PlayerUI = ({
|
|
|
2378
2416
|
}
|
|
2379
2417
|
player.emitter.dispatchScaleChange(scale);
|
|
2380
2418
|
}, [player.emitter, scale]);
|
|
2381
|
-
const { setMediaVolume, setMediaMuted } = useContext6(
|
|
2382
|
-
const { mediaMuted, mediaVolume } = useContext6(
|
|
2419
|
+
const { setMediaVolume, setMediaMuted } = useContext6(Internals11.SetMediaVolumeContext);
|
|
2420
|
+
const { mediaMuted, mediaVolume } = useContext6(Internals11.MediaVolumeContext);
|
|
2383
2421
|
useEffect12(() => {
|
|
2384
2422
|
player.emitter.dispatchVolumeChange(mediaVolume);
|
|
2385
2423
|
}, [player.emitter, mediaVolume]);
|
|
@@ -2507,7 +2545,7 @@ var PlayerUI = ({
|
|
|
2507
2545
|
scale
|
|
2508
2546
|
]);
|
|
2509
2547
|
const VideoComponent = video ? video.component : null;
|
|
2510
|
-
const outerStyle =
|
|
2548
|
+
const outerStyle = useMemo12(() => {
|
|
2511
2549
|
return calculateOuterStyle({
|
|
2512
2550
|
canvasSize,
|
|
2513
2551
|
config,
|
|
@@ -2516,10 +2554,10 @@ var PlayerUI = ({
|
|
|
2516
2554
|
layout
|
|
2517
2555
|
});
|
|
2518
2556
|
}, [canvasSize, config, layout, overflowVisible, style]);
|
|
2519
|
-
const outer =
|
|
2557
|
+
const outer = useMemo12(() => {
|
|
2520
2558
|
return calculateOuter({ config, layout, scale, overflowVisible });
|
|
2521
2559
|
}, [config, layout, overflowVisible, scale]);
|
|
2522
|
-
const containerStyle3 =
|
|
2560
|
+
const containerStyle3 = useMemo12(() => {
|
|
2523
2561
|
return calculateContainerStyle({
|
|
2524
2562
|
canvasSize,
|
|
2525
2563
|
config,
|
|
@@ -2528,32 +2566,34 @@ var PlayerUI = ({
|
|
|
2528
2566
|
overflowVisible
|
|
2529
2567
|
});
|
|
2530
2568
|
}, [canvasSize, config, layout, overflowVisible, scale]);
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2569
|
+
const playerPause = player.pause;
|
|
2570
|
+
const playerDispatchError = player.emitter.dispatchError;
|
|
2571
|
+
const onError = useCallback11((error) => {
|
|
2572
|
+
playerPause();
|
|
2573
|
+
playerDispatchError(error);
|
|
2574
|
+
}, [playerDispatchError, playerPause]);
|
|
2575
|
+
const onFullscreenButtonClick = useCallback11((e) => {
|
|
2536
2576
|
e.stopPropagation();
|
|
2537
2577
|
requestFullscreen();
|
|
2538
2578
|
}, [requestFullscreen]);
|
|
2539
|
-
const onExitFullscreenButtonClick =
|
|
2579
|
+
const onExitFullscreenButtonClick = useCallback11((e) => {
|
|
2540
2580
|
e.stopPropagation();
|
|
2541
2581
|
exitFullscreen();
|
|
2542
2582
|
}, [exitFullscreen]);
|
|
2543
|
-
const onSingleClick =
|
|
2583
|
+
const onSingleClick = useCallback11((e) => {
|
|
2544
2584
|
const rightClick = e instanceof MouseEvent ? e.button === 2 : e.nativeEvent.button;
|
|
2545
2585
|
if (rightClick) {
|
|
2546
2586
|
return;
|
|
2547
2587
|
}
|
|
2548
2588
|
toggle(e);
|
|
2549
2589
|
}, [toggle]);
|
|
2550
|
-
const onSeekStart =
|
|
2590
|
+
const onSeekStart = useCallback11(() => {
|
|
2551
2591
|
setSeeking(true);
|
|
2552
2592
|
}, []);
|
|
2553
|
-
const onSeekEnd =
|
|
2593
|
+
const onSeekEnd = useCallback11(() => {
|
|
2554
2594
|
setSeeking(false);
|
|
2555
2595
|
}, []);
|
|
2556
|
-
const onDoubleClick =
|
|
2596
|
+
const onDoubleClick = useCallback11(() => {
|
|
2557
2597
|
if (isFullscreen) {
|
|
2558
2598
|
exitFullscreen();
|
|
2559
2599
|
} else {
|
|
@@ -2567,14 +2607,14 @@ var PlayerUI = ({
|
|
|
2567
2607
|
setShouldAutoPlay(false);
|
|
2568
2608
|
}
|
|
2569
2609
|
}, [shouldAutoplay, player]);
|
|
2570
|
-
const loadingMarkup =
|
|
2610
|
+
const loadingMarkup = useMemo12(() => {
|
|
2571
2611
|
return renderLoading ? renderLoading({
|
|
2572
2612
|
height: outerStyle.height,
|
|
2573
2613
|
width: outerStyle.width,
|
|
2574
2614
|
isBuffering: showBufferIndicator
|
|
2575
2615
|
}) : null;
|
|
2576
2616
|
}, [outerStyle.height, outerStyle.width, renderLoading, showBufferIndicator]);
|
|
2577
|
-
const currentScale =
|
|
2617
|
+
const currentScale = useMemo12(() => {
|
|
2578
2618
|
return {
|
|
2579
2619
|
type: "scale",
|
|
2580
2620
|
scale
|
|
@@ -2598,20 +2638,20 @@ var PlayerUI = ({
|
|
|
2598
2638
|
showPosterWhenBuffering && showBufferIndicator && player.isPlaying()
|
|
2599
2639
|
].some(Boolean);
|
|
2600
2640
|
const { left, top, width, height, ...outerWithoutScale } = outer;
|
|
2601
|
-
const content = /* @__PURE__ */
|
|
2641
|
+
const content = /* @__PURE__ */ jsxs9(Fragment3, {
|
|
2602
2642
|
children: [
|
|
2603
2643
|
/* @__PURE__ */ jsx11("div", {
|
|
2604
2644
|
style: outer,
|
|
2605
2645
|
onPointerDown: clickToPlay ? handlePointerDown : undefined,
|
|
2606
2646
|
onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
|
|
2607
|
-
children: /* @__PURE__ */
|
|
2647
|
+
children: /* @__PURE__ */ jsxs9("div", {
|
|
2608
2648
|
style: containerStyle3,
|
|
2609
|
-
className:
|
|
2649
|
+
className: playerCssClassname(overrideInternalClassName),
|
|
2610
2650
|
children: [
|
|
2611
2651
|
VideoComponent ? /* @__PURE__ */ jsx11(ErrorBoundary, {
|
|
2612
2652
|
onError,
|
|
2613
2653
|
errorFallback,
|
|
2614
|
-
children: /* @__PURE__ */ jsx11(
|
|
2654
|
+
children: /* @__PURE__ */ jsx11(Internals11.CurrentScaleContext.Provider, {
|
|
2615
2655
|
value: currentScale,
|
|
2616
2656
|
children: /* @__PURE__ */ jsx11(VideoComponent, {
|
|
2617
2657
|
...video?.props ?? {},
|
|
@@ -2640,8 +2680,9 @@ var PlayerUI = ({
|
|
|
2640
2680
|
}) : null,
|
|
2641
2681
|
controls ? /* @__PURE__ */ jsx11(Controls, {
|
|
2642
2682
|
fps: config.fps,
|
|
2683
|
+
playing: player.playing,
|
|
2684
|
+
toggle: player.toggle,
|
|
2643
2685
|
durationInFrames: config.durationInFrames,
|
|
2644
|
-
player,
|
|
2645
2686
|
containerRef: container,
|
|
2646
2687
|
onFullscreenButtonClick,
|
|
2647
2688
|
isFullscreen,
|
|
@@ -2689,8 +2730,8 @@ var PlayerUI = ({
|
|
|
2689
2730
|
var PlayerUI_default = forwardRef(PlayerUI);
|
|
2690
2731
|
|
|
2691
2732
|
// src/SharedPlayerContext.tsx
|
|
2692
|
-
import { useCallback as
|
|
2693
|
-
import { Internals as
|
|
2733
|
+
import { useCallback as useCallback12, useMemo as useMemo13, useState as useState12 } from "react";
|
|
2734
|
+
import { Internals as Internals12 } from "remotion";
|
|
2694
2735
|
|
|
2695
2736
|
// src/volume-persistance.ts
|
|
2696
2737
|
var VOLUME_PERSISTANCE_KEY = "remotion.volumePreference";
|
|
@@ -2730,7 +2771,7 @@ var SharedPlayerContexts = ({
|
|
|
2730
2771
|
numberOfSharedAudioTags,
|
|
2731
2772
|
initiallyMuted
|
|
2732
2773
|
}) => {
|
|
2733
|
-
const compositionManagerContext =
|
|
2774
|
+
const compositionManagerContext = useMemo13(() => {
|
|
2734
2775
|
const context = {
|
|
2735
2776
|
compositions: [
|
|
2736
2777
|
{
|
|
@@ -2776,38 +2817,38 @@ var SharedPlayerContexts = ({
|
|
|
2776
2817
|
}, [component, durationInFrames, compositionHeight, compositionWidth, fps]);
|
|
2777
2818
|
const [mediaMuted, setMediaMuted] = useState12(() => initiallyMuted);
|
|
2778
2819
|
const [mediaVolume, setMediaVolume] = useState12(() => getPreferredVolume());
|
|
2779
|
-
const mediaVolumeContextValue =
|
|
2820
|
+
const mediaVolumeContextValue = useMemo13(() => {
|
|
2780
2821
|
return {
|
|
2781
2822
|
mediaMuted,
|
|
2782
2823
|
mediaVolume
|
|
2783
2824
|
};
|
|
2784
2825
|
}, [mediaMuted, mediaVolume]);
|
|
2785
|
-
const setMediaVolumeAndPersist =
|
|
2826
|
+
const setMediaVolumeAndPersist = useCallback12((vol) => {
|
|
2786
2827
|
setMediaVolume(vol);
|
|
2787
2828
|
persistVolume(vol);
|
|
2788
2829
|
}, []);
|
|
2789
|
-
const setMediaVolumeContextValue =
|
|
2830
|
+
const setMediaVolumeContextValue = useMemo13(() => {
|
|
2790
2831
|
return {
|
|
2791
2832
|
setMediaMuted,
|
|
2792
2833
|
setMediaVolume: setMediaVolumeAndPersist
|
|
2793
2834
|
};
|
|
2794
2835
|
}, [setMediaVolumeAndPersist]);
|
|
2795
|
-
return /* @__PURE__ */ jsx12(
|
|
2796
|
-
children: /* @__PURE__ */ jsx12(
|
|
2836
|
+
return /* @__PURE__ */ jsx12(Internals12.CanUseRemotionHooksProvider, {
|
|
2837
|
+
children: /* @__PURE__ */ jsx12(Internals12.Timeline.TimelineContext.Provider, {
|
|
2797
2838
|
value: timelineContext,
|
|
2798
|
-
children: /* @__PURE__ */ jsx12(
|
|
2839
|
+
children: /* @__PURE__ */ jsx12(Internals12.CompositionManager.Provider, {
|
|
2799
2840
|
value: compositionManagerContext,
|
|
2800
|
-
children: /* @__PURE__ */ jsx12(
|
|
2801
|
-
children: /* @__PURE__ */ jsx12(
|
|
2802
|
-
children: /* @__PURE__ */ jsx12(
|
|
2803
|
-
children: /* @__PURE__ */ jsx12(
|
|
2841
|
+
children: /* @__PURE__ */ jsx12(Internals12.ResolveCompositionConfig, {
|
|
2842
|
+
children: /* @__PURE__ */ jsx12(Internals12.PrefetchProvider, {
|
|
2843
|
+
children: /* @__PURE__ */ jsx12(Internals12.DurationsContextProvider, {
|
|
2844
|
+
children: /* @__PURE__ */ jsx12(Internals12.MediaVolumeContext.Provider, {
|
|
2804
2845
|
value: mediaVolumeContextValue,
|
|
2805
|
-
children: /* @__PURE__ */ jsx12(
|
|
2846
|
+
children: /* @__PURE__ */ jsx12(Internals12.SetMediaVolumeContext.Provider, {
|
|
2806
2847
|
value: setMediaVolumeContextValue,
|
|
2807
|
-
children: /* @__PURE__ */ jsx12(
|
|
2848
|
+
children: /* @__PURE__ */ jsx12(Internals12.SharedAudioContextProvider, {
|
|
2808
2849
|
numberOfAudioTags: numberOfSharedAudioTags,
|
|
2809
2850
|
component,
|
|
2810
|
-
children: /* @__PURE__ */ jsx12(
|
|
2851
|
+
children: /* @__PURE__ */ jsx12(Internals12.BufferingProvider, {
|
|
2811
2852
|
children
|
|
2812
2853
|
})
|
|
2813
2854
|
})
|
|
@@ -2943,7 +2984,7 @@ var PlayerFn = ({
|
|
|
2943
2984
|
spaceKeyToPlayOrPause = true,
|
|
2944
2985
|
moveToBeginningWhenEnded = true,
|
|
2945
2986
|
numberOfSharedAudioTags = 5,
|
|
2946
|
-
errorFallback = () => "
|
|
2987
|
+
errorFallback = () => "⚠️",
|
|
2947
2988
|
playbackRate = 1,
|
|
2948
2989
|
renderLoading,
|
|
2949
2990
|
className: className2,
|
|
@@ -2968,6 +3009,7 @@ var PlayerFn = ({
|
|
|
2968
3009
|
overflowVisible = false,
|
|
2969
3010
|
renderMuteButton,
|
|
2970
3011
|
browserMediaControlsBehavior: passedBrowserMediaControlsBehavior,
|
|
3012
|
+
overrideInternalClassName,
|
|
2971
3013
|
...componentProps
|
|
2972
3014
|
}, ref) => {
|
|
2973
3015
|
if (typeof window !== "undefined") {
|
|
@@ -2985,16 +3027,16 @@ var PlayerFn = ({
|
|
|
2985
3027
|
if (componentForValidation === Composition) {
|
|
2986
3028
|
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
3029
|
}
|
|
2988
|
-
const component =
|
|
3030
|
+
const component = Internals13.useLazyComponent(componentProps);
|
|
2989
3031
|
validateInitialFrame({ initialFrame, durationInFrames });
|
|
2990
3032
|
const [frame, setFrame] = useState13(() => ({
|
|
2991
3033
|
[PLAYER_COMP_ID]: initialFrame ?? 0
|
|
2992
3034
|
}));
|
|
2993
3035
|
const [playing, setPlaying] = useState13(false);
|
|
2994
3036
|
const [rootId] = useState13("player-comp");
|
|
2995
|
-
const rootRef =
|
|
2996
|
-
const audioAndVideoTags =
|
|
2997
|
-
const imperativePlaying =
|
|
3037
|
+
const rootRef = useRef11(null);
|
|
3038
|
+
const audioAndVideoTags = useRef11([]);
|
|
3039
|
+
const imperativePlaying = useRef11(false);
|
|
2998
3040
|
const [currentPlaybackRate, setCurrentPlaybackRate] = useState13(playbackRate);
|
|
2999
3041
|
if (typeof compositionHeight !== "number") {
|
|
3000
3042
|
throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
|
|
@@ -3047,7 +3089,7 @@ var PlayerFn = ({
|
|
|
3047
3089
|
setCurrentPlaybackRate(playbackRate);
|
|
3048
3090
|
}, [playbackRate]);
|
|
3049
3091
|
useImperativeHandle2(ref, () => rootRef.current, []);
|
|
3050
|
-
const timelineContextValue =
|
|
3092
|
+
const timelineContextValue = useMemo14(() => {
|
|
3051
3093
|
return {
|
|
3052
3094
|
frame,
|
|
3053
3095
|
playing,
|
|
@@ -3060,7 +3102,7 @@ var PlayerFn = ({
|
|
|
3060
3102
|
audioAndVideoTags
|
|
3061
3103
|
};
|
|
3062
3104
|
}, [frame, currentPlaybackRate, playing, rootId]);
|
|
3063
|
-
const setTimelineContextValue =
|
|
3105
|
+
const setTimelineContextValue = useMemo14(() => {
|
|
3064
3106
|
return {
|
|
3065
3107
|
setFrame,
|
|
3066
3108
|
setPlaying
|
|
@@ -3068,16 +3110,16 @@ var PlayerFn = ({
|
|
|
3068
3110
|
}, [setFrame]);
|
|
3069
3111
|
if (typeof window !== "undefined") {
|
|
3070
3112
|
useLayoutEffect(() => {
|
|
3071
|
-
|
|
3072
|
-
}, []);
|
|
3113
|
+
Internals13.CSSUtils.injectCSS(Internals13.CSSUtils.makeDefaultPreviewCSS(`.${playerCssClassname(overrideInternalClassName)}`, "#fff"));
|
|
3114
|
+
}, [overrideInternalClassName]);
|
|
3073
3115
|
}
|
|
3074
|
-
const actualInputProps =
|
|
3075
|
-
const browserMediaControlsBehavior =
|
|
3116
|
+
const actualInputProps = useMemo14(() => inputProps ?? {}, [inputProps]);
|
|
3117
|
+
const browserMediaControlsBehavior = useMemo14(() => {
|
|
3076
3118
|
return passedBrowserMediaControlsBehavior ?? {
|
|
3077
3119
|
mode: "prevent-media-session"
|
|
3078
3120
|
};
|
|
3079
3121
|
}, [passedBrowserMediaControlsBehavior]);
|
|
3080
|
-
return /* @__PURE__ */ jsx13(
|
|
3122
|
+
return /* @__PURE__ */ jsx13(Internals13.IsPlayerContextProvider, {
|
|
3081
3123
|
children: /* @__PURE__ */ jsx13(SharedPlayerContexts, {
|
|
3082
3124
|
timelineContext: timelineContextValue,
|
|
3083
3125
|
component,
|
|
@@ -3087,7 +3129,7 @@ var PlayerFn = ({
|
|
|
3087
3129
|
fps,
|
|
3088
3130
|
numberOfSharedAudioTags,
|
|
3089
3131
|
initiallyMuted,
|
|
3090
|
-
children: /* @__PURE__ */ jsx13(
|
|
3132
|
+
children: /* @__PURE__ */ jsx13(Internals13.Timeline.SetTimelineContext.Provider, {
|
|
3091
3133
|
value: setTimelineContextValue,
|
|
3092
3134
|
children: /* @__PURE__ */ jsx13(PlayerEmitterProvider, {
|
|
3093
3135
|
currentPlaybackRate,
|
|
@@ -3126,7 +3168,8 @@ var PlayerFn = ({
|
|
|
3126
3168
|
bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds ?? 300,
|
|
3127
3169
|
hideControlsWhenPointerDoesntMove,
|
|
3128
3170
|
overflowVisible,
|
|
3129
|
-
browserMediaControlsBehavior
|
|
3171
|
+
browserMediaControlsBehavior,
|
|
3172
|
+
overrideInternalClassName: overrideInternalClassName ?? undefined
|
|
3130
3173
|
})
|
|
3131
3174
|
})
|
|
3132
3175
|
})
|
|
@@ -3140,31 +3183,31 @@ import {
|
|
|
3140
3183
|
forwardRef as forwardRef4,
|
|
3141
3184
|
useImperativeHandle as useImperativeHandle4,
|
|
3142
3185
|
useLayoutEffect as useLayoutEffect2,
|
|
3143
|
-
useMemo as
|
|
3144
|
-
useRef as
|
|
3186
|
+
useMemo as useMemo17,
|
|
3187
|
+
useRef as useRef13,
|
|
3145
3188
|
useState as useState14
|
|
3146
3189
|
} from "react";
|
|
3147
|
-
import { Internals as
|
|
3190
|
+
import { Internals as Internals15, random as random2 } from "remotion";
|
|
3148
3191
|
|
|
3149
3192
|
// src/ThumbnailUI.tsx
|
|
3150
|
-
import
|
|
3193
|
+
import React12, {
|
|
3151
3194
|
forwardRef as forwardRef3,
|
|
3152
3195
|
Suspense as Suspense2,
|
|
3153
|
-
useCallback as
|
|
3196
|
+
useCallback as useCallback13,
|
|
3154
3197
|
useImperativeHandle as useImperativeHandle3,
|
|
3155
|
-
useMemo as
|
|
3156
|
-
useRef as
|
|
3198
|
+
useMemo as useMemo16,
|
|
3199
|
+
useRef as useRef12
|
|
3157
3200
|
} from "react";
|
|
3158
|
-
import { Internals as
|
|
3201
|
+
import { Internals as Internals14 } from "remotion";
|
|
3159
3202
|
|
|
3160
3203
|
// src/use-thumbnail.ts
|
|
3161
|
-
import { useContext as useContext7, useMemo as
|
|
3204
|
+
import { useContext as useContext7, useMemo as useMemo15 } from "react";
|
|
3162
3205
|
var useThumbnail = () => {
|
|
3163
3206
|
const emitter = useContext7(ThumbnailEmitterContext);
|
|
3164
3207
|
if (!emitter) {
|
|
3165
3208
|
throw new TypeError("Expected Player event emitter context");
|
|
3166
3209
|
}
|
|
3167
|
-
const returnValue =
|
|
3210
|
+
const returnValue = useMemo15(() => {
|
|
3168
3211
|
return {
|
|
3169
3212
|
emitter
|
|
3170
3213
|
};
|
|
@@ -3174,20 +3217,28 @@ var useThumbnail = () => {
|
|
|
3174
3217
|
|
|
3175
3218
|
// src/ThumbnailUI.tsx
|
|
3176
3219
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
3177
|
-
var reactVersion2 =
|
|
3220
|
+
var reactVersion2 = React12.version.split(".")[0];
|
|
3178
3221
|
if (reactVersion2 === "0") {
|
|
3179
3222
|
throw new Error(`Version ${reactVersion2} of "react" is not supported by Remotion`);
|
|
3180
3223
|
}
|
|
3181
3224
|
var doesReactVersionSupportSuspense2 = parseInt(reactVersion2, 10) >= 18;
|
|
3182
|
-
var ThumbnailUI = ({
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3225
|
+
var ThumbnailUI = ({
|
|
3226
|
+
style,
|
|
3227
|
+
inputProps,
|
|
3228
|
+
errorFallback,
|
|
3229
|
+
renderLoading,
|
|
3230
|
+
className: className2,
|
|
3231
|
+
overflowVisible,
|
|
3232
|
+
overrideInternalClassName
|
|
3233
|
+
}, ref) => {
|
|
3234
|
+
const config = Internals14.useUnsafeVideoConfig();
|
|
3235
|
+
const video = Internals14.useVideo();
|
|
3236
|
+
const container = useRef12(null);
|
|
3186
3237
|
const canvasSize = useElementSize(container, {
|
|
3187
3238
|
triggerOnWindowResize: false,
|
|
3188
3239
|
shouldApplyCssTransforms: false
|
|
3189
3240
|
});
|
|
3190
|
-
const layout =
|
|
3241
|
+
const layout = useMemo16(() => {
|
|
3191
3242
|
if (!config || !canvasSize) {
|
|
3192
3243
|
return null;
|
|
3193
3244
|
}
|
|
@@ -3209,7 +3260,7 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3209
3260
|
return Object.assign(thumbnail.emitter, methods);
|
|
3210
3261
|
}, [scale, thumbnail.emitter]);
|
|
3211
3262
|
const VideoComponent = video ? video.component : null;
|
|
3212
|
-
const outerStyle =
|
|
3263
|
+
const outerStyle = useMemo16(() => {
|
|
3213
3264
|
return calculateOuterStyle({
|
|
3214
3265
|
config,
|
|
3215
3266
|
style,
|
|
@@ -3218,10 +3269,10 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3218
3269
|
layout
|
|
3219
3270
|
});
|
|
3220
3271
|
}, [canvasSize, config, layout, overflowVisible, style]);
|
|
3221
|
-
const outer =
|
|
3272
|
+
const outer = useMemo16(() => {
|
|
3222
3273
|
return calculateOuter({ config, layout, scale, overflowVisible });
|
|
3223
3274
|
}, [config, layout, overflowVisible, scale]);
|
|
3224
|
-
const containerStyle3 =
|
|
3275
|
+
const containerStyle3 = useMemo16(() => {
|
|
3225
3276
|
return calculateContainerStyle({
|
|
3226
3277
|
canvasSize,
|
|
3227
3278
|
config,
|
|
@@ -3230,17 +3281,17 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3230
3281
|
overflowVisible
|
|
3231
3282
|
});
|
|
3232
3283
|
}, [canvasSize, config, layout, overflowVisible, scale]);
|
|
3233
|
-
const onError =
|
|
3284
|
+
const onError = useCallback13((error) => {
|
|
3234
3285
|
thumbnail.emitter.dispatchError(error);
|
|
3235
3286
|
}, [thumbnail.emitter]);
|
|
3236
|
-
const loadingMarkup =
|
|
3287
|
+
const loadingMarkup = useMemo16(() => {
|
|
3237
3288
|
return renderLoading ? renderLoading({
|
|
3238
3289
|
height: outerStyle.height,
|
|
3239
3290
|
width: outerStyle.width,
|
|
3240
3291
|
isBuffering: false
|
|
3241
3292
|
}) : null;
|
|
3242
3293
|
}, [outerStyle.height, outerStyle.width, renderLoading]);
|
|
3243
|
-
const currentScaleContext =
|
|
3294
|
+
const currentScaleContext = useMemo16(() => {
|
|
3244
3295
|
return {
|
|
3245
3296
|
type: "scale",
|
|
3246
3297
|
scale
|
|
@@ -3253,11 +3304,11 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3253
3304
|
style: outer,
|
|
3254
3305
|
children: /* @__PURE__ */ jsx14("div", {
|
|
3255
3306
|
style: containerStyle3,
|
|
3256
|
-
className:
|
|
3307
|
+
className: playerCssClassname(overrideInternalClassName),
|
|
3257
3308
|
children: VideoComponent ? /* @__PURE__ */ jsx14(ErrorBoundary, {
|
|
3258
3309
|
onError,
|
|
3259
3310
|
errorFallback,
|
|
3260
|
-
children: /* @__PURE__ */ jsx14(
|
|
3311
|
+
children: /* @__PURE__ */ jsx14(Internals14.CurrentScaleContext.Provider, {
|
|
3261
3312
|
value: currentScaleContext,
|
|
3262
3313
|
children: /* @__PURE__ */ jsx14(VideoComponent, {
|
|
3263
3314
|
...video?.props ?? {},
|
|
@@ -3298,9 +3349,10 @@ var ThumbnailFn = ({
|
|
|
3298
3349
|
durationInFrames,
|
|
3299
3350
|
fps,
|
|
3300
3351
|
className: className2,
|
|
3301
|
-
errorFallback = () => "
|
|
3352
|
+
errorFallback = () => "⚠️",
|
|
3302
3353
|
renderLoading,
|
|
3303
3354
|
overflowVisible = false,
|
|
3355
|
+
overrideInternalClassName,
|
|
3304
3356
|
...componentProps
|
|
3305
3357
|
}, ref) => {
|
|
3306
3358
|
if (typeof window !== "undefined") {
|
|
@@ -3309,8 +3361,8 @@ var ThumbnailFn = ({
|
|
|
3309
3361
|
}, []);
|
|
3310
3362
|
}
|
|
3311
3363
|
const [thumbnailId] = useState14(() => String(random2(null)));
|
|
3312
|
-
const rootRef =
|
|
3313
|
-
const timelineState =
|
|
3364
|
+
const rootRef = useRef13(null);
|
|
3365
|
+
const timelineState = useMemo17(() => {
|
|
3314
3366
|
const value = {
|
|
3315
3367
|
playing: false,
|
|
3316
3368
|
frame: {
|
|
@@ -3329,12 +3381,12 @@ var ThumbnailFn = ({
|
|
|
3329
3381
|
return value;
|
|
3330
3382
|
}, [frameToDisplay, thumbnailId]);
|
|
3331
3383
|
useImperativeHandle4(ref, () => rootRef.current, []);
|
|
3332
|
-
const Component =
|
|
3384
|
+
const Component = Internals15.useLazyComponent(componentProps);
|
|
3333
3385
|
const [emitter] = useState14(() => new ThumbnailEmitter);
|
|
3334
|
-
const passedInputProps =
|
|
3386
|
+
const passedInputProps = useMemo17(() => {
|
|
3335
3387
|
return inputProps ?? {};
|
|
3336
3388
|
}, [inputProps]);
|
|
3337
|
-
return /* @__PURE__ */ jsx15(
|
|
3389
|
+
return /* @__PURE__ */ jsx15(Internals15.IsPlayerContextProvider, {
|
|
3338
3390
|
children: /* @__PURE__ */ jsx15(SharedPlayerContexts, {
|
|
3339
3391
|
timelineContext: timelineState,
|
|
3340
3392
|
component: Component,
|
|
@@ -3353,7 +3405,8 @@ var ThumbnailFn = ({
|
|
|
3353
3405
|
inputProps: passedInputProps,
|
|
3354
3406
|
renderLoading,
|
|
3355
3407
|
style,
|
|
3356
|
-
overflowVisible
|
|
3408
|
+
overflowVisible,
|
|
3409
|
+
overrideInternalClassName
|
|
3357
3410
|
})
|
|
3358
3411
|
})
|
|
3359
3412
|
})
|
|
@@ -3373,7 +3426,8 @@ var PlayerInternals = {
|
|
|
3373
3426
|
useHoverState,
|
|
3374
3427
|
updateAllElementsSizes,
|
|
3375
3428
|
PlayerEmitterProvider,
|
|
3376
|
-
BufferingIndicator
|
|
3429
|
+
BufferingIndicator,
|
|
3430
|
+
useFrameImperative
|
|
3377
3431
|
};
|
|
3378
3432
|
export {
|
|
3379
3433
|
Thumbnail,
|