remotion 4.0.176 → 4.0.177
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/buffer-until-first-frame.d.ts +3 -2
- package/dist/cjs/buffer-until-first-frame.js +8 -4
- package/dist/cjs/use-media-playback.js +35 -9
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +93 -66
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const useBufferUntilFirstFrame: ({ mediaRef, mediaType, }: {
|
|
1
|
+
export declare const useBufferUntilFirstFrame: ({ mediaRef, mediaType, onVariableFpsVideoDetected, }: {
|
|
2
2
|
mediaRef: React.RefObject<HTMLVideoElement | HTMLAudioElement>;
|
|
3
3
|
mediaType: 'video' | 'audio';
|
|
4
|
+
onVariableFpsVideoDetected: () => void;
|
|
4
5
|
}) => {
|
|
5
6
|
isBuffering: () => boolean;
|
|
6
|
-
bufferUntilFirstFrame: () => void;
|
|
7
|
+
bufferUntilFirstFrame: (requestedTime: number) => void;
|
|
7
8
|
};
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useBufferUntilFirstFrame = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const use_buffer_state_1 = require("./use-buffer-state");
|
|
6
|
-
const useBufferUntilFirstFrame = ({ mediaRef, mediaType, }) => {
|
|
6
|
+
const useBufferUntilFirstFrame = ({ mediaRef, mediaType, onVariableFpsVideoDetected, }) => {
|
|
7
7
|
const bufferingRef = (0, react_1.useRef)(false);
|
|
8
8
|
const { delayPlayback } = (0, use_buffer_state_1.useBufferState)();
|
|
9
|
-
const bufferUntilFirstFrame = (0, react_1.useCallback)(() => {
|
|
9
|
+
const bufferUntilFirstFrame = (0, react_1.useCallback)((requestedTime) => {
|
|
10
10
|
if (mediaType !== 'video') {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -34,7 +34,11 @@ const useBufferUntilFirstFrame = ({ mediaRef, mediaType, }) => {
|
|
|
34
34
|
const onEndedOrPause = () => {
|
|
35
35
|
unblock();
|
|
36
36
|
};
|
|
37
|
-
current.requestVideoFrameCallback(() => {
|
|
37
|
+
current.requestVideoFrameCallback((_, info) => {
|
|
38
|
+
const differenceFromRequested = Math.abs(info.mediaTime - requestedTime);
|
|
39
|
+
if (differenceFromRequested > 0.5) {
|
|
40
|
+
onVariableFpsVideoDetected();
|
|
41
|
+
}
|
|
38
42
|
// Safari often seeks and then stalls.
|
|
39
43
|
// This makes sure that the video actually starts playing.
|
|
40
44
|
current.requestVideoFrameCallback(() => {
|
|
@@ -43,7 +47,7 @@ const useBufferUntilFirstFrame = ({ mediaRef, mediaType, }) => {
|
|
|
43
47
|
});
|
|
44
48
|
current.addEventListener('ended', onEndedOrPause, { once: true });
|
|
45
49
|
current.addEventListener('pause', onEndedOrPause, { once: true });
|
|
46
|
-
}, [delayPlayback, mediaRef, mediaType]);
|
|
50
|
+
}, [delayPlayback, mediaRef, mediaType, onVariableFpsVideoDetected]);
|
|
47
51
|
return (0, react_1.useMemo)(() => {
|
|
48
52
|
return {
|
|
49
53
|
isBuffering: () => bufferingRef.current,
|
|
@@ -31,6 +31,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
31
31
|
const buffering = (0, react_1.useContext)(buffering_js_1.BufferingContextReact);
|
|
32
32
|
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
33
33
|
const mediaStartsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
|
|
34
|
+
const lastSeekDueToShift = (0, react_1.useRef)(null);
|
|
34
35
|
if (!buffering) {
|
|
35
36
|
throw new Error('useMediaPlayback must be used inside a <BufferingContext>');
|
|
36
37
|
}
|
|
@@ -46,9 +47,21 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
46
47
|
shouldBuffer: pauseWhenBuffering,
|
|
47
48
|
isPremounting,
|
|
48
49
|
});
|
|
50
|
+
const isVariableFpsVideoMap = (0, react_1.useRef)({});
|
|
51
|
+
const onVariableFpsVideoDetected = (0, react_1.useCallback)(() => {
|
|
52
|
+
if (!src) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (debugSeeking) {
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.log(`Detected ${src} as a variable FPS video. Disabling buffering while seeking.`);
|
|
58
|
+
}
|
|
59
|
+
isVariableFpsVideoMap.current[src] = true;
|
|
60
|
+
}, [debugSeeking, src]);
|
|
49
61
|
const { bufferUntilFirstFrame, isBuffering } = (0, buffer_until_first_frame_js_1.useBufferUntilFirstFrame)({
|
|
50
62
|
mediaRef,
|
|
51
63
|
mediaType,
|
|
64
|
+
onVariableFpsVideoDetected,
|
|
52
65
|
});
|
|
53
66
|
const playbackRate = localPlaybackRate * globalPlaybackRate;
|
|
54
67
|
// For short audio, a lower acceptable time shift is used
|
|
@@ -94,31 +107,42 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
94
107
|
const shouldBeTime = !Number.isNaN(duration) && Number.isFinite(duration)
|
|
95
108
|
? Math.min(duration, desiredUnclampedTime)
|
|
96
109
|
: desiredUnclampedTime;
|
|
97
|
-
const
|
|
110
|
+
const mediaTagTime = mediaRef.current.currentTime;
|
|
98
111
|
const rvcTime = (_a = currentTime.current) !== null && _a !== void 0 ? _a : null;
|
|
99
|
-
const
|
|
112
|
+
const isVariableFpsVideo = isVariableFpsVideoMap.current[src];
|
|
113
|
+
const timeShiftMediaTag = Math.abs(shouldBeTime - mediaTagTime);
|
|
100
114
|
const timeShiftRvcTag = rvcTime ? Math.abs(shouldBeTime - rvcTime) : null;
|
|
101
|
-
const timeShift = timeShiftRvcTag
|
|
115
|
+
const timeShift = timeShiftRvcTag && !isVariableFpsVideo
|
|
116
|
+
? timeShiftRvcTag
|
|
117
|
+
: timeShiftMediaTag;
|
|
102
118
|
if (debugSeeking) {
|
|
103
119
|
// eslint-disable-next-line no-console
|
|
104
120
|
console.log({
|
|
105
|
-
|
|
121
|
+
mediaTagTime,
|
|
106
122
|
rvcTime,
|
|
107
123
|
shouldBeTime,
|
|
108
124
|
state: mediaRef.current.readyState,
|
|
109
125
|
playing: !mediaRef.current.paused,
|
|
126
|
+
isVariableFpsVideo,
|
|
110
127
|
});
|
|
111
128
|
}
|
|
112
|
-
if (timeShift > acceptableTimeShiftButLessThanDuration
|
|
129
|
+
if (timeShift > acceptableTimeShiftButLessThanDuration &&
|
|
130
|
+
lastSeekDueToShift.current !== shouldBeTime) {
|
|
113
131
|
// If scrubbing around, adjust timing
|
|
114
132
|
// or if time shift is bigger than 0.45sec
|
|
115
133
|
if (debugSeeking) {
|
|
116
134
|
// eslint-disable-next-line no-console
|
|
117
|
-
console.log('Seeking', {
|
|
135
|
+
console.log('Seeking', {
|
|
136
|
+
shouldBeTime,
|
|
137
|
+
isTime: mediaTagTime,
|
|
138
|
+
rvcTime,
|
|
139
|
+
timeShift,
|
|
140
|
+
});
|
|
118
141
|
}
|
|
119
142
|
seek(mediaRef, shouldBeTime);
|
|
120
|
-
|
|
121
|
-
|
|
143
|
+
lastSeekDueToShift.current = shouldBeTime;
|
|
144
|
+
if (playing && !isVariableFpsVideo) {
|
|
145
|
+
bufferUntilFirstFrame(shouldBeTime);
|
|
122
146
|
if (mediaRef.current.paused) {
|
|
123
147
|
(0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)(mediaRef, mediaType);
|
|
124
148
|
}
|
|
@@ -150,7 +174,9 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
|
|
|
150
174
|
seek(mediaRef, shouldBeTime);
|
|
151
175
|
}
|
|
152
176
|
(0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)(mediaRef, mediaType);
|
|
153
|
-
|
|
177
|
+
if (!isVariableFpsVideo) {
|
|
178
|
+
bufferUntilFirstFrame(shouldBeTime);
|
|
179
|
+
}
|
|
154
180
|
}
|
|
155
181
|
}, [
|
|
156
182
|
absoluteFrame,
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -138,7 +138,7 @@ function truthy(value) {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// src/version.ts
|
|
141
|
-
var VERSION = "4.0.
|
|
141
|
+
var VERSION = "4.0.177";
|
|
142
142
|
|
|
143
143
|
// src/multiple-versions-warning.ts
|
|
144
144
|
var checkMultipleRemotionVersions = () => {
|
|
@@ -1611,7 +1611,7 @@ var Artifact = ({ filename, content }) => {
|
|
|
1611
1611
|
return null;
|
|
1612
1612
|
};
|
|
1613
1613
|
// src/audio/Audio.tsx
|
|
1614
|
-
import {forwardRef as forwardRef5, useCallback as
|
|
1614
|
+
import {forwardRef as forwardRef5, useCallback as useCallback9, useContext as useContext23} from "react";
|
|
1615
1615
|
|
|
1616
1616
|
// src/absolute-src.ts
|
|
1617
1617
|
var getAbsoluteSrc = (relativeSrc) => {
|
|
@@ -2005,7 +2005,7 @@ useContext as useContext21,
|
|
|
2005
2005
|
useEffect as useEffect16,
|
|
2006
2006
|
useImperativeHandle as useImperativeHandle3,
|
|
2007
2007
|
useMemo as useMemo20,
|
|
2008
|
-
useRef as
|
|
2008
|
+
useRef as useRef8,
|
|
2009
2009
|
useState as useState14
|
|
2010
2010
|
} from "react";
|
|
2011
2011
|
|
|
@@ -2262,7 +2262,7 @@ var useMediaInTimeline = ({
|
|
|
2262
2262
|
};
|
|
2263
2263
|
|
|
2264
2264
|
// src/use-media-playback.ts
|
|
2265
|
-
import {useContext as useContext18, useEffect as useEffect12} from "react";
|
|
2265
|
+
import {useCallback as useCallback7, useContext as useContext18, useEffect as useEffect12, useRef as useRef6} from "react";
|
|
2266
2266
|
|
|
2267
2267
|
// src/buffer-until-first-frame.ts
|
|
2268
2268
|
import {useCallback as useCallback6, useMemo as useMemo17, useRef as useRef3} from "react";
|
|
@@ -2353,11 +2353,12 @@ var useBufferState = () => {
|
|
|
2353
2353
|
// src/buffer-until-first-frame.ts
|
|
2354
2354
|
var useBufferUntilFirstFrame = ({
|
|
2355
2355
|
mediaRef,
|
|
2356
|
-
mediaType
|
|
2356
|
+
mediaType,
|
|
2357
|
+
onVariableFpsVideoDetected
|
|
2357
2358
|
}) => {
|
|
2358
2359
|
const bufferingRef = useRef3(false);
|
|
2359
2360
|
const { delayPlayback } = useBufferState();
|
|
2360
|
-
const bufferUntilFirstFrame = useCallback6(() => {
|
|
2361
|
+
const bufferUntilFirstFrame = useCallback6((requestedTime) => {
|
|
2361
2362
|
if (mediaType !== "video") {
|
|
2362
2363
|
return;
|
|
2363
2364
|
}
|
|
@@ -2383,14 +2384,18 @@ var useBufferUntilFirstFrame = ({
|
|
|
2383
2384
|
const onEndedOrPause = () => {
|
|
2384
2385
|
unblock();
|
|
2385
2386
|
};
|
|
2386
|
-
current.requestVideoFrameCallback(() => {
|
|
2387
|
+
current.requestVideoFrameCallback((_, info) => {
|
|
2388
|
+
const differenceFromRequested = Math.abs(info.mediaTime - requestedTime);
|
|
2389
|
+
if (differenceFromRequested > 0.5) {
|
|
2390
|
+
onVariableFpsVideoDetected();
|
|
2391
|
+
}
|
|
2387
2392
|
current.requestVideoFrameCallback(() => {
|
|
2388
2393
|
unblock();
|
|
2389
2394
|
});
|
|
2390
2395
|
});
|
|
2391
2396
|
current.addEventListener("ended", onEndedOrPause, { once: true });
|
|
2392
2397
|
current.addEventListener("pause", onEndedOrPause, { once: true });
|
|
2393
|
-
}, [delayPlayback, mediaRef, mediaType]);
|
|
2398
|
+
}, [delayPlayback, mediaRef, mediaType, onVariableFpsVideoDetected]);
|
|
2394
2399
|
return useMemo17(() => {
|
|
2395
2400
|
return {
|
|
2396
2401
|
isBuffering: () => bufferingRef.current,
|
|
@@ -2783,6 +2788,7 @@ var useMediaPlayback = ({
|
|
|
2783
2788
|
const buffering3 = useContext18(BufferingContextReact);
|
|
2784
2789
|
const { fps } = useVideoConfig();
|
|
2785
2790
|
const mediaStartsAt = useMediaStartsAt();
|
|
2791
|
+
const lastSeekDueToShift = useRef6(null);
|
|
2786
2792
|
if (!buffering3) {
|
|
2787
2793
|
throw new Error("useMediaPlayback must be used inside a <BufferingContext>");
|
|
2788
2794
|
}
|
|
@@ -2798,9 +2804,20 @@ var useMediaPlayback = ({
|
|
|
2798
2804
|
shouldBuffer: pauseWhenBuffering,
|
|
2799
2805
|
isPremounting
|
|
2800
2806
|
});
|
|
2807
|
+
const isVariableFpsVideoMap = useRef6({});
|
|
2808
|
+
const onVariableFpsVideoDetected = useCallback7(() => {
|
|
2809
|
+
if (!src) {
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
if (debugSeeking) {
|
|
2813
|
+
console.log(`Detected ${src} as a variable FPS video. Disabling buffering while seeking.`);
|
|
2814
|
+
}
|
|
2815
|
+
isVariableFpsVideoMap.current[src] = true;
|
|
2816
|
+
}, [debugSeeking, src]);
|
|
2801
2817
|
const { bufferUntilFirstFrame, isBuffering } = useBufferUntilFirstFrame({
|
|
2802
2818
|
mediaRef,
|
|
2803
|
-
mediaType
|
|
2819
|
+
mediaType,
|
|
2820
|
+
onVariableFpsVideoDetected
|
|
2804
2821
|
});
|
|
2805
2822
|
const playbackRate = localPlaybackRate * globalPlaybackRate;
|
|
2806
2823
|
const acceptableTimeShiftButLessThanDuration = (() => {
|
|
@@ -2840,27 +2857,35 @@ var useMediaPlayback = ({
|
|
|
2840
2857
|
}
|
|
2841
2858
|
const { duration } = mediaRef.current;
|
|
2842
2859
|
const shouldBeTime = !Number.isNaN(duration) && Number.isFinite(duration) ? Math.min(duration, desiredUnclampedTime) : desiredUnclampedTime;
|
|
2843
|
-
const
|
|
2860
|
+
const mediaTagTime = mediaRef.current.currentTime;
|
|
2844
2861
|
const rvcTime = currentTime.current ?? null;
|
|
2845
|
-
const
|
|
2862
|
+
const isVariableFpsVideo = isVariableFpsVideoMap.current[src];
|
|
2863
|
+
const timeShiftMediaTag = Math.abs(shouldBeTime - mediaTagTime);
|
|
2846
2864
|
const timeShiftRvcTag = rvcTime ? Math.abs(shouldBeTime - rvcTime) : null;
|
|
2847
|
-
const timeShift = timeShiftRvcTag ? timeShiftRvcTag : timeShiftMediaTag;
|
|
2865
|
+
const timeShift = timeShiftRvcTag && !isVariableFpsVideo ? timeShiftRvcTag : timeShiftMediaTag;
|
|
2848
2866
|
if (debugSeeking) {
|
|
2849
2867
|
console.log({
|
|
2850
|
-
|
|
2868
|
+
mediaTagTime,
|
|
2851
2869
|
rvcTime,
|
|
2852
2870
|
shouldBeTime,
|
|
2853
2871
|
state: mediaRef.current.readyState,
|
|
2854
|
-
playing: !mediaRef.current.paused
|
|
2872
|
+
playing: !mediaRef.current.paused,
|
|
2873
|
+
isVariableFpsVideo
|
|
2855
2874
|
});
|
|
2856
2875
|
}
|
|
2857
|
-
if (timeShift > acceptableTimeShiftButLessThanDuration) {
|
|
2876
|
+
if (timeShift > acceptableTimeShiftButLessThanDuration && lastSeekDueToShift.current !== shouldBeTime) {
|
|
2858
2877
|
if (debugSeeking) {
|
|
2859
|
-
console.log("Seeking", {
|
|
2878
|
+
console.log("Seeking", {
|
|
2879
|
+
shouldBeTime,
|
|
2880
|
+
isTime: mediaTagTime,
|
|
2881
|
+
rvcTime,
|
|
2882
|
+
timeShift
|
|
2883
|
+
});
|
|
2860
2884
|
}
|
|
2861
2885
|
seek(mediaRef, shouldBeTime);
|
|
2862
|
-
|
|
2863
|
-
|
|
2886
|
+
lastSeekDueToShift.current = shouldBeTime;
|
|
2887
|
+
if (playing && !isVariableFpsVideo) {
|
|
2888
|
+
bufferUntilFirstFrame(shouldBeTime);
|
|
2864
2889
|
if (mediaRef.current.paused) {
|
|
2865
2890
|
playAndHandleNotAllowedError(mediaRef, mediaType);
|
|
2866
2891
|
}
|
|
@@ -2885,7 +2910,9 @@ var useMediaPlayback = ({
|
|
|
2885
2910
|
seek(mediaRef, shouldBeTime);
|
|
2886
2911
|
}
|
|
2887
2912
|
playAndHandleNotAllowedError(mediaRef, mediaType);
|
|
2888
|
-
|
|
2913
|
+
if (!isVariableFpsVideo) {
|
|
2914
|
+
bufferUntilFirstFrame(shouldBeTime);
|
|
2915
|
+
}
|
|
2889
2916
|
}
|
|
2890
2917
|
}, [
|
|
2891
2918
|
absoluteFrame,
|
|
@@ -2996,11 +3023,11 @@ var useMediaMutedState = () => {
|
|
|
2996
3023
|
import React12, {
|
|
2997
3024
|
createContext as createContext15,
|
|
2998
3025
|
createRef as createRef2,
|
|
2999
|
-
useCallback as
|
|
3026
|
+
useCallback as useCallback8,
|
|
3000
3027
|
useContext as useContext20,
|
|
3001
3028
|
useEffect as useEffect15,
|
|
3002
3029
|
useMemo as useMemo19,
|
|
3003
|
-
useRef as
|
|
3030
|
+
useRef as useRef7,
|
|
3004
3031
|
useState as useState13
|
|
3005
3032
|
} from "react";
|
|
3006
3033
|
import {
|
|
@@ -3035,7 +3062,7 @@ var didPropChange = (key, newProp, prevProp) => {
|
|
|
3035
3062
|
};
|
|
3036
3063
|
var SharedAudioContext = createContext15(null);
|
|
3037
3064
|
var SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) => {
|
|
3038
|
-
const audios =
|
|
3065
|
+
const audios = useRef7([]);
|
|
3039
3066
|
const [initialNumberOfAudioTags] = useState13(numberOfAudioTags);
|
|
3040
3067
|
if (numberOfAudioTags !== initialNumberOfAudioTags) {
|
|
3041
3068
|
throw new Error("The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.");
|
|
@@ -3045,8 +3072,8 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) =>
|
|
|
3045
3072
|
return { id: Math.random(), ref: createRef2() };
|
|
3046
3073
|
});
|
|
3047
3074
|
}, [numberOfAudioTags]);
|
|
3048
|
-
const takenAudios =
|
|
3049
|
-
const rerenderAudios =
|
|
3075
|
+
const takenAudios = useRef7(new Array(numberOfAudioTags).fill(false));
|
|
3076
|
+
const rerenderAudios = useCallback8(() => {
|
|
3050
3077
|
refs.forEach(({ ref, id }) => {
|
|
3051
3078
|
const data = audios.current?.find((a) => a.id === id);
|
|
3052
3079
|
const { current } = ref;
|
|
@@ -3067,7 +3094,7 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) =>
|
|
|
3067
3094
|
});
|
|
3068
3095
|
});
|
|
3069
3096
|
}, [refs]);
|
|
3070
|
-
const registerAudio =
|
|
3097
|
+
const registerAudio = useCallback8((aud, audioId) => {
|
|
3071
3098
|
const found = audios.current?.find((a) => a.audioId === audioId);
|
|
3072
3099
|
if (found) {
|
|
3073
3100
|
return found;
|
|
@@ -3090,7 +3117,7 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) =>
|
|
|
3090
3117
|
rerenderAudios();
|
|
3091
3118
|
return newElem;
|
|
3092
3119
|
}, [numberOfAudioTags, refs, rerenderAudios]);
|
|
3093
|
-
const unregisterAudio =
|
|
3120
|
+
const unregisterAudio = useCallback8((id) => {
|
|
3094
3121
|
const cloned = [...takenAudios.current];
|
|
3095
3122
|
const index = refs.findIndex((r) => r.id === id);
|
|
3096
3123
|
if (index === -1) {
|
|
@@ -3101,7 +3128,7 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) =>
|
|
|
3101
3128
|
audios.current = audios.current?.filter((a) => a.id !== id);
|
|
3102
3129
|
rerenderAudios();
|
|
3103
3130
|
}, [refs, rerenderAudios]);
|
|
3104
|
-
const updateAudio =
|
|
3131
|
+
const updateAudio = useCallback8(({
|
|
3105
3132
|
aud,
|
|
3106
3133
|
audioId,
|
|
3107
3134
|
id
|
|
@@ -3126,7 +3153,7 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) =>
|
|
|
3126
3153
|
rerenderAudios();
|
|
3127
3154
|
}
|
|
3128
3155
|
}, [rerenderAudios]);
|
|
3129
|
-
const playAllAudios =
|
|
3156
|
+
const playAllAudios = useCallback8(() => {
|
|
3130
3157
|
refs.forEach((ref) => {
|
|
3131
3158
|
playAndHandleNotAllowedError(ref.ref, "audio");
|
|
3132
3159
|
});
|
|
@@ -3146,7 +3173,7 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) =>
|
|
|
3146
3173
|
unregisterAudio,
|
|
3147
3174
|
updateAudio
|
|
3148
3175
|
]);
|
|
3149
|
-
const resetAudio =
|
|
3176
|
+
const resetAudio = useCallback8(() => {
|
|
3150
3177
|
takenAudios.current = new Array(numberOfAudioTags).fill(false);
|
|
3151
3178
|
audios.current = [];
|
|
3152
3179
|
rerenderAudios();
|
|
@@ -3307,7 +3334,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
3307
3334
|
useImperativeHandle3(ref, () => {
|
|
3308
3335
|
return audioRef.current;
|
|
3309
3336
|
}, [audioRef]);
|
|
3310
|
-
const currentOnDurationCallback =
|
|
3337
|
+
const currentOnDurationCallback = useRef8();
|
|
3311
3338
|
currentOnDurationCallback.current = onDuration;
|
|
3312
3339
|
useEffect16(() => {
|
|
3313
3340
|
const { current } = audioRef;
|
|
@@ -3345,7 +3372,7 @@ useEffect as useEffect17,
|
|
|
3345
3372
|
useImperativeHandle as useImperativeHandle4,
|
|
3346
3373
|
useLayoutEffect as useLayoutEffect3,
|
|
3347
3374
|
useMemo as useMemo21,
|
|
3348
|
-
useRef as
|
|
3375
|
+
useRef as useRef9
|
|
3349
3376
|
} from "react";
|
|
3350
3377
|
|
|
3351
3378
|
// src/delay-render.ts
|
|
@@ -3420,7 +3447,7 @@ import {
|
|
|
3420
3447
|
jsx as jsx17
|
|
3421
3448
|
} from "react/jsx-runtime";
|
|
3422
3449
|
var AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
3423
|
-
const audioRef =
|
|
3450
|
+
const audioRef = useRef9(null);
|
|
3424
3451
|
const {
|
|
3425
3452
|
volume: volumeProp,
|
|
3426
3453
|
playbackRate,
|
|
@@ -3571,7 +3598,7 @@ var AudioRefForwardingFunction = (props, ref) => {
|
|
|
3571
3598
|
throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
|
|
3572
3599
|
}
|
|
3573
3600
|
const preloadedSrc = usePreload(props.src);
|
|
3574
|
-
const onError =
|
|
3601
|
+
const onError = useCallback9((e) => {
|
|
3575
3602
|
console.log(e.currentTarget.error);
|
|
3576
3603
|
const errMessage = `Could not play audio with src ${preloadedSrc}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
|
|
3577
3604
|
if (loop3) {
|
|
@@ -3580,7 +3607,7 @@ var AudioRefForwardingFunction = (props, ref) => {
|
|
|
3580
3607
|
console.warn(errMessage);
|
|
3581
3608
|
}
|
|
3582
3609
|
}, [loop3, preloadedSrc]);
|
|
3583
|
-
const onDuration =
|
|
3610
|
+
const onDuration = useCallback9((src, durationInSeconds) => {
|
|
3584
3611
|
setDurations({ type: "got-duration", durationInSeconds, src });
|
|
3585
3612
|
}, [setDurations]);
|
|
3586
3613
|
const durationFetched = durations[getAbsoluteSrc(preloadedSrc)] ?? durations[getAbsoluteSrc(props.src)];
|
|
@@ -3959,10 +3986,10 @@ var Composition = ({
|
|
|
3959
3986
|
};
|
|
3960
3987
|
// src/CompositionManager.tsx
|
|
3961
3988
|
import React18, {
|
|
3962
|
-
useCallback as
|
|
3989
|
+
useCallback as useCallback10,
|
|
3963
3990
|
useImperativeHandle as useImperativeHandle5,
|
|
3964
3991
|
useMemo as useMemo25,
|
|
3965
|
-
useRef as
|
|
3992
|
+
useRef as useRef10,
|
|
3966
3993
|
useState as useState15
|
|
3967
3994
|
} from "react";
|
|
3968
3995
|
import {
|
|
@@ -3971,18 +3998,18 @@ jsx as jsx22
|
|
|
3971
3998
|
var compositionsRef = React18.createRef();
|
|
3972
3999
|
var CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
3973
4000
|
const [compositions, setCompositions] = useState15([]);
|
|
3974
|
-
const currentcompositionsRef =
|
|
4001
|
+
const currentcompositionsRef = useRef10(compositions);
|
|
3975
4002
|
const [folders, setFolders] = useState15([]);
|
|
3976
4003
|
const [canvasContent, setCanvasContent] = useState15(null);
|
|
3977
4004
|
const [currentCompositionMetadata, setCurrentCompositionMetadata] = useState15(null);
|
|
3978
|
-
const updateCompositions =
|
|
4005
|
+
const updateCompositions = useCallback10((updateComps) => {
|
|
3979
4006
|
setCompositions((comps) => {
|
|
3980
4007
|
const updated = updateComps(comps);
|
|
3981
4008
|
currentcompositionsRef.current = updated;
|
|
3982
4009
|
return updated;
|
|
3983
4010
|
});
|
|
3984
4011
|
}, []);
|
|
3985
|
-
const registerComposition =
|
|
4012
|
+
const registerComposition = useCallback10((comp) => {
|
|
3986
4013
|
updateCompositions((comps) => {
|
|
3987
4014
|
if (comps.find((c) => c.id === comp.id)) {
|
|
3988
4015
|
throw new Error(`Multiple composition with id ${comp.id} are registered.`);
|
|
@@ -3991,12 +4018,12 @@ var CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
3991
4018
|
return value;
|
|
3992
4019
|
});
|
|
3993
4020
|
}, [updateCompositions]);
|
|
3994
|
-
const unregisterComposition =
|
|
4021
|
+
const unregisterComposition = useCallback10((id) => {
|
|
3995
4022
|
setCompositions((comps) => {
|
|
3996
4023
|
return comps.filter((c) => c.id !== id);
|
|
3997
4024
|
});
|
|
3998
4025
|
}, []);
|
|
3999
|
-
const registerFolder =
|
|
4026
|
+
const registerFolder = useCallback10((name, parent) => {
|
|
4000
4027
|
setFolders((prevFolders) => {
|
|
4001
4028
|
return [
|
|
4002
4029
|
...prevFolders,
|
|
@@ -4007,7 +4034,7 @@ var CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
4007
4034
|
];
|
|
4008
4035
|
});
|
|
4009
4036
|
}, []);
|
|
4010
|
-
const unregisterFolder =
|
|
4037
|
+
const unregisterFolder = useCallback10((name, parent) => {
|
|
4011
4038
|
setFolders((prevFolders) => {
|
|
4012
4039
|
return prevFolders.filter((p) => !(p.name === name && p.parent === parent));
|
|
4013
4040
|
});
|
|
@@ -4018,7 +4045,7 @@ var CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
4018
4045
|
};
|
|
4019
4046
|
}, []);
|
|
4020
4047
|
const composition = compositions.find((c) => canvasContent?.type === "composition" ? c.id === canvasContent.compositionId : null);
|
|
4021
|
-
const updateCompositionDefaultProps =
|
|
4048
|
+
const updateCompositionDefaultProps = useCallback10((id, newDefaultProps) => {
|
|
4022
4049
|
setCompositions((comps) => {
|
|
4023
4050
|
const updated = comps.map((c) => {
|
|
4024
4051
|
if (c.id === id) {
|
|
@@ -4286,7 +4313,7 @@ var getStaticFiles = () => {
|
|
|
4286
4313
|
return window.remotion_staticFiles;
|
|
4287
4314
|
};
|
|
4288
4315
|
// src/IFrame.tsx
|
|
4289
|
-
import {forwardRef as forwardRef6, useCallback as
|
|
4316
|
+
import {forwardRef as forwardRef6, useCallback as useCallback11, useState as useState16} from "react";
|
|
4290
4317
|
import {
|
|
4291
4318
|
jsx as jsx23
|
|
4292
4319
|
} from "react/jsx-runtime";
|
|
@@ -4301,11 +4328,11 @@ var IFrameRefForwarding = ({
|
|
|
4301
4328
|
retries: delayRenderRetries ?? undefined,
|
|
4302
4329
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds ?? undefined
|
|
4303
4330
|
}));
|
|
4304
|
-
const didLoad =
|
|
4331
|
+
const didLoad = useCallback11((e) => {
|
|
4305
4332
|
continueRender(handle);
|
|
4306
4333
|
onLoad?.(e);
|
|
4307
4334
|
}, [handle, onLoad]);
|
|
4308
|
-
const didGetError =
|
|
4335
|
+
const didGetError = useCallback11((e) => {
|
|
4309
4336
|
continueRender(handle);
|
|
4310
4337
|
if (onError) {
|
|
4311
4338
|
onError(e);
|
|
@@ -4324,11 +4351,11 @@ var IFrame = forwardRef6(IFrameRefForwarding);
|
|
|
4324
4351
|
// src/Img.tsx
|
|
4325
4352
|
import {
|
|
4326
4353
|
forwardRef as forwardRef7,
|
|
4327
|
-
useCallback as
|
|
4354
|
+
useCallback as useCallback12,
|
|
4328
4355
|
useContext as useContext26,
|
|
4329
4356
|
useImperativeHandle as useImperativeHandle6,
|
|
4330
4357
|
useLayoutEffect as useLayoutEffect4,
|
|
4331
|
-
useRef as
|
|
4358
|
+
useRef as useRef11
|
|
4332
4359
|
} from "react";
|
|
4333
4360
|
var exponentialBackoff = function(errorCount) {
|
|
4334
4361
|
return 1000 * 2 ** (errorCount - 1);
|
|
@@ -4345,8 +4372,8 @@ var ImgRefForwarding = ({
|
|
|
4345
4372
|
delayRenderTimeoutInMilliseconds,
|
|
4346
4373
|
...props2
|
|
4347
4374
|
}, ref) => {
|
|
4348
|
-
const imageRef =
|
|
4349
|
-
const errors =
|
|
4375
|
+
const imageRef = useRef11(null);
|
|
4376
|
+
const errors = useRef11({});
|
|
4350
4377
|
const { delayPlayback } = useBufferState();
|
|
4351
4378
|
const sequenceContext = useContext26(SequenceContext);
|
|
4352
4379
|
if (!src) {
|
|
@@ -4356,7 +4383,7 @@ var ImgRefForwarding = ({
|
|
|
4356
4383
|
return imageRef.current;
|
|
4357
4384
|
}, []);
|
|
4358
4385
|
const actualSrc = usePreload(src);
|
|
4359
|
-
const retryIn =
|
|
4386
|
+
const retryIn = useCallback12((timeout) => {
|
|
4360
4387
|
if (!imageRef.current) {
|
|
4361
4388
|
return;
|
|
4362
4389
|
}
|
|
@@ -4373,7 +4400,7 @@ var ImgRefForwarding = ({
|
|
|
4373
4400
|
imageRef.current.setAttribute("src", newSrc);
|
|
4374
4401
|
}, timeout);
|
|
4375
4402
|
}, []);
|
|
4376
|
-
const didGetError =
|
|
4403
|
+
const didGetError = useCallback12((e) => {
|
|
4377
4404
|
if (!errors.current) {
|
|
4378
4405
|
return;
|
|
4379
4406
|
}
|
|
@@ -4547,7 +4574,7 @@ import {
|
|
|
4547
4574
|
useEffect as useEffect20,
|
|
4548
4575
|
useLayoutEffect as useLayoutEffect5,
|
|
4549
4576
|
useMemo as useMemo26,
|
|
4550
|
-
useRef as
|
|
4577
|
+
useRef as useRef12,
|
|
4551
4578
|
useState as useState17
|
|
4552
4579
|
} from "react";
|
|
4553
4580
|
import {
|
|
@@ -4557,10 +4584,10 @@ var RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
4557
4584
|
const [remotionRootId] = useState17(() => String(random(null)));
|
|
4558
4585
|
const [frame, setFrame] = useState17(() => getInitialFrameState());
|
|
4559
4586
|
const [playing, setPlaying] = useState17(false);
|
|
4560
|
-
const imperativePlaying =
|
|
4587
|
+
const imperativePlaying = useRef12(false);
|
|
4561
4588
|
const [fastRefreshes, setFastRefreshes] = useState17(0);
|
|
4562
4589
|
const [playbackRate, setPlaybackRate] = useState17(1);
|
|
4563
|
-
const audioAndVideoTags =
|
|
4590
|
+
const audioAndVideoTags = useRef12([]);
|
|
4564
4591
|
if (typeof window !== "undefined") {
|
|
4565
4592
|
useLayoutEffect5(() => {
|
|
4566
4593
|
window.remotion_setFrame = (f, composition, attempt) => {
|
|
@@ -5658,10 +5685,10 @@ var Still = (props2) => {
|
|
|
5658
5685
|
return React27.createElement(Composition, newProps);
|
|
5659
5686
|
};
|
|
5660
5687
|
// src/video/OffthreadVideo.tsx
|
|
5661
|
-
import {useCallback as
|
|
5688
|
+
import {useCallback as useCallback14} from "react";
|
|
5662
5689
|
|
|
5663
5690
|
// src/video/OffthreadVideoForRendering.tsx
|
|
5664
|
-
import {useCallback as
|
|
5691
|
+
import {useCallback as useCallback13, useContext as useContext27, useEffect as useEffect21, useMemo as useMemo29} from "react";
|
|
5665
5692
|
import {
|
|
5666
5693
|
jsx as jsx29
|
|
5667
5694
|
} from "react/jsx-runtime";
|
|
@@ -5759,7 +5786,7 @@ var OffthreadVideoForRendering = ({
|
|
|
5759
5786
|
toneMapped
|
|
5760
5787
|
});
|
|
5761
5788
|
}, [toneMapped, currentTime, src, transparent]);
|
|
5762
|
-
const onErr =
|
|
5789
|
+
const onErr = useCallback13((e) => {
|
|
5763
5790
|
if (onError) {
|
|
5764
5791
|
onError?.(e);
|
|
5765
5792
|
} else {
|
|
@@ -5784,14 +5811,14 @@ useContext as useContext28,
|
|
|
5784
5811
|
useEffect as useEffect22,
|
|
5785
5812
|
useImperativeHandle as useImperativeHandle7,
|
|
5786
5813
|
useMemo as useMemo30,
|
|
5787
|
-
useRef as
|
|
5814
|
+
useRef as useRef13,
|
|
5788
5815
|
useState as useState18
|
|
5789
5816
|
} from "react";
|
|
5790
5817
|
import {
|
|
5791
5818
|
jsx as jsx30
|
|
5792
5819
|
} from "react/jsx-runtime";
|
|
5793
5820
|
var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
|
|
5794
|
-
const videoRef =
|
|
5821
|
+
const videoRef = useRef13(null);
|
|
5795
5822
|
const {
|
|
5796
5823
|
volume,
|
|
5797
5824
|
muted,
|
|
@@ -5887,7 +5914,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
|
|
|
5887
5914
|
current.removeEventListener("error", errorHandler);
|
|
5888
5915
|
};
|
|
5889
5916
|
}, [props2.onError, src]);
|
|
5890
|
-
const currentOnDurationCallback =
|
|
5917
|
+
const currentOnDurationCallback = useRef13();
|
|
5891
5918
|
currentOnDurationCallback.current = onDuration;
|
|
5892
5919
|
useEffect22(() => {
|
|
5893
5920
|
const { current } = videoRef;
|
|
@@ -5950,7 +5977,7 @@ var OffthreadVideo = (props2) => {
|
|
|
5950
5977
|
...otherProps
|
|
5951
5978
|
} = props2;
|
|
5952
5979
|
const environment = getRemotionEnvironment();
|
|
5953
|
-
const onDuration =
|
|
5980
|
+
const onDuration = useCallback14(() => {
|
|
5954
5981
|
return;
|
|
5955
5982
|
}, []);
|
|
5956
5983
|
if (typeof props2.src !== "string") {
|
|
@@ -5999,7 +6026,7 @@ var OffthreadVideo = (props2) => {
|
|
|
5999
6026
|
});
|
|
6000
6027
|
};
|
|
6001
6028
|
// src/video/Video.tsx
|
|
6002
|
-
import {forwardRef as forwardRef11, useCallback as
|
|
6029
|
+
import {forwardRef as forwardRef11, useCallback as useCallback15, useContext as useContext30} from "react";
|
|
6003
6030
|
|
|
6004
6031
|
// src/video/VideoForRendering.tsx
|
|
6005
6032
|
import {
|
|
@@ -6009,7 +6036,7 @@ useEffect as useEffect23,
|
|
|
6009
6036
|
useImperativeHandle as useImperativeHandle8,
|
|
6010
6037
|
useLayoutEffect as useLayoutEffect6,
|
|
6011
6038
|
useMemo as useMemo31,
|
|
6012
|
-
useRef as
|
|
6039
|
+
useRef as useRef14
|
|
6013
6040
|
} from "react";
|
|
6014
6041
|
|
|
6015
6042
|
// src/video/seek-until-right.ts
|
|
@@ -6121,7 +6148,7 @@ var VideoForRenderingForwardFunction = ({
|
|
|
6121
6148
|
const frame = useCurrentFrame();
|
|
6122
6149
|
const volumePropsFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
|
|
6123
6150
|
const videoConfig = useUnsafeVideoConfig();
|
|
6124
|
-
const videoRef =
|
|
6151
|
+
const videoRef = useRef14(null);
|
|
6125
6152
|
const sequenceContext = useContext29(SequenceContext);
|
|
6126
6153
|
const mediaStartsAt = useMediaStartsAt();
|
|
6127
6154
|
const environment = getRemotionEnvironment();
|
|
@@ -6319,7 +6346,7 @@ var VideoForwardingFunction = (props2, ref) => {
|
|
|
6319
6346
|
throw new TypeError(`The \`<Video>\` tag requires a string for \`src\`, but got ${JSON.stringify(props2.src)} instead.`);
|
|
6320
6347
|
}
|
|
6321
6348
|
const preloadedSrc = usePreload(props2.src);
|
|
6322
|
-
const onDuration =
|
|
6349
|
+
const onDuration = useCallback15((src, durationInSeconds) => {
|
|
6323
6350
|
setDurations({ type: "got-duration", durationInSeconds, src });
|
|
6324
6351
|
}, [setDurations]);
|
|
6325
6352
|
const durationFetched = durations[getAbsoluteSrc(preloadedSrc)] ?? durations[getAbsoluteSrc(props2.src)];
|
package/dist/esm/version.mjs
CHANGED