@remotion/player 4.0.186 → 4.0.188
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/MediaVolumeSlider.d.ts +8 -1
- package/dist/cjs/MediaVolumeSlider.js +35 -102
- package/dist/cjs/Player.d.ts +4 -0
- package/dist/cjs/Player.js +2 -2
- package/dist/cjs/PlayerControls.d.ts +4 -0
- package/dist/cjs/PlayerControls.js +2 -2
- package/dist/cjs/PlayerUI.d.ts +4 -0
- package/dist/cjs/PlayerUI.js +2 -2
- package/dist/cjs/_check-rsc.d.ts +1 -0
- package/dist/cjs/_check-rsc.js +17 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/render-volume-slider.d.ts +11 -0
- package/dist/cjs/render-volume-slider.js +112 -0
- package/dist/esm/index.mjs +353 -290
- package/package.json +2 -2
- package/happydom.ts +0 -6
package/dist/esm/index.mjs
CHANGED
|
@@ -1007,28 +1007,28 @@ forwardRef as forwardRef2,
|
|
|
1007
1007
|
useEffect as useEffect12,
|
|
1008
1008
|
useImperativeHandle as useImperativeHandle2,
|
|
1009
1009
|
useLayoutEffect,
|
|
1010
|
-
useMemo as
|
|
1010
|
+
useMemo as useMemo13,
|
|
1011
1011
|
useRef as useRef10,
|
|
1012
|
-
useState as
|
|
1012
|
+
useState as useState13
|
|
1013
1013
|
} from "react";
|
|
1014
1014
|
import {Composition, Internals as Internals12} from "remotion";
|
|
1015
1015
|
|
|
1016
1016
|
// src/PlayerUI.tsx
|
|
1017
|
-
import
|
|
1017
|
+
import React8, {
|
|
1018
1018
|
Suspense,
|
|
1019
1019
|
forwardRef,
|
|
1020
|
-
useCallback as
|
|
1020
|
+
useCallback as useCallback10,
|
|
1021
1021
|
useContext as useContext6,
|
|
1022
1022
|
useEffect as useEffect11,
|
|
1023
1023
|
useImperativeHandle,
|
|
1024
|
-
useMemo as
|
|
1024
|
+
useMemo as useMemo11,
|
|
1025
1025
|
useRef as useRef9,
|
|
1026
|
-
useState as
|
|
1026
|
+
useState as useState11
|
|
1027
1027
|
} from "react";
|
|
1028
1028
|
import {Internals as Internals10} from "remotion";
|
|
1029
1029
|
|
|
1030
1030
|
// src/PlayerControls.tsx
|
|
1031
|
-
import {useCallback as
|
|
1031
|
+
import {useCallback as useCallback7, useEffect as useEffect10, useMemo as useMemo8, useRef as useRef7, useState as useState10} from "react";
|
|
1032
1032
|
import {Internals as Internals9} from "remotion";
|
|
1033
1033
|
|
|
1034
1034
|
// src/DefaultPlayPauseButton.tsx
|
|
@@ -1048,75 +1048,35 @@ var DefaultPlayPauseButton = ({ playing, buffering }) => {
|
|
|
1048
1048
|
};
|
|
1049
1049
|
|
|
1050
1050
|
// src/MediaVolumeSlider.tsx
|
|
1051
|
-
import
|
|
1052
|
-
import {Internals as Internals6
|
|
1051
|
+
import {useCallback as useCallback4, useMemo as useMemo4, useRef as useRef4, useState as useState6} from "react";
|
|
1052
|
+
import {Internals as Internals6} from "remotion";
|
|
1053
|
+
|
|
1054
|
+
// src/render-volume-slider.tsx
|
|
1055
|
+
import React3, {useCallback as useCallback3, useMemo as useMemo3, useState as useState5} from "react";
|
|
1056
|
+
import {random} from "remotion";
|
|
1053
1057
|
import {
|
|
1054
1058
|
jsx as jsx5,
|
|
1055
1059
|
jsxs as jsxs3
|
|
1056
1060
|
} from "react/jsx-runtime";
|
|
1057
|
-
var BAR_HEIGHT = 5;
|
|
1058
1061
|
var KNOB_SIZE = 12;
|
|
1059
|
-
var
|
|
1060
|
-
var
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
const randomId = typeof React3.useId === "undefined" ? "volume-slider" : React3.useId();
|
|
1068
|
-
const [randomClass] = useState5(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
|
|
1069
|
-
const isMutedOrZero = mediaMuted || mediaVolume === 0;
|
|
1070
|
-
const onVolumeChange = useCallback3((e) => {
|
|
1071
|
-
setMediaVolume(parseFloat(e.target.value));
|
|
1072
|
-
}, [setMediaVolume]);
|
|
1073
|
-
const onBlur = () => {
|
|
1074
|
-
setTimeout(() => {
|
|
1075
|
-
if (document.activeElement !== inputRef.current) {
|
|
1076
|
-
setFocused(false);
|
|
1077
|
-
}
|
|
1078
|
-
}, 10);
|
|
1079
|
-
};
|
|
1080
|
-
const isVolume0 = mediaVolume === 0;
|
|
1081
|
-
const onClick = useCallback3(() => {
|
|
1082
|
-
if (isVolume0) {
|
|
1083
|
-
setMediaVolume(1);
|
|
1084
|
-
setMediaMuted(false);
|
|
1085
|
-
return;
|
|
1086
|
-
}
|
|
1087
|
-
setMediaMuted((mute) => !mute);
|
|
1088
|
-
}, [isVolume0, setMediaMuted, setMediaVolume]);
|
|
1089
|
-
const parentDivStyle = useMemo3(() => {
|
|
1090
|
-
return {
|
|
1091
|
-
display: "inline-flex",
|
|
1092
|
-
background: "none",
|
|
1093
|
-
border: "none",
|
|
1094
|
-
justifyContent: "center",
|
|
1095
|
-
alignItems: "center",
|
|
1096
|
-
touchAction: "none",
|
|
1097
|
-
...displayVerticalVolumeSlider && { position: "relative" }
|
|
1098
|
-
};
|
|
1099
|
-
}, [displayVerticalVolumeSlider]);
|
|
1100
|
-
const volumeContainer = useMemo3(() => {
|
|
1101
|
-
return {
|
|
1102
|
-
display: "inline",
|
|
1103
|
-
width: ICON_SIZE,
|
|
1104
|
-
height: ICON_SIZE,
|
|
1105
|
-
cursor: "pointer",
|
|
1106
|
-
appearance: "none",
|
|
1107
|
-
background: "none",
|
|
1108
|
-
border: "none",
|
|
1109
|
-
padding: 0
|
|
1110
|
-
};
|
|
1111
|
-
}, []);
|
|
1062
|
+
var BAR_HEIGHT = 5;
|
|
1063
|
+
var DefaultVolumeSlider = ({
|
|
1064
|
+
volume,
|
|
1065
|
+
isVertical,
|
|
1066
|
+
onBlur,
|
|
1067
|
+
inputRef,
|
|
1068
|
+
setVolume
|
|
1069
|
+
}) => {
|
|
1112
1070
|
const sliderContainer = useMemo3(() => {
|
|
1113
1071
|
const paddingLeft = 5;
|
|
1114
1072
|
const common = {
|
|
1115
1073
|
paddingLeft,
|
|
1116
1074
|
height: ICON_SIZE,
|
|
1117
|
-
width: VOLUME_SLIDER_WIDTH
|
|
1075
|
+
width: VOLUME_SLIDER_WIDTH,
|
|
1076
|
+
display: "inline-flex",
|
|
1077
|
+
alignItems: "center"
|
|
1118
1078
|
};
|
|
1119
|
-
if (
|
|
1079
|
+
if (isVertical) {
|
|
1120
1080
|
return {
|
|
1121
1081
|
...common,
|
|
1122
1082
|
position: "absolute",
|
|
@@ -1126,7 +1086,12 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
1126
1086
|
return {
|
|
1127
1087
|
...common
|
|
1128
1088
|
};
|
|
1129
|
-
}, [
|
|
1089
|
+
}, [isVertical]);
|
|
1090
|
+
const randomId = typeof React3.useId === "undefined" ? "volume-slider" : React3.useId();
|
|
1091
|
+
const [randomClass] = useState5(() => `__remotion-volume-slider-${random(randomId)}`.replace(".", ""));
|
|
1092
|
+
const onVolumeChange = useCallback3((e) => {
|
|
1093
|
+
setVolume(parseFloat(e.target.value));
|
|
1094
|
+
}, [setVolume]);
|
|
1130
1095
|
const inputStyle = useMemo3(() => {
|
|
1131
1096
|
const commonStyle = {
|
|
1132
1097
|
WebkitAppearance: "none",
|
|
@@ -1137,17 +1102,17 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
1137
1102
|
width: VOLUME_SLIDER_WIDTH,
|
|
1138
1103
|
backgroundImage: `linear-gradient(
|
|
1139
1104
|
to right,
|
|
1140
|
-
white ${
|
|
1105
|
+
white ${volume * 100}%, rgba(255, 255, 255, 0) ${volume * 100}%
|
|
1141
1106
|
)`
|
|
1142
1107
|
};
|
|
1143
|
-
if (
|
|
1108
|
+
if (isVertical) {
|
|
1144
1109
|
return {
|
|
1145
1110
|
...commonStyle,
|
|
1146
1111
|
bottom: ICON_SIZE + VOLUME_SLIDER_WIDTH / 2
|
|
1147
1112
|
};
|
|
1148
1113
|
}
|
|
1149
1114
|
return commonStyle;
|
|
1150
|
-
}, [
|
|
1115
|
+
}, [isVertical, volume]);
|
|
1151
1116
|
const sliderStyle = `
|
|
1152
1117
|
.${randomClass}::-webkit-slider-thumb {
|
|
1153
1118
|
-webkit-appearance: none;
|
|
@@ -1168,58 +1133,144 @@ var MediaVolumeSlider = ({ displayVerticalVolumeSlider }) => {
|
|
|
1168
1133
|
}
|
|
1169
1134
|
`;
|
|
1170
1135
|
return jsxs3("div", {
|
|
1171
|
-
|
|
1172
|
-
style: parentDivStyle,
|
|
1136
|
+
style: sliderContainer,
|
|
1173
1137
|
children: [
|
|
1174
1138
|
jsx5("style", {
|
|
1175
1139
|
dangerouslySetInnerHTML: {
|
|
1176
1140
|
__html: sliderStyle
|
|
1177
1141
|
}
|
|
1178
1142
|
}),
|
|
1179
|
-
jsx5("
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1143
|
+
jsx5("input", {
|
|
1144
|
+
ref: inputRef,
|
|
1145
|
+
"aria-label": "Change volume",
|
|
1146
|
+
className: randomClass,
|
|
1147
|
+
max: 1,
|
|
1148
|
+
min: 0,
|
|
1183
1149
|
onBlur,
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
type: "
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1150
|
+
onChange: onVolumeChange,
|
|
1151
|
+
step: 0.01,
|
|
1152
|
+
type: "range",
|
|
1153
|
+
value: volume,
|
|
1154
|
+
style: inputStyle
|
|
1155
|
+
})
|
|
1156
|
+
]
|
|
1157
|
+
});
|
|
1158
|
+
};
|
|
1159
|
+
var renderDefaultVolumeSlider = (props) => {
|
|
1160
|
+
return jsx5(DefaultVolumeSlider, {
|
|
1161
|
+
...props
|
|
1162
|
+
});
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
// src/MediaVolumeSlider.tsx
|
|
1166
|
+
import {
|
|
1167
|
+
jsx as jsx6,
|
|
1168
|
+
jsxs as jsxs4
|
|
1169
|
+
} from "react/jsx-runtime";
|
|
1170
|
+
var VOLUME_SLIDER_WIDTH = 100;
|
|
1171
|
+
var MediaVolumeSlider2 = ({ displayVerticalVolumeSlider, renderMuteButton, renderVolumeSlider }) => {
|
|
1172
|
+
const [mediaMuted, setMediaMuted] = Internals6.useMediaMutedState();
|
|
1173
|
+
const [mediaVolume, setMediaVolume] = Internals6.useMediaVolumeState();
|
|
1174
|
+
const [focused, setFocused] = useState6(false);
|
|
1175
|
+
const parentDivRef = useRef4(null);
|
|
1176
|
+
const inputRef = useRef4(null);
|
|
1177
|
+
const hover = useHoverState(parentDivRef, false);
|
|
1178
|
+
const onBlur = useCallback4(() => {
|
|
1179
|
+
setTimeout(() => {
|
|
1180
|
+
if (inputRef.current && document.activeElement !== inputRef.current) {
|
|
1181
|
+
setFocused(false);
|
|
1182
|
+
}
|
|
1183
|
+
}, 10);
|
|
1184
|
+
}, []);
|
|
1185
|
+
const isVolume0 = mediaVolume === 0;
|
|
1186
|
+
const onClick = useCallback4(() => {
|
|
1187
|
+
if (isVolume0) {
|
|
1188
|
+
setMediaVolume(1);
|
|
1189
|
+
setMediaMuted(false);
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
setMediaMuted((mute) => !mute);
|
|
1193
|
+
}, [isVolume0, setMediaMuted, setMediaVolume]);
|
|
1194
|
+
const parentDivStyle = useMemo4(() => {
|
|
1195
|
+
return {
|
|
1196
|
+
display: "inline-flex",
|
|
1197
|
+
background: "none",
|
|
1198
|
+
border: "none",
|
|
1199
|
+
justifyContent: "center",
|
|
1200
|
+
alignItems: "center",
|
|
1201
|
+
touchAction: "none",
|
|
1202
|
+
...displayVerticalVolumeSlider && { position: "relative" }
|
|
1203
|
+
};
|
|
1204
|
+
}, [displayVerticalVolumeSlider]);
|
|
1205
|
+
const volumeContainer = useMemo4(() => {
|
|
1206
|
+
return {
|
|
1207
|
+
display: "inline",
|
|
1208
|
+
width: ICON_SIZE,
|
|
1209
|
+
height: ICON_SIZE,
|
|
1210
|
+
cursor: "pointer",
|
|
1211
|
+
appearance: "none",
|
|
1212
|
+
background: "none",
|
|
1213
|
+
border: "none",
|
|
1214
|
+
padding: 0
|
|
1215
|
+
};
|
|
1216
|
+
}, []);
|
|
1217
|
+
const renderDefaultMuteButton = useCallback4(({ muted, volume }) => {
|
|
1218
|
+
const isMutedOrZero = muted || volume === 0;
|
|
1219
|
+
return jsx6("button", {
|
|
1220
|
+
"aria-label": isMutedOrZero ? "Unmute sound" : "Mute sound",
|
|
1221
|
+
title: isMutedOrZero ? "Unmute sound" : "Mute sound",
|
|
1222
|
+
onClick,
|
|
1223
|
+
onBlur,
|
|
1224
|
+
onFocus: () => setFocused(true),
|
|
1225
|
+
style: volumeContainer,
|
|
1226
|
+
type: "button",
|
|
1227
|
+
children: isMutedOrZero ? jsx6(VolumeOffIcon, {}) : jsx6(VolumeOnIcon, {})
|
|
1228
|
+
});
|
|
1229
|
+
}, [onBlur, onClick, volumeContainer]);
|
|
1230
|
+
const muteButton = useMemo4(() => {
|
|
1231
|
+
return renderMuteButton ? renderMuteButton({ muted: mediaMuted, volume: mediaVolume }) : renderDefaultMuteButton({ muted: mediaMuted, volume: mediaVolume });
|
|
1232
|
+
}, [mediaMuted, mediaVolume, renderDefaultMuteButton, renderMuteButton]);
|
|
1233
|
+
const volumeSlider = useMemo4(() => {
|
|
1234
|
+
return (focused || hover) && !mediaMuted && !Internals6.isIosSafari() ? (renderVolumeSlider ?? renderDefaultVolumeSlider)({
|
|
1235
|
+
isVertical: displayVerticalVolumeSlider,
|
|
1236
|
+
volume: mediaVolume,
|
|
1237
|
+
onBlur: () => setFocused(false),
|
|
1238
|
+
inputRef,
|
|
1239
|
+
setVolume: setMediaVolume
|
|
1240
|
+
}) : null;
|
|
1241
|
+
}, [
|
|
1242
|
+
displayVerticalVolumeSlider,
|
|
1243
|
+
focused,
|
|
1244
|
+
hover,
|
|
1245
|
+
mediaMuted,
|
|
1246
|
+
mediaVolume,
|
|
1247
|
+
renderVolumeSlider,
|
|
1248
|
+
setMediaVolume
|
|
1249
|
+
]);
|
|
1250
|
+
return jsxs4("div", {
|
|
1251
|
+
ref: parentDivRef,
|
|
1252
|
+
style: parentDivStyle,
|
|
1253
|
+
children: [
|
|
1254
|
+
muteButton,
|
|
1255
|
+
volumeSlider
|
|
1205
1256
|
]
|
|
1206
1257
|
});
|
|
1207
1258
|
};
|
|
1208
1259
|
|
|
1209
1260
|
// src/PlaybackrateControl.tsx
|
|
1210
1261
|
import {
|
|
1211
|
-
useCallback as
|
|
1262
|
+
useCallback as useCallback5,
|
|
1212
1263
|
useContext as useContext5,
|
|
1213
1264
|
useEffect as useEffect8,
|
|
1214
|
-
useMemo as
|
|
1215
|
-
useState as
|
|
1265
|
+
useMemo as useMemo5,
|
|
1266
|
+
useState as useState8
|
|
1216
1267
|
} from "react";
|
|
1217
1268
|
import {Internals as Internals7} from "remotion";
|
|
1218
1269
|
|
|
1219
1270
|
// src/utils/use-component-visible.ts
|
|
1220
|
-
import {useEffect as useEffect7, useRef as useRef5, useState as
|
|
1271
|
+
import {useEffect as useEffect7, useRef as useRef5, useState as useState7} from "react";
|
|
1221
1272
|
function useComponentVisible(initialIsVisible) {
|
|
1222
|
-
const [isComponentVisible, setIsComponentVisible] =
|
|
1273
|
+
const [isComponentVisible, setIsComponentVisible] = useState7(initialIsVisible);
|
|
1223
1274
|
const ref = useRef5(null);
|
|
1224
1275
|
useEffect7(() => {
|
|
1225
1276
|
const handleClickOutside = (event) => {
|
|
@@ -1237,8 +1288,8 @@ function useComponentVisible(initialIsVisible) {
|
|
|
1237
1288
|
|
|
1238
1289
|
// src/PlaybackrateControl.tsx
|
|
1239
1290
|
import {
|
|
1240
|
-
jsx as
|
|
1241
|
-
jsxs as
|
|
1291
|
+
jsx as jsx7,
|
|
1292
|
+
jsxs as jsxs5
|
|
1242
1293
|
} from "react/jsx-runtime";
|
|
1243
1294
|
var BOTTOM = 35;
|
|
1244
1295
|
var THRESHOLD = 70;
|
|
@@ -1260,44 +1311,44 @@ var checkmarkStyle = {
|
|
|
1260
1311
|
height: 14,
|
|
1261
1312
|
color: "black"
|
|
1262
1313
|
};
|
|
1263
|
-
var Checkmark = () =>
|
|
1314
|
+
var Checkmark = () => jsx7("svg", {
|
|
1264
1315
|
viewBox: "0 0 512 512",
|
|
1265
1316
|
style: checkmarkStyle,
|
|
1266
|
-
children:
|
|
1317
|
+
children: jsx7("path", {
|
|
1267
1318
|
fill: "currentColor",
|
|
1268
1319
|
d: "M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"
|
|
1269
1320
|
})
|
|
1270
1321
|
});
|
|
1271
1322
|
var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }) => {
|
|
1272
|
-
const onClick =
|
|
1323
|
+
const onClick = useCallback5((e) => {
|
|
1273
1324
|
e.stopPropagation();
|
|
1274
1325
|
e.preventDefault();
|
|
1275
1326
|
onSelect(rate);
|
|
1276
1327
|
}, [onSelect, rate]);
|
|
1277
|
-
const [hovered, setHovered] =
|
|
1278
|
-
const onMouseEnter =
|
|
1328
|
+
const [hovered, setHovered] = useState8(false);
|
|
1329
|
+
const onMouseEnter = useCallback5(() => {
|
|
1279
1330
|
setHovered(true);
|
|
1280
1331
|
}, []);
|
|
1281
|
-
const onMouseLeave =
|
|
1332
|
+
const onMouseLeave = useCallback5(() => {
|
|
1282
1333
|
setHovered(false);
|
|
1283
1334
|
}, []);
|
|
1284
1335
|
const isFocused = keyboardSelectedRate === rate;
|
|
1285
|
-
const actualStyle =
|
|
1336
|
+
const actualStyle = useMemo5(() => {
|
|
1286
1337
|
return {
|
|
1287
1338
|
...rateDiv,
|
|
1288
1339
|
backgroundColor: hovered || isFocused ? "#eee" : "transparent"
|
|
1289
1340
|
};
|
|
1290
1341
|
}, [hovered, isFocused]);
|
|
1291
|
-
return
|
|
1342
|
+
return jsxs5("div", {
|
|
1292
1343
|
onMouseEnter,
|
|
1293
1344
|
onMouseLeave,
|
|
1294
1345
|
tabIndex: 0,
|
|
1295
1346
|
style: actualStyle,
|
|
1296
1347
|
onClick,
|
|
1297
1348
|
children: [
|
|
1298
|
-
|
|
1349
|
+
jsx7("div", {
|
|
1299
1350
|
style: checkmarkContainer,
|
|
1300
|
-
children: rate === selectedRate ?
|
|
1351
|
+
children: rate === selectedRate ? jsx7(Checkmark, {}) : null
|
|
1301
1352
|
}),
|
|
1302
1353
|
rate.toFixed(1),
|
|
1303
1354
|
"x"
|
|
@@ -1306,7 +1357,7 @@ var PlaybackrateOption = ({ rate, onSelect, selectedRate, keyboardSelectedRate }
|
|
|
1306
1357
|
};
|
|
1307
1358
|
var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
1308
1359
|
const { setPlaybackRate, playbackRate } = useContext5(Internals7.Timeline.TimelineContext);
|
|
1309
|
-
const [keyboardSelectedRate, setKeyboardSelectedRate] =
|
|
1360
|
+
const [keyboardSelectedRate, setKeyboardSelectedRate] = useState8(playbackRate);
|
|
1310
1361
|
useEffect8(() => {
|
|
1311
1362
|
const listener = (e) => {
|
|
1312
1363
|
e.preventDefault();
|
|
@@ -1345,11 +1396,11 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
|
1345
1396
|
setPlaybackRate,
|
|
1346
1397
|
setIsComponentVisible
|
|
1347
1398
|
]);
|
|
1348
|
-
const onSelect =
|
|
1399
|
+
const onSelect = useCallback5((rate) => {
|
|
1349
1400
|
setPlaybackRate(rate);
|
|
1350
1401
|
setIsComponentVisible(false);
|
|
1351
1402
|
}, [setIsComponentVisible, setPlaybackRate]);
|
|
1352
|
-
const playbackPopup =
|
|
1403
|
+
const playbackPopup = useMemo5(() => {
|
|
1353
1404
|
return {
|
|
1354
1405
|
position: "absolute",
|
|
1355
1406
|
right: 0,
|
|
@@ -1363,10 +1414,10 @@ var PlaybackPopup = ({ setIsComponentVisible, playbackRates, canvasSize }) => {
|
|
|
1363
1414
|
textAlign: "left"
|
|
1364
1415
|
};
|
|
1365
1416
|
}, [canvasSize.height]);
|
|
1366
|
-
return
|
|
1417
|
+
return jsx7("div", {
|
|
1367
1418
|
style: playbackPopup,
|
|
1368
1419
|
children: playbackRates.map((rate) => {
|
|
1369
|
-
return
|
|
1420
|
+
return jsx7(PlaybackrateOption, {
|
|
1370
1421
|
selectedRate: playbackRate,
|
|
1371
1422
|
onSelect,
|
|
1372
1423
|
rate,
|
|
@@ -1408,27 +1459,27 @@ var button = {
|
|
|
1408
1459
|
var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
|
|
1409
1460
|
const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false);
|
|
1410
1461
|
const { playbackRate } = useContext5(Internals7.Timeline.TimelineContext);
|
|
1411
|
-
const onClick =
|
|
1462
|
+
const onClick = useCallback5((e) => {
|
|
1412
1463
|
e.stopPropagation();
|
|
1413
1464
|
e.preventDefault();
|
|
1414
1465
|
setIsComponentVisible((prevIsComponentVisible) => !prevIsComponentVisible);
|
|
1415
1466
|
}, [setIsComponentVisible]);
|
|
1416
|
-
return
|
|
1467
|
+
return jsx7("div", {
|
|
1417
1468
|
ref,
|
|
1418
|
-
children:
|
|
1469
|
+
children: jsxs5("button", {
|
|
1419
1470
|
type: "button",
|
|
1420
1471
|
"aria-label": "Change playback rate",
|
|
1421
1472
|
style: button,
|
|
1422
1473
|
onClick,
|
|
1423
1474
|
children: [
|
|
1424
|
-
|
|
1475
|
+
jsxs5("div", {
|
|
1425
1476
|
style: label,
|
|
1426
1477
|
children: [
|
|
1427
1478
|
playbackRate,
|
|
1428
1479
|
"x"
|
|
1429
1480
|
]
|
|
1430
1481
|
}),
|
|
1431
|
-
isComponentVisible &&
|
|
1482
|
+
isComponentVisible && jsx7(PlaybackPopup, {
|
|
1432
1483
|
canvasSize,
|
|
1433
1484
|
playbackRates,
|
|
1434
1485
|
setIsComponentVisible
|
|
@@ -1439,11 +1490,11 @@ var PlaybackrateControl = ({ playbackRates, canvasSize }) => {
|
|
|
1439
1490
|
};
|
|
1440
1491
|
|
|
1441
1492
|
// src/PlayerSeekBar.tsx
|
|
1442
|
-
import {useCallback as
|
|
1493
|
+
import {useCallback as useCallback6, useEffect as useEffect9, useMemo as useMemo6, useRef as useRef6, useState as useState9} from "react";
|
|
1443
1494
|
import {Internals as Internals8, interpolate} from "remotion";
|
|
1444
1495
|
import {
|
|
1445
|
-
jsx as
|
|
1446
|
-
jsxs as
|
|
1496
|
+
jsx as jsx8,
|
|
1497
|
+
jsxs as jsxs6
|
|
1447
1498
|
} from "react/jsx-runtime";
|
|
1448
1499
|
var getFrameFromX = (clientX, durationInFrames, width) => {
|
|
1449
1500
|
const pos = clientX;
|
|
@@ -1488,11 +1539,11 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1488
1539
|
});
|
|
1489
1540
|
const { seek, play, pause, playing } = usePlayer();
|
|
1490
1541
|
const frame = Internals8.Timeline.useTimelinePosition();
|
|
1491
|
-
const [dragging, setDragging] =
|
|
1542
|
+
const [dragging, setDragging] = useState9({
|
|
1492
1543
|
dragging: false
|
|
1493
1544
|
});
|
|
1494
1545
|
const width = size?.width ?? 0;
|
|
1495
|
-
const onPointerDown =
|
|
1546
|
+
const onPointerDown = useCallback6((e) => {
|
|
1496
1547
|
if (e.button !== 0) {
|
|
1497
1548
|
return;
|
|
1498
1549
|
}
|
|
@@ -1506,7 +1557,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1506
1557
|
});
|
|
1507
1558
|
onSeekStart();
|
|
1508
1559
|
}, [durationInFrames, width, pause, seek, playing, onSeekStart]);
|
|
1509
|
-
const onPointerMove =
|
|
1560
|
+
const onPointerMove = useCallback6((e) => {
|
|
1510
1561
|
if (!size) {
|
|
1511
1562
|
throw new Error("Player has no size");
|
|
1512
1563
|
}
|
|
@@ -1517,7 +1568,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1517
1568
|
const _frame = getFrameFromX(e.clientX - posLeft, durationInFrames, size.width);
|
|
1518
1569
|
seek(_frame);
|
|
1519
1570
|
}, [dragging.dragging, durationInFrames, seek, size]);
|
|
1520
|
-
const onPointerUp =
|
|
1571
|
+
const onPointerUp = useCallback6(() => {
|
|
1521
1572
|
setDragging({
|
|
1522
1573
|
dragging: false
|
|
1523
1574
|
});
|
|
@@ -1543,20 +1594,20 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1543
1594
|
body.removeEventListener("pointerup", onPointerUp);
|
|
1544
1595
|
};
|
|
1545
1596
|
}, [dragging.dragging, onPointerMove, onPointerUp]);
|
|
1546
|
-
const knobStyle =
|
|
1597
|
+
const knobStyle = useMemo6(() => {
|
|
1547
1598
|
return {
|
|
1548
1599
|
height: KNOB_SIZE2,
|
|
1549
1600
|
width: KNOB_SIZE2,
|
|
1550
1601
|
borderRadius: KNOB_SIZE2 / 2,
|
|
1551
1602
|
position: "absolute",
|
|
1552
|
-
top: VERTICAL_PADDING - KNOB_SIZE2 / 2 + 2
|
|
1603
|
+
top: VERTICAL_PADDING - KNOB_SIZE2 / 2 + 5 / 2,
|
|
1553
1604
|
backgroundColor: "white",
|
|
1554
1605
|
left: Math.max(0, frame / Math.max(1, durationInFrames - 1) * width - KNOB_SIZE2 / 2),
|
|
1555
1606
|
boxShadow: "0 0 2px black",
|
|
1556
1607
|
opacity: Number(barHovered)
|
|
1557
1608
|
};
|
|
1558
1609
|
}, [barHovered, durationInFrames, frame, width]);
|
|
1559
|
-
const fillStyle =
|
|
1610
|
+
const fillStyle = useMemo6(() => {
|
|
1560
1611
|
return {
|
|
1561
1612
|
height: BAR_HEIGHT2,
|
|
1562
1613
|
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
@@ -1565,7 +1616,7 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1565
1616
|
borderRadius: BAR_HEIGHT2 / 2
|
|
1566
1617
|
};
|
|
1567
1618
|
}, [durationInFrames, frame, inFrame]);
|
|
1568
|
-
const active =
|
|
1619
|
+
const active = useMemo6(() => {
|
|
1569
1620
|
return {
|
|
1570
1621
|
height: BAR_HEIGHT2,
|
|
1571
1622
|
backgroundColor: "rgba(255, 255, 255, 0.25)",
|
|
@@ -1575,23 +1626,23 @@ var PlayerSeekBar = ({ durationInFrames, onSeekEnd, onSeekStart, inFrame, outFra
|
|
|
1575
1626
|
position: "absolute"
|
|
1576
1627
|
};
|
|
1577
1628
|
}, [durationInFrames, inFrame, outFrame]);
|
|
1578
|
-
return
|
|
1629
|
+
return jsxs6("div", {
|
|
1579
1630
|
ref: containerRef,
|
|
1580
1631
|
onPointerDown,
|
|
1581
1632
|
style: containerStyle,
|
|
1582
1633
|
children: [
|
|
1583
|
-
|
|
1634
|
+
jsxs6("div", {
|
|
1584
1635
|
style: barBackground,
|
|
1585
1636
|
children: [
|
|
1586
|
-
|
|
1637
|
+
jsx8("div", {
|
|
1587
1638
|
style: active
|
|
1588
1639
|
}),
|
|
1589
|
-
|
|
1640
|
+
jsx8("div", {
|
|
1590
1641
|
style: fillStyle
|
|
1591
1642
|
})
|
|
1592
1643
|
]
|
|
1593
1644
|
}),
|
|
1594
|
-
|
|
1645
|
+
jsx8("div", {
|
|
1595
1646
|
style: knobStyle
|
|
1596
1647
|
})
|
|
1597
1648
|
]
|
|
@@ -1606,14 +1657,14 @@ var formatTime = (timeInSeconds) => {
|
|
|
1606
1657
|
};
|
|
1607
1658
|
|
|
1608
1659
|
// src/use-video-controls-resize.ts
|
|
1609
|
-
import {useMemo as
|
|
1660
|
+
import {useMemo as useMemo7} from "react";
|
|
1610
1661
|
var X_SPACER = 10;
|
|
1611
1662
|
var X_PADDING = 12;
|
|
1612
1663
|
var useVideoControlsResize = ({
|
|
1613
1664
|
allowFullscreen: allowFullScreen,
|
|
1614
1665
|
playerWidth
|
|
1615
1666
|
}) => {
|
|
1616
|
-
const resizeInfo =
|
|
1667
|
+
const resizeInfo = useMemo7(() => {
|
|
1617
1668
|
const playPauseIconSize = ICON_SIZE;
|
|
1618
1669
|
const volumeIconSize = ICON_SIZE;
|
|
1619
1670
|
const _fullscreenIconSize = allowFullScreen ? fullscreenIconSize : 0;
|
|
@@ -1634,8 +1685,8 @@ var useVideoControlsResize = ({
|
|
|
1634
1685
|
|
|
1635
1686
|
// src/PlayerControls.tsx
|
|
1636
1687
|
import {
|
|
1637
|
-
jsx as
|
|
1638
|
-
jsxs as
|
|
1688
|
+
jsx as jsx9,
|
|
1689
|
+
jsxs as jsxs7,
|
|
1639
1690
|
Fragment as Fragment2
|
|
1640
1691
|
} from "react/jsx-runtime";
|
|
1641
1692
|
var gradientSteps = [
|
|
@@ -1672,7 +1723,7 @@ var gradientOpacities = [
|
|
|
1672
1723
|
84.5,
|
|
1673
1724
|
91.9
|
|
1674
1725
|
];
|
|
1675
|
-
var globalGradientOpacity = 1.
|
|
1726
|
+
var globalGradientOpacity = 1 / 0.7;
|
|
1676
1727
|
var containerStyle2 = {
|
|
1677
1728
|
boxSizing: "border-box",
|
|
1678
1729
|
position: "absolute",
|
|
@@ -1740,17 +1791,19 @@ var Controls = ({
|
|
|
1740
1791
|
buffering,
|
|
1741
1792
|
hideControlsWhenPointerDoesntMove,
|
|
1742
1793
|
onPointerDown,
|
|
1743
|
-
onDoubleClick
|
|
1794
|
+
onDoubleClick,
|
|
1795
|
+
renderMuteButton,
|
|
1796
|
+
renderVolumeSlider
|
|
1744
1797
|
}) => {
|
|
1745
1798
|
const playButtonRef = useRef7(null);
|
|
1746
1799
|
const frame = Internals9.Timeline.useTimelinePosition();
|
|
1747
|
-
const [supportsFullscreen, setSupportsFullscreen] =
|
|
1800
|
+
const [supportsFullscreen, setSupportsFullscreen] = useState10(false);
|
|
1748
1801
|
const hovered = useHoverState(containerRef, hideControlsWhenPointerDoesntMove);
|
|
1749
1802
|
const { maxTimeLabelWidth, displayVerticalVolumeSlider } = useVideoControlsResize({
|
|
1750
1803
|
allowFullscreen,
|
|
1751
1804
|
playerWidth: canvasSize?.width ?? 0
|
|
1752
1805
|
});
|
|
1753
|
-
const [shouldShowInitially, setInitiallyShowControls] =
|
|
1806
|
+
const [shouldShowInitially, setInitiallyShowControls] = useState10(() => {
|
|
1754
1807
|
if (typeof initiallyShowControls === "boolean") {
|
|
1755
1808
|
return initiallyShowControls;
|
|
1756
1809
|
}
|
|
@@ -1771,7 +1824,7 @@ var Controls = ({
|
|
|
1771
1824
|
}
|
|
1772
1825
|
throw new TypeError("initiallyShowControls must be a number or a boolean");
|
|
1773
1826
|
});
|
|
1774
|
-
const containerCss =
|
|
1827
|
+
const containerCss = useMemo8(() => {
|
|
1775
1828
|
const shouldShow = hovered || !player.playing || shouldShowInitially || alwaysShowControls;
|
|
1776
1829
|
return {
|
|
1777
1830
|
...containerStyle2,
|
|
@@ -1800,7 +1853,7 @@ var Controls = ({
|
|
|
1800
1853
|
clearInterval(timeout);
|
|
1801
1854
|
};
|
|
1802
1855
|
}, [shouldShowInitially]);
|
|
1803
|
-
const timeLabel =
|
|
1856
|
+
const timeLabel = useMemo8(() => {
|
|
1804
1857
|
return {
|
|
1805
1858
|
color: "white",
|
|
1806
1859
|
fontFamily: "sans-serif",
|
|
@@ -1810,7 +1863,7 @@ var Controls = ({
|
|
|
1810
1863
|
textOverflow: "ellipsis"
|
|
1811
1864
|
};
|
|
1812
1865
|
}, [maxTimeLabelWidth]);
|
|
1813
|
-
const playbackRates =
|
|
1866
|
+
const playbackRates = useMemo8(() => {
|
|
1814
1867
|
if (showPlaybackRateControl === true) {
|
|
1815
1868
|
return [0.5, 0.8, 1, 1.2, 1.5, 1.8, 2, 2.5, 3];
|
|
1816
1869
|
}
|
|
@@ -1829,61 +1882,63 @@ var Controls = ({
|
|
|
1829
1882
|
}, [showPlaybackRateControl]);
|
|
1830
1883
|
const ref = useRef7(null);
|
|
1831
1884
|
const flexRef = useRef7(null);
|
|
1832
|
-
const onPointerDownIfContainer =
|
|
1885
|
+
const onPointerDownIfContainer = useCallback7((e) => {
|
|
1833
1886
|
if (e.target === ref.current || e.target === flexRef.current) {
|
|
1834
1887
|
onPointerDown?.(e);
|
|
1835
1888
|
}
|
|
1836
1889
|
}, [onPointerDown]);
|
|
1837
|
-
const onDoubleClickIfContainer =
|
|
1890
|
+
const onDoubleClickIfContainer = useCallback7((e) => {
|
|
1838
1891
|
if (e.target === ref.current || e.target === flexRef.current) {
|
|
1839
1892
|
onDoubleClick?.(e);
|
|
1840
1893
|
}
|
|
1841
1894
|
}, [onDoubleClick]);
|
|
1842
|
-
return
|
|
1895
|
+
return jsxs7("div", {
|
|
1843
1896
|
ref,
|
|
1844
1897
|
style: containerCss,
|
|
1845
1898
|
onPointerDown: onPointerDownIfContainer,
|
|
1846
1899
|
onDoubleClick: onDoubleClickIfContainer,
|
|
1847
1900
|
children: [
|
|
1848
|
-
|
|
1901
|
+
jsxs7("div", {
|
|
1849
1902
|
ref: flexRef,
|
|
1850
1903
|
style: controlsRow,
|
|
1851
1904
|
children: [
|
|
1852
|
-
|
|
1905
|
+
jsxs7("div", {
|
|
1853
1906
|
style: leftPartStyle,
|
|
1854
1907
|
children: [
|
|
1855
|
-
|
|
1908
|
+
jsx9("button", {
|
|
1856
1909
|
ref: playButtonRef,
|
|
1857
1910
|
type: "button",
|
|
1858
1911
|
style: playerButtonStyle,
|
|
1859
1912
|
onClick: player.playing ? player.pause : player.play,
|
|
1860
1913
|
"aria-label": player.playing ? "Pause video" : "Play video",
|
|
1861
1914
|
title: player.playing ? "Pause video" : "Play video",
|
|
1862
|
-
children: renderPlayPauseButton === null ?
|
|
1915
|
+
children: renderPlayPauseButton === null ? jsx9(DefaultPlayPauseButton, {
|
|
1863
1916
|
buffering,
|
|
1864
1917
|
playing: player.playing
|
|
1865
1918
|
}) : renderPlayPauseButton({
|
|
1866
1919
|
playing: player.playing,
|
|
1867
1920
|
isBuffering: buffering
|
|
1868
|
-
}) ??
|
|
1921
|
+
}) ?? jsx9(DefaultPlayPauseButton, {
|
|
1869
1922
|
buffering,
|
|
1870
1923
|
playing: player.playing
|
|
1871
1924
|
})
|
|
1872
1925
|
}),
|
|
1873
|
-
showVolumeControls ?
|
|
1926
|
+
showVolumeControls ? jsxs7(Fragment2, {
|
|
1874
1927
|
children: [
|
|
1875
|
-
|
|
1928
|
+
jsx9("div", {
|
|
1876
1929
|
style: xSpacer
|
|
1877
1930
|
}),
|
|
1878
|
-
|
|
1931
|
+
jsx9(MediaVolumeSlider2, {
|
|
1932
|
+
renderMuteButton,
|
|
1933
|
+
renderVolumeSlider,
|
|
1879
1934
|
displayVerticalVolumeSlider
|
|
1880
1935
|
})
|
|
1881
1936
|
]
|
|
1882
1937
|
}) : null,
|
|
1883
|
-
|
|
1938
|
+
jsx9("div", {
|
|
1884
1939
|
style: xSpacer
|
|
1885
1940
|
}),
|
|
1886
|
-
|
|
1941
|
+
jsxs7("div", {
|
|
1887
1942
|
style: timeLabel,
|
|
1888
1943
|
children: [
|
|
1889
1944
|
formatTime(frame / fps),
|
|
@@ -1891,40 +1946,40 @@ var Controls = ({
|
|
|
1891
1946
|
formatTime(durationInFrames / fps)
|
|
1892
1947
|
]
|
|
1893
1948
|
}),
|
|
1894
|
-
|
|
1949
|
+
jsx9("div", {
|
|
1895
1950
|
style: xSpacer
|
|
1896
1951
|
})
|
|
1897
1952
|
]
|
|
1898
1953
|
}),
|
|
1899
|
-
|
|
1954
|
+
jsx9("div", {
|
|
1900
1955
|
style: flex1
|
|
1901
1956
|
}),
|
|
1902
|
-
playbackRates && canvasSize &&
|
|
1957
|
+
playbackRates && canvasSize && jsx9(PlaybackrateControl, {
|
|
1903
1958
|
canvasSize,
|
|
1904
1959
|
playbackRates
|
|
1905
1960
|
}),
|
|
1906
|
-
playbackRates && supportsFullscreen && allowFullscreen ?
|
|
1961
|
+
playbackRates && supportsFullscreen && allowFullscreen ? jsx9("div", {
|
|
1907
1962
|
style: xSpacer
|
|
1908
1963
|
}) : null,
|
|
1909
|
-
|
|
1964
|
+
jsx9("div", {
|
|
1910
1965
|
style: fullscreen,
|
|
1911
|
-
children: supportsFullscreen && allowFullscreen ?
|
|
1966
|
+
children: supportsFullscreen && allowFullscreen ? jsx9("button", {
|
|
1912
1967
|
type: "button",
|
|
1913
1968
|
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
|
|
1914
1969
|
title: isFullscreen ? "Exit fullscreen" : "Enter Fullscreen",
|
|
1915
1970
|
style: playerButtonStyle,
|
|
1916
1971
|
onClick: isFullscreen ? onExitFullscreenButtonClick : onFullscreenButtonClick,
|
|
1917
|
-
children: renderFullscreenButton === null ?
|
|
1972
|
+
children: renderFullscreenButton === null ? jsx9(FullscreenIcon, {
|
|
1918
1973
|
isFullscreen
|
|
1919
1974
|
}) : renderFullscreenButton({ isFullscreen })
|
|
1920
1975
|
}) : null
|
|
1921
1976
|
})
|
|
1922
1977
|
]
|
|
1923
1978
|
}),
|
|
1924
|
-
|
|
1979
|
+
jsx9("div", {
|
|
1925
1980
|
style: ySpacer
|
|
1926
1981
|
}),
|
|
1927
|
-
|
|
1982
|
+
jsx9(PlayerSeekBar, {
|
|
1928
1983
|
onSeekEnd,
|
|
1929
1984
|
onSeekStart,
|
|
1930
1985
|
durationInFrames,
|
|
@@ -1936,9 +1991,9 @@ var Controls = ({
|
|
|
1936
1991
|
};
|
|
1937
1992
|
|
|
1938
1993
|
// src/error-boundary.tsx
|
|
1939
|
-
import
|
|
1994
|
+
import React7 from "react";
|
|
1940
1995
|
import {
|
|
1941
|
-
jsx as
|
|
1996
|
+
jsx as jsx10
|
|
1942
1997
|
} from "react/jsx-runtime";
|
|
1943
1998
|
var errorStyle = {
|
|
1944
1999
|
display: "flex",
|
|
@@ -1949,7 +2004,7 @@ var errorStyle = {
|
|
|
1949
2004
|
width: "100%"
|
|
1950
2005
|
};
|
|
1951
2006
|
|
|
1952
|
-
class ErrorBoundary extends
|
|
2007
|
+
class ErrorBoundary extends React7.Component {
|
|
1953
2008
|
state = { hasError: null };
|
|
1954
2009
|
static getDerivedStateFromError(error) {
|
|
1955
2010
|
return { hasError: error };
|
|
@@ -1959,7 +2014,7 @@ class ErrorBoundary extends React6.Component {
|
|
|
1959
2014
|
}
|
|
1960
2015
|
render() {
|
|
1961
2016
|
if (this.state.hasError) {
|
|
1962
|
-
return
|
|
2017
|
+
return jsx10("div", {
|
|
1963
2018
|
style: errorStyle,
|
|
1964
2019
|
children: this.props.errorFallback({
|
|
1965
2020
|
error: this.state.hasError
|
|
@@ -1977,7 +2032,7 @@ var PLAYER_CSS_CLASSNAME = "__remotion-player";
|
|
|
1977
2032
|
var IS_NODE = typeof document === "undefined";
|
|
1978
2033
|
|
|
1979
2034
|
// src/utils/use-click-prevention-on-double-click.ts
|
|
1980
|
-
import {useCallback as
|
|
2035
|
+
import {useCallback as useCallback9, useMemo as useMemo10} from "react";
|
|
1981
2036
|
|
|
1982
2037
|
// src/utils/cancellable-promise.ts
|
|
1983
2038
|
var cancellablePromise = (promise) => {
|
|
@@ -2005,17 +2060,17 @@ var cancellablePromise = (promise) => {
|
|
|
2005
2060
|
var delay = (n) => new Promise((resolve) => setTimeout(resolve, n));
|
|
2006
2061
|
|
|
2007
2062
|
// src/utils/use-cancellable-promises.ts
|
|
2008
|
-
import {useCallback as
|
|
2063
|
+
import {useCallback as useCallback8, useMemo as useMemo9, useRef as useRef8} from "react";
|
|
2009
2064
|
var useCancellablePromises = () => {
|
|
2010
2065
|
const pendingPromises = useRef8([]);
|
|
2011
|
-
const appendPendingPromise =
|
|
2066
|
+
const appendPendingPromise = useCallback8((promise) => {
|
|
2012
2067
|
pendingPromises.current = [...pendingPromises.current, promise];
|
|
2013
2068
|
}, []);
|
|
2014
|
-
const removePendingPromise =
|
|
2069
|
+
const removePendingPromise = useCallback8((promise) => {
|
|
2015
2070
|
pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
|
|
2016
2071
|
}, []);
|
|
2017
|
-
const clearPendingPromises =
|
|
2018
|
-
const api =
|
|
2072
|
+
const clearPendingPromises = useCallback8(() => pendingPromises.current.map((p) => p.cancel()), []);
|
|
2073
|
+
const api = useMemo9(() => ({
|
|
2019
2074
|
appendPendingPromise,
|
|
2020
2075
|
removePendingPromise,
|
|
2021
2076
|
clearPendingPromises
|
|
@@ -2026,7 +2081,7 @@ var useCancellablePromises = () => {
|
|
|
2026
2081
|
// src/utils/use-click-prevention-on-double-click.ts
|
|
2027
2082
|
var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
|
|
2028
2083
|
const api = useCancellablePromises();
|
|
2029
|
-
const handleClick =
|
|
2084
|
+
const handleClick = useCallback9(async (e) => {
|
|
2030
2085
|
if (e instanceof PointerEvent ? e.pointerType === "touch" : e.nativeEvent.pointerType === "touch") {
|
|
2031
2086
|
onClick(e);
|
|
2032
2087
|
return;
|
|
@@ -2046,18 +2101,18 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
|
|
|
2046
2101
|
}
|
|
2047
2102
|
}
|
|
2048
2103
|
}, [api, onClick]);
|
|
2049
|
-
const handlePointerDown =
|
|
2104
|
+
const handlePointerDown = useCallback9(() => {
|
|
2050
2105
|
document.addEventListener("pointerup", (newEvt) => {
|
|
2051
2106
|
handleClick(newEvt);
|
|
2052
2107
|
}, {
|
|
2053
2108
|
once: true
|
|
2054
2109
|
});
|
|
2055
2110
|
}, [handleClick]);
|
|
2056
|
-
const handleDoubleClick =
|
|
2111
|
+
const handleDoubleClick = useCallback9(() => {
|
|
2057
2112
|
api.clearPendingPromises();
|
|
2058
2113
|
onDoubleClick();
|
|
2059
2114
|
}, [api, onDoubleClick]);
|
|
2060
|
-
const returnValue =
|
|
2115
|
+
const returnValue = useMemo10(() => {
|
|
2061
2116
|
if (!doubleClickToFullscreen) {
|
|
2062
2117
|
return { handlePointerDown: onClick, handleDoubleClick: () => {
|
|
2063
2118
|
return;
|
|
@@ -2070,11 +2125,11 @@ var useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFull
|
|
|
2070
2125
|
|
|
2071
2126
|
// src/PlayerUI.tsx
|
|
2072
2127
|
import {
|
|
2073
|
-
jsx as
|
|
2074
|
-
jsxs as
|
|
2128
|
+
jsx as jsx11,
|
|
2129
|
+
jsxs as jsxs8,
|
|
2075
2130
|
Fragment as Fragment3
|
|
2076
2131
|
} from "react/jsx-runtime";
|
|
2077
|
-
var reactVersion =
|
|
2132
|
+
var reactVersion = React8.version.split(".")[0];
|
|
2078
2133
|
if (reactVersion === "0") {
|
|
2079
2134
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
2080
2135
|
}
|
|
@@ -2105,6 +2160,8 @@ var PlayerUI = ({
|
|
|
2105
2160
|
initiallyShowControls,
|
|
2106
2161
|
renderFullscreen: renderFullscreenButton,
|
|
2107
2162
|
renderPlayPauseButton,
|
|
2163
|
+
renderMuteButton,
|
|
2164
|
+
renderVolumeSlider,
|
|
2108
2165
|
alwaysShowControls,
|
|
2109
2166
|
showPlaybackRateControl,
|
|
2110
2167
|
posterFillMode,
|
|
@@ -2119,11 +2176,11 @@ var PlayerUI = ({
|
|
|
2119
2176
|
triggerOnWindowResize: false,
|
|
2120
2177
|
shouldApplyCssTransforms: false
|
|
2121
2178
|
});
|
|
2122
|
-
const [hasPausedToResume, setHasPausedToResume] =
|
|
2123
|
-
const [shouldAutoplay, setShouldAutoPlay] =
|
|
2124
|
-
const [isFullscreen, setIsFullscreen] =
|
|
2125
|
-
const [seeking, setSeeking] =
|
|
2126
|
-
const supportsFullScreen =
|
|
2179
|
+
const [hasPausedToResume, setHasPausedToResume] = useState11(false);
|
|
2180
|
+
const [shouldAutoplay, setShouldAutoPlay] = useState11(autoPlay);
|
|
2181
|
+
const [isFullscreen, setIsFullscreen] = useState11(() => false);
|
|
2182
|
+
const [seeking, setSeeking] = useState11(false);
|
|
2183
|
+
const supportsFullScreen = useMemo11(() => {
|
|
2127
2184
|
if (typeof document === "undefined") {
|
|
2128
2185
|
return false;
|
|
2129
2186
|
}
|
|
@@ -2159,14 +2216,14 @@ var PlayerUI = ({
|
|
|
2159
2216
|
document.removeEventListener("webkitfullscreenchange", onFullscreenChange);
|
|
2160
2217
|
};
|
|
2161
2218
|
}, []);
|
|
2162
|
-
const toggle =
|
|
2219
|
+
const toggle = useCallback10((e) => {
|
|
2163
2220
|
if (player.isPlaying()) {
|
|
2164
2221
|
player.pause();
|
|
2165
2222
|
} else {
|
|
2166
2223
|
player.play(e);
|
|
2167
2224
|
}
|
|
2168
2225
|
}, [player]);
|
|
2169
|
-
const requestFullscreen =
|
|
2226
|
+
const requestFullscreen = useCallback10(() => {
|
|
2170
2227
|
if (!allowFullscreen) {
|
|
2171
2228
|
throw new Error("allowFullscreen is false");
|
|
2172
2229
|
}
|
|
@@ -2182,7 +2239,7 @@ var PlayerUI = ({
|
|
|
2182
2239
|
container.current.requestFullscreen();
|
|
2183
2240
|
}
|
|
2184
2241
|
}, [allowFullscreen, supportsFullScreen]);
|
|
2185
|
-
const exitFullscreen =
|
|
2242
|
+
const exitFullscreen = useCallback10(() => {
|
|
2186
2243
|
if (document.webkitExitFullscreen) {
|
|
2187
2244
|
document.webkitExitFullscreen();
|
|
2188
2245
|
} else {
|
|
@@ -2214,7 +2271,7 @@ var PlayerUI = ({
|
|
|
2214
2271
|
};
|
|
2215
2272
|
}, [player.emitter]);
|
|
2216
2273
|
const durationInFrames = config?.durationInFrames ?? 1;
|
|
2217
|
-
const layout =
|
|
2274
|
+
const layout = useMemo11(() => {
|
|
2218
2275
|
if (!config || !canvasSize) {
|
|
2219
2276
|
return null;
|
|
2220
2277
|
}
|
|
@@ -2245,7 +2302,7 @@ var PlayerUI = ({
|
|
|
2245
2302
|
isMuted
|
|
2246
2303
|
});
|
|
2247
2304
|
}, [player.emitter, isMuted]);
|
|
2248
|
-
const [showBufferIndicator, setShowBufferState] =
|
|
2305
|
+
const [showBufferIndicator, setShowBufferState] = useState11(false);
|
|
2249
2306
|
useEffect11(() => {
|
|
2250
2307
|
let timeout = null;
|
|
2251
2308
|
let stopped = false;
|
|
@@ -2358,13 +2415,13 @@ var PlayerUI = ({
|
|
|
2358
2415
|
scale
|
|
2359
2416
|
]);
|
|
2360
2417
|
const VideoComponent = video ? video.component : null;
|
|
2361
|
-
const outerStyle =
|
|
2418
|
+
const outerStyle = useMemo11(() => {
|
|
2362
2419
|
return calculateOuterStyle({ canvasSize, config, style, overflowVisible });
|
|
2363
2420
|
}, [canvasSize, config, overflowVisible, style]);
|
|
2364
|
-
const outer =
|
|
2421
|
+
const outer = useMemo11(() => {
|
|
2365
2422
|
return calculateOuter({ config, layout, scale, overflowVisible });
|
|
2366
2423
|
}, [config, layout, overflowVisible, scale]);
|
|
2367
|
-
const containerStyle3 =
|
|
2424
|
+
const containerStyle3 = useMemo11(() => {
|
|
2368
2425
|
return calculateContainerStyle({
|
|
2369
2426
|
canvasSize,
|
|
2370
2427
|
config,
|
|
@@ -2373,28 +2430,28 @@ var PlayerUI = ({
|
|
|
2373
2430
|
overflowVisible
|
|
2374
2431
|
});
|
|
2375
2432
|
}, [canvasSize, config, layout, overflowVisible, scale]);
|
|
2376
|
-
const onError =
|
|
2433
|
+
const onError = useCallback10((error) => {
|
|
2377
2434
|
player.pause();
|
|
2378
2435
|
player.emitter.dispatchError(error);
|
|
2379
2436
|
}, [player]);
|
|
2380
|
-
const onFullscreenButtonClick =
|
|
2437
|
+
const onFullscreenButtonClick = useCallback10((e) => {
|
|
2381
2438
|
e.stopPropagation();
|
|
2382
2439
|
requestFullscreen();
|
|
2383
2440
|
}, [requestFullscreen]);
|
|
2384
|
-
const onExitFullscreenButtonClick =
|
|
2441
|
+
const onExitFullscreenButtonClick = useCallback10((e) => {
|
|
2385
2442
|
e.stopPropagation();
|
|
2386
2443
|
exitFullscreen();
|
|
2387
2444
|
}, [exitFullscreen]);
|
|
2388
|
-
const onSingleClick =
|
|
2445
|
+
const onSingleClick = useCallback10((e) => {
|
|
2389
2446
|
toggle(e);
|
|
2390
2447
|
}, [toggle]);
|
|
2391
|
-
const onSeekStart =
|
|
2448
|
+
const onSeekStart = useCallback10(() => {
|
|
2392
2449
|
setSeeking(true);
|
|
2393
2450
|
}, []);
|
|
2394
|
-
const onSeekEnd =
|
|
2451
|
+
const onSeekEnd = useCallback10(() => {
|
|
2395
2452
|
setSeeking(false);
|
|
2396
2453
|
}, []);
|
|
2397
|
-
const onDoubleClick =
|
|
2454
|
+
const onDoubleClick = useCallback10(() => {
|
|
2398
2455
|
if (isFullscreen) {
|
|
2399
2456
|
exitFullscreen();
|
|
2400
2457
|
} else {
|
|
@@ -2408,14 +2465,14 @@ var PlayerUI = ({
|
|
|
2408
2465
|
setShouldAutoPlay(false);
|
|
2409
2466
|
}
|
|
2410
2467
|
}, [shouldAutoplay, player]);
|
|
2411
|
-
const loadingMarkup =
|
|
2468
|
+
const loadingMarkup = useMemo11(() => {
|
|
2412
2469
|
return renderLoading ? renderLoading({
|
|
2413
2470
|
height: outerStyle.height,
|
|
2414
2471
|
width: outerStyle.width,
|
|
2415
2472
|
isBuffering: showBufferIndicator
|
|
2416
2473
|
}) : null;
|
|
2417
2474
|
}, [outerStyle.height, outerStyle.width, renderLoading, showBufferIndicator]);
|
|
2418
|
-
const currentScale =
|
|
2475
|
+
const currentScale = useMemo11(() => {
|
|
2419
2476
|
return {
|
|
2420
2477
|
type: "scale",
|
|
2421
2478
|
scale
|
|
@@ -2439,30 +2496,30 @@ var PlayerUI = ({
|
|
|
2439
2496
|
showPosterWhenBuffering && showBufferIndicator && player.isPlaying()
|
|
2440
2497
|
].some(Boolean);
|
|
2441
2498
|
const { left, top, width, height, ...outerWithoutScale } = outer;
|
|
2442
|
-
const content =
|
|
2499
|
+
const content = jsxs8(Fragment3, {
|
|
2443
2500
|
children: [
|
|
2444
|
-
|
|
2501
|
+
jsx11("div", {
|
|
2445
2502
|
style: outer,
|
|
2446
2503
|
onPointerDown: clickToPlay ? handlePointerDown : undefined,
|
|
2447
2504
|
onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
|
|
2448
|
-
children:
|
|
2505
|
+
children: jsxs8("div", {
|
|
2449
2506
|
style: containerStyle3,
|
|
2450
2507
|
className: PLAYER_CSS_CLASSNAME,
|
|
2451
2508
|
children: [
|
|
2452
|
-
VideoComponent ?
|
|
2509
|
+
VideoComponent ? jsx11(ErrorBoundary, {
|
|
2453
2510
|
onError,
|
|
2454
2511
|
errorFallback,
|
|
2455
|
-
children:
|
|
2456
|
-
children:
|
|
2512
|
+
children: jsx11(Internals10.ClipComposition, {
|
|
2513
|
+
children: jsx11(Internals10.CurrentScaleContext.Provider, {
|
|
2457
2514
|
value: currentScale,
|
|
2458
|
-
children:
|
|
2515
|
+
children: jsx11(VideoComponent, {
|
|
2459
2516
|
...video?.props ?? {},
|
|
2460
2517
|
...inputProps ?? {}
|
|
2461
2518
|
})
|
|
2462
2519
|
})
|
|
2463
2520
|
})
|
|
2464
2521
|
}) : null,
|
|
2465
|
-
shouldShowPoster && posterFillMode === "composition-size" ?
|
|
2522
|
+
shouldShowPoster && posterFillMode === "composition-size" ? jsx11("div", {
|
|
2466
2523
|
style: {
|
|
2467
2524
|
...outerWithoutScale,
|
|
2468
2525
|
width: config.width,
|
|
@@ -2475,13 +2532,13 @@ var PlayerUI = ({
|
|
|
2475
2532
|
]
|
|
2476
2533
|
})
|
|
2477
2534
|
}),
|
|
2478
|
-
shouldShowPoster && posterFillMode === "player-size" ?
|
|
2535
|
+
shouldShowPoster && posterFillMode === "player-size" ? jsx11("div", {
|
|
2479
2536
|
style: outer,
|
|
2480
2537
|
onPointerDown: clickToPlay ? handlePointerDown : undefined,
|
|
2481
2538
|
onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
|
|
2482
2539
|
children: poster
|
|
2483
2540
|
}) : null,
|
|
2484
|
-
controls ?
|
|
2541
|
+
controls ? jsx11(Controls, {
|
|
2485
2542
|
fps: config.fps,
|
|
2486
2543
|
durationInFrames: config.durationInFrames,
|
|
2487
2544
|
player,
|
|
@@ -2505,23 +2562,25 @@ var PlayerUI = ({
|
|
|
2505
2562
|
buffering: showBufferIndicator,
|
|
2506
2563
|
hideControlsWhenPointerDoesntMove,
|
|
2507
2564
|
onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
|
|
2508
|
-
onPointerDown: clickToPlay ? handlePointerDown : undefined
|
|
2565
|
+
onPointerDown: clickToPlay ? handlePointerDown : undefined,
|
|
2566
|
+
renderMuteButton,
|
|
2567
|
+
renderVolumeSlider
|
|
2509
2568
|
}) : null
|
|
2510
2569
|
]
|
|
2511
2570
|
});
|
|
2512
2571
|
if (IS_NODE && !doesReactVersionSupportSuspense) {
|
|
2513
|
-
return
|
|
2572
|
+
return jsx11("div", {
|
|
2514
2573
|
ref: container,
|
|
2515
2574
|
style: outerStyle,
|
|
2516
2575
|
className: className2,
|
|
2517
2576
|
children: content
|
|
2518
2577
|
});
|
|
2519
2578
|
}
|
|
2520
|
-
return
|
|
2579
|
+
return jsx11("div", {
|
|
2521
2580
|
ref: container,
|
|
2522
2581
|
style: outerStyle,
|
|
2523
2582
|
className: className2,
|
|
2524
|
-
children:
|
|
2583
|
+
children: jsx11(Suspense, {
|
|
2525
2584
|
fallback: loadingMarkup,
|
|
2526
2585
|
children: content
|
|
2527
2586
|
})
|
|
@@ -2530,7 +2589,7 @@ var PlayerUI = ({
|
|
|
2530
2589
|
var PlayerUI_default = forwardRef(PlayerUI);
|
|
2531
2590
|
|
|
2532
2591
|
// src/SharedPlayerContext.tsx
|
|
2533
|
-
import {useCallback as
|
|
2592
|
+
import {useCallback as useCallback11, useMemo as useMemo12, useState as useState12} from "react";
|
|
2534
2593
|
import {Internals as Internals11} from "remotion";
|
|
2535
2594
|
|
|
2536
2595
|
// src/volume-persistance.ts
|
|
@@ -2559,7 +2618,7 @@ var getPreferredVolume = () => {
|
|
|
2559
2618
|
|
|
2560
2619
|
// src/SharedPlayerContext.tsx
|
|
2561
2620
|
import {
|
|
2562
|
-
jsx as
|
|
2621
|
+
jsx as jsx12
|
|
2563
2622
|
} from "react/jsx-runtime";
|
|
2564
2623
|
var PLAYER_COMP_ID = "player-comp";
|
|
2565
2624
|
var SharedPlayerContexts = ({
|
|
@@ -2573,7 +2632,7 @@ var SharedPlayerContexts = ({
|
|
|
2573
2632
|
numberOfSharedAudioTags,
|
|
2574
2633
|
initiallyMuted
|
|
2575
2634
|
}) => {
|
|
2576
|
-
const compositionManagerContext =
|
|
2635
|
+
const compositionManagerContext = useMemo12(() => {
|
|
2577
2636
|
const context = {
|
|
2578
2637
|
compositions: [
|
|
2579
2638
|
{
|
|
@@ -2617,41 +2676,41 @@ var SharedPlayerContexts = ({
|
|
|
2617
2676
|
};
|
|
2618
2677
|
return context;
|
|
2619
2678
|
}, [component, durationInFrames, compositionHeight, compositionWidth, fps]);
|
|
2620
|
-
const [mediaMuted, setMediaMuted] =
|
|
2621
|
-
const [mediaVolume, setMediaVolume] =
|
|
2622
|
-
const mediaVolumeContextValue =
|
|
2679
|
+
const [mediaMuted, setMediaMuted] = useState12(() => initiallyMuted);
|
|
2680
|
+
const [mediaVolume, setMediaVolume] = useState12(() => getPreferredVolume());
|
|
2681
|
+
const mediaVolumeContextValue = useMemo12(() => {
|
|
2623
2682
|
return {
|
|
2624
2683
|
mediaMuted,
|
|
2625
2684
|
mediaVolume
|
|
2626
2685
|
};
|
|
2627
2686
|
}, [mediaMuted, mediaVolume]);
|
|
2628
|
-
const setMediaVolumeAndPersist =
|
|
2687
|
+
const setMediaVolumeAndPersist = useCallback11((vol) => {
|
|
2629
2688
|
setMediaVolume(vol);
|
|
2630
2689
|
persistVolume(vol);
|
|
2631
2690
|
}, []);
|
|
2632
|
-
const setMediaVolumeContextValue =
|
|
2691
|
+
const setMediaVolumeContextValue = useMemo12(() => {
|
|
2633
2692
|
return {
|
|
2634
2693
|
setMediaMuted,
|
|
2635
2694
|
setMediaVolume: setMediaVolumeAndPersist
|
|
2636
2695
|
};
|
|
2637
2696
|
}, [setMediaVolumeAndPersist]);
|
|
2638
|
-
return
|
|
2639
|
-
children:
|
|
2697
|
+
return jsx12(Internals11.CanUseRemotionHooksProvider, {
|
|
2698
|
+
children: jsx12(Internals11.Timeline.TimelineContext.Provider, {
|
|
2640
2699
|
value: timelineContext,
|
|
2641
|
-
children:
|
|
2700
|
+
children: jsx12(Internals11.CompositionManager.Provider, {
|
|
2642
2701
|
value: compositionManagerContext,
|
|
2643
|
-
children:
|
|
2644
|
-
children:
|
|
2645
|
-
children:
|
|
2646
|
-
children:
|
|
2702
|
+
children: jsx12(Internals11.ResolveCompositionConfig, {
|
|
2703
|
+
children: jsx12(Internals11.PrefetchProvider, {
|
|
2704
|
+
children: jsx12(Internals11.DurationsContextProvider, {
|
|
2705
|
+
children: jsx12(Internals11.MediaVolumeContext.Provider, {
|
|
2647
2706
|
value: mediaVolumeContextValue,
|
|
2648
|
-
children:
|
|
2649
|
-
children:
|
|
2707
|
+
children: jsx12(Internals11.NativeLayersProvider, {
|
|
2708
|
+
children: jsx12(Internals11.SetMediaVolumeContext.Provider, {
|
|
2650
2709
|
value: setMediaVolumeContextValue,
|
|
2651
|
-
children:
|
|
2710
|
+
children: jsx12(Internals11.SharedAudioContextProvider, {
|
|
2652
2711
|
numberOfAudioTags: numberOfSharedAudioTags,
|
|
2653
2712
|
component,
|
|
2654
|
-
children:
|
|
2713
|
+
children: jsx12(Internals11.BufferingProvider, {
|
|
2655
2714
|
children
|
|
2656
2715
|
})
|
|
2657
2716
|
})
|
|
@@ -2765,7 +2824,7 @@ var validateDefaultAndInputProps = NoReactInternals.validateDefaultAndInputProps
|
|
|
2765
2824
|
|
|
2766
2825
|
// src/Player.tsx
|
|
2767
2826
|
import {
|
|
2768
|
-
jsx as
|
|
2827
|
+
jsx as jsx13
|
|
2769
2828
|
} from "react/jsx-runtime";
|
|
2770
2829
|
var componentOrNullIfLazy = (props) => {
|
|
2771
2830
|
if ("component" in props) {
|
|
@@ -2805,6 +2864,7 @@ var PlayerFn = ({
|
|
|
2805
2864
|
initiallyShowControls,
|
|
2806
2865
|
renderFullscreenButton,
|
|
2807
2866
|
renderPlayPauseButton,
|
|
2867
|
+
renderVolumeSlider,
|
|
2808
2868
|
alwaysShowControls = false,
|
|
2809
2869
|
initiallyMuted = false,
|
|
2810
2870
|
showPlaybackRateControl = false,
|
|
@@ -2812,6 +2872,7 @@ var PlayerFn = ({
|
|
|
2812
2872
|
bufferStateDelayInMilliseconds,
|
|
2813
2873
|
hideControlsWhenPointerDoesntMove = true,
|
|
2814
2874
|
overflowVisible = false,
|
|
2875
|
+
renderMuteButton,
|
|
2815
2876
|
...componentProps
|
|
2816
2877
|
}, ref) => {
|
|
2817
2878
|
if (typeof window !== "undefined") {
|
|
@@ -2831,15 +2892,15 @@ var PlayerFn = ({
|
|
|
2831
2892
|
}
|
|
2832
2893
|
const component = Internals12.useLazyComponent(componentProps);
|
|
2833
2894
|
validateInitialFrame({ initialFrame, durationInFrames });
|
|
2834
|
-
const [frame, setFrame] =
|
|
2895
|
+
const [frame, setFrame] = useState13(() => ({
|
|
2835
2896
|
[PLAYER_COMP_ID]: initialFrame ?? 0
|
|
2836
2897
|
}));
|
|
2837
|
-
const [playing, setPlaying] =
|
|
2838
|
-
const [rootId] =
|
|
2898
|
+
const [playing, setPlaying] = useState13(false);
|
|
2899
|
+
const [rootId] = useState13("player-comp");
|
|
2839
2900
|
const rootRef = useRef10(null);
|
|
2840
2901
|
const audioAndVideoTags = useRef10([]);
|
|
2841
2902
|
const imperativePlaying = useRef10(false);
|
|
2842
|
-
const [currentPlaybackRate, setCurrentPlaybackRate] =
|
|
2903
|
+
const [currentPlaybackRate, setCurrentPlaybackRate] = useState13(playbackRate);
|
|
2843
2904
|
if (typeof compositionHeight !== "number") {
|
|
2844
2905
|
throw new TypeError(`'compositionHeight' must be a number but got '${typeof compositionHeight}' instead`);
|
|
2845
2906
|
}
|
|
@@ -2891,7 +2952,7 @@ var PlayerFn = ({
|
|
|
2891
2952
|
setCurrentPlaybackRate(playbackRate);
|
|
2892
2953
|
}, [playbackRate]);
|
|
2893
2954
|
useImperativeHandle2(ref, () => rootRef.current, []);
|
|
2894
|
-
const timelineContextValue =
|
|
2955
|
+
const timelineContextValue = useMemo13(() => {
|
|
2895
2956
|
return {
|
|
2896
2957
|
frame,
|
|
2897
2958
|
playing,
|
|
@@ -2904,7 +2965,7 @@ var PlayerFn = ({
|
|
|
2904
2965
|
audioAndVideoTags
|
|
2905
2966
|
};
|
|
2906
2967
|
}, [frame, currentPlaybackRate, playing, rootId]);
|
|
2907
|
-
const setTimelineContextValue =
|
|
2968
|
+
const setTimelineContextValue = useMemo13(() => {
|
|
2908
2969
|
return {
|
|
2909
2970
|
setFrame,
|
|
2910
2971
|
setPlaying
|
|
@@ -2915,9 +2976,9 @@ var PlayerFn = ({
|
|
|
2915
2976
|
Internals12.CSSUtils.injectCSS(Internals12.CSSUtils.makeDefaultPreviewCSS(`.${PLAYER_CSS_CLASSNAME}`, "#fff"));
|
|
2916
2977
|
}, []);
|
|
2917
2978
|
}
|
|
2918
|
-
const actualInputProps =
|
|
2919
|
-
return
|
|
2920
|
-
children:
|
|
2979
|
+
const actualInputProps = useMemo13(() => inputProps ?? {}, [inputProps]);
|
|
2980
|
+
return jsx13(Internals12.IsPlayerContextProvider, {
|
|
2981
|
+
children: jsx13(SharedPlayerContexts, {
|
|
2921
2982
|
timelineContext: timelineContextValue,
|
|
2922
2983
|
component,
|
|
2923
2984
|
compositionHeight,
|
|
@@ -2926,11 +2987,11 @@ var PlayerFn = ({
|
|
|
2926
2987
|
fps,
|
|
2927
2988
|
numberOfSharedAudioTags,
|
|
2928
2989
|
initiallyMuted,
|
|
2929
|
-
children:
|
|
2990
|
+
children: jsx13(Internals12.Timeline.SetTimelineContext.Provider, {
|
|
2930
2991
|
value: setTimelineContextValue,
|
|
2931
|
-
children:
|
|
2992
|
+
children: jsx13(PlayerEmitterProvider, {
|
|
2932
2993
|
currentPlaybackRate,
|
|
2933
|
-
children:
|
|
2994
|
+
children: jsx13(PlayerUI_default, {
|
|
2934
2995
|
ref: rootRef,
|
|
2935
2996
|
posterFillMode,
|
|
2936
2997
|
renderLoading,
|
|
@@ -2958,6 +3019,8 @@ var PlayerFn = ({
|
|
|
2958
3019
|
initiallyShowControls: initiallyShowControls ?? true,
|
|
2959
3020
|
renderFullscreen: renderFullscreenButton ?? null,
|
|
2960
3021
|
renderPlayPauseButton: renderPlayPauseButton ?? null,
|
|
3022
|
+
renderMuteButton: renderMuteButton ?? null,
|
|
3023
|
+
renderVolumeSlider: renderVolumeSlider ?? null,
|
|
2961
3024
|
alwaysShowControls,
|
|
2962
3025
|
showPlaybackRateControl,
|
|
2963
3026
|
bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds ?? 300,
|
|
@@ -2977,31 +3040,31 @@ import {
|
|
|
2977
3040
|
forwardRef as forwardRef4,
|
|
2978
3041
|
useImperativeHandle as useImperativeHandle4,
|
|
2979
3042
|
useLayoutEffect as useLayoutEffect2,
|
|
2980
|
-
useMemo as
|
|
3043
|
+
useMemo as useMemo16,
|
|
2981
3044
|
useRef as useRef12,
|
|
2982
|
-
useState as
|
|
3045
|
+
useState as useState14
|
|
2983
3046
|
} from "react";
|
|
2984
3047
|
import {Internals as Internals14, random as random2} from "remotion";
|
|
2985
3048
|
|
|
2986
3049
|
// src/ThumbnailUI.tsx
|
|
2987
|
-
import
|
|
3050
|
+
import React11, {
|
|
2988
3051
|
forwardRef as forwardRef3,
|
|
2989
3052
|
Suspense as Suspense2,
|
|
2990
|
-
useCallback as
|
|
3053
|
+
useCallback as useCallback12,
|
|
2991
3054
|
useImperativeHandle as useImperativeHandle3,
|
|
2992
|
-
useMemo as
|
|
3055
|
+
useMemo as useMemo15,
|
|
2993
3056
|
useRef as useRef11
|
|
2994
3057
|
} from "react";
|
|
2995
3058
|
import {Internals as Internals13} from "remotion";
|
|
2996
3059
|
|
|
2997
3060
|
// src/use-thumbnail.ts
|
|
2998
|
-
import {useContext as useContext7, useMemo as
|
|
3061
|
+
import {useContext as useContext7, useMemo as useMemo14} from "react";
|
|
2999
3062
|
var useThumbnail = () => {
|
|
3000
3063
|
const emitter = useContext7(ThumbnailEmitterContext);
|
|
3001
3064
|
if (!emitter) {
|
|
3002
3065
|
throw new TypeError("Expected Player event emitter context");
|
|
3003
3066
|
}
|
|
3004
|
-
const returnValue =
|
|
3067
|
+
const returnValue = useMemo14(() => {
|
|
3005
3068
|
return {
|
|
3006
3069
|
emitter
|
|
3007
3070
|
};
|
|
@@ -3011,9 +3074,9 @@ var useThumbnail = () => {
|
|
|
3011
3074
|
|
|
3012
3075
|
// src/ThumbnailUI.tsx
|
|
3013
3076
|
import {
|
|
3014
|
-
jsx as
|
|
3077
|
+
jsx as jsx14
|
|
3015
3078
|
} from "react/jsx-runtime";
|
|
3016
|
-
var reactVersion2 =
|
|
3079
|
+
var reactVersion2 = React11.version.split(".")[0];
|
|
3017
3080
|
if (reactVersion2 === "0") {
|
|
3018
3081
|
throw new Error(`Version ${reactVersion2} of "react" is not supported by Remotion`);
|
|
3019
3082
|
}
|
|
@@ -3026,7 +3089,7 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3026
3089
|
triggerOnWindowResize: false,
|
|
3027
3090
|
shouldApplyCssTransforms: false
|
|
3028
3091
|
});
|
|
3029
|
-
const layout =
|
|
3092
|
+
const layout = useMemo15(() => {
|
|
3030
3093
|
if (!config || !canvasSize) {
|
|
3031
3094
|
return null;
|
|
3032
3095
|
}
|
|
@@ -3048,13 +3111,13 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3048
3111
|
return Object.assign(thumbnail.emitter, methods);
|
|
3049
3112
|
}, [scale, thumbnail.emitter]);
|
|
3050
3113
|
const VideoComponent = video ? video.component : null;
|
|
3051
|
-
const outerStyle =
|
|
3114
|
+
const outerStyle = useMemo15(() => {
|
|
3052
3115
|
return calculateOuterStyle({ config, style, canvasSize, overflowVisible });
|
|
3053
3116
|
}, [canvasSize, config, overflowVisible, style]);
|
|
3054
|
-
const outer =
|
|
3117
|
+
const outer = useMemo15(() => {
|
|
3055
3118
|
return calculateOuter({ config, layout, scale, overflowVisible });
|
|
3056
3119
|
}, [config, layout, overflowVisible, scale]);
|
|
3057
|
-
const containerStyle3 =
|
|
3120
|
+
const containerStyle3 = useMemo15(() => {
|
|
3058
3121
|
return calculateContainerStyle({
|
|
3059
3122
|
canvasSize,
|
|
3060
3123
|
config,
|
|
@@ -3063,17 +3126,17 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3063
3126
|
overflowVisible
|
|
3064
3127
|
});
|
|
3065
3128
|
}, [canvasSize, config, layout, overflowVisible, scale]);
|
|
3066
|
-
const onError =
|
|
3129
|
+
const onError = useCallback12((error) => {
|
|
3067
3130
|
thumbnail.emitter.dispatchError(error);
|
|
3068
3131
|
}, [thumbnail.emitter]);
|
|
3069
|
-
const loadingMarkup =
|
|
3132
|
+
const loadingMarkup = useMemo15(() => {
|
|
3070
3133
|
return renderLoading ? renderLoading({
|
|
3071
3134
|
height: outerStyle.height,
|
|
3072
3135
|
width: outerStyle.width,
|
|
3073
3136
|
isBuffering: false
|
|
3074
3137
|
}) : null;
|
|
3075
3138
|
}, [outerStyle.height, outerStyle.width, renderLoading]);
|
|
3076
|
-
const currentScaleContext =
|
|
3139
|
+
const currentScaleContext = useMemo15(() => {
|
|
3077
3140
|
return {
|
|
3078
3141
|
type: "scale",
|
|
3079
3142
|
scale
|
|
@@ -3082,17 +3145,17 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3082
3145
|
if (!config) {
|
|
3083
3146
|
return null;
|
|
3084
3147
|
}
|
|
3085
|
-
const content =
|
|
3148
|
+
const content = jsx14("div", {
|
|
3086
3149
|
style: outer,
|
|
3087
|
-
children:
|
|
3150
|
+
children: jsx14("div", {
|
|
3088
3151
|
style: containerStyle3,
|
|
3089
3152
|
className: PLAYER_CSS_CLASSNAME,
|
|
3090
|
-
children: VideoComponent ?
|
|
3153
|
+
children: VideoComponent ? jsx14(ErrorBoundary, {
|
|
3091
3154
|
onError,
|
|
3092
3155
|
errorFallback,
|
|
3093
|
-
children:
|
|
3156
|
+
children: jsx14(Internals13.CurrentScaleContext.Provider, {
|
|
3094
3157
|
value: currentScaleContext,
|
|
3095
|
-
children:
|
|
3158
|
+
children: jsx14(VideoComponent, {
|
|
3096
3159
|
...video?.props ?? {},
|
|
3097
3160
|
...inputProps ?? {}
|
|
3098
3161
|
})
|
|
@@ -3101,18 +3164,18 @@ var ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className:
|
|
|
3101
3164
|
})
|
|
3102
3165
|
});
|
|
3103
3166
|
if (IS_NODE && !doesReactVersionSupportSuspense2) {
|
|
3104
|
-
return
|
|
3167
|
+
return jsx14("div", {
|
|
3105
3168
|
ref: container,
|
|
3106
3169
|
style: outerStyle,
|
|
3107
3170
|
className: className2,
|
|
3108
3171
|
children: content
|
|
3109
3172
|
});
|
|
3110
3173
|
}
|
|
3111
|
-
return
|
|
3174
|
+
return jsx14("div", {
|
|
3112
3175
|
ref: container,
|
|
3113
3176
|
style: outerStyle,
|
|
3114
3177
|
className: className2,
|
|
3115
|
-
children:
|
|
3178
|
+
children: jsx14(Suspense2, {
|
|
3116
3179
|
fallback: loadingMarkup,
|
|
3117
3180
|
children: content
|
|
3118
3181
|
})
|
|
@@ -3122,7 +3185,7 @@ var ThumbnailUI_default = forwardRef3(ThumbnailUI);
|
|
|
3122
3185
|
|
|
3123
3186
|
// src/Thumbnail.tsx
|
|
3124
3187
|
import {
|
|
3125
|
-
jsx as
|
|
3188
|
+
jsx as jsx15
|
|
3126
3189
|
} from "react/jsx-runtime";
|
|
3127
3190
|
var ThumbnailFn = ({
|
|
3128
3191
|
frameToDisplay,
|
|
@@ -3143,9 +3206,9 @@ var ThumbnailFn = ({
|
|
|
3143
3206
|
window.remotion_isPlayer = true;
|
|
3144
3207
|
}, []);
|
|
3145
3208
|
}
|
|
3146
|
-
const [thumbnailId] =
|
|
3209
|
+
const [thumbnailId] = useState14(() => String(random2(null)));
|
|
3147
3210
|
const rootRef = useRef12(null);
|
|
3148
|
-
const timelineState =
|
|
3211
|
+
const timelineState = useMemo16(() => {
|
|
3149
3212
|
const value = {
|
|
3150
3213
|
playing: false,
|
|
3151
3214
|
frame: {
|
|
@@ -3165,12 +3228,12 @@ var ThumbnailFn = ({
|
|
|
3165
3228
|
}, [frameToDisplay, thumbnailId]);
|
|
3166
3229
|
useImperativeHandle4(ref, () => rootRef.current, []);
|
|
3167
3230
|
const Component = Internals14.useLazyComponent(componentProps);
|
|
3168
|
-
const [emitter] =
|
|
3169
|
-
const passedInputProps =
|
|
3231
|
+
const [emitter] = useState14(() => new ThumbnailEmitter);
|
|
3232
|
+
const passedInputProps = useMemo16(() => {
|
|
3170
3233
|
return inputProps ?? {};
|
|
3171
3234
|
}, [inputProps]);
|
|
3172
|
-
return
|
|
3173
|
-
children:
|
|
3235
|
+
return jsx15(Internals14.IsPlayerContextProvider, {
|
|
3236
|
+
children: jsx15(SharedPlayerContexts, {
|
|
3174
3237
|
timelineContext: timelineState,
|
|
3175
3238
|
component: Component,
|
|
3176
3239
|
compositionHeight,
|
|
@@ -3179,9 +3242,9 @@ var ThumbnailFn = ({
|
|
|
3179
3242
|
fps,
|
|
3180
3243
|
numberOfSharedAudioTags: 0,
|
|
3181
3244
|
initiallyMuted: true,
|
|
3182
|
-
children:
|
|
3245
|
+
children: jsx15(ThumbnailEmitterContext.Provider, {
|
|
3183
3246
|
value: emitter,
|
|
3184
|
-
children:
|
|
3247
|
+
children: jsx15(ThumbnailUI_default, {
|
|
3185
3248
|
ref: rootRef,
|
|
3186
3249
|
className: className2,
|
|
3187
3250
|
errorFallback,
|