remotion 4.0.519 → 4.0.521

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.
Files changed (61) hide show
  1. package/THIRD_PARTY_LICENSES.md +28 -0
  2. package/dist/cjs/AbsoluteFill.d.ts +3 -15
  3. package/dist/cjs/Composition.js +5 -5
  4. package/dist/cjs/CompositionManager.d.ts +2 -3
  5. package/dist/cjs/CompositionManagerContext.d.ts +1 -2
  6. package/dist/cjs/CompositionManagerProvider.js +119 -5
  7. package/dist/cjs/Folder.d.ts +1 -2
  8. package/dist/cjs/Folder.js +6 -5
  9. package/dist/cjs/Img.d.ts +1 -0
  10. package/dist/cjs/Img.js +1 -0
  11. package/dist/cjs/Interactive.d.ts +3 -15
  12. package/dist/cjs/RemotionRoot.js +1 -8
  13. package/dist/cjs/Sequence.js +47 -60
  14. package/dist/cjs/SequenceManager.d.ts +1 -0
  15. package/dist/cjs/SequenceManager.js +85 -3
  16. package/dist/cjs/TimelineContext.d.ts +14 -8
  17. package/dist/cjs/TimelineContext.js +40 -23
  18. package/dist/cjs/animated-image/AnimatedImage.d.ts +1 -0
  19. package/dist/cjs/animated-image/AnimatedImage.js +1 -0
  20. package/dist/cjs/audio/AudioForPreview.js +6 -2
  21. package/dist/cjs/audio/shared-audio-tags.d.ts +1 -0
  22. package/dist/cjs/audio/shared-audio-tags.js +10 -1
  23. package/dist/cjs/audio/wait-until-actually-resumed.d.ts +1 -1
  24. package/dist/cjs/audio/wait-until-actually-resumed.js +16 -14
  25. package/dist/cjs/buffering.d.ts +3 -19
  26. package/dist/cjs/buffering.js +16 -77
  27. package/dist/cjs/canvas-image/CanvasImage.d.ts +1 -0
  28. package/dist/cjs/canvas-image/CanvasImage.js +1 -0
  29. package/dist/cjs/freeze.js +1 -4
  30. package/dist/cjs/index.d.ts +0 -1
  31. package/dist/cjs/interactivity-schema.d.ts +11 -16
  32. package/dist/cjs/interactivity-schema.js +3 -15
  33. package/dist/cjs/internals.d.ts +18 -45
  34. package/dist/cjs/internals.js +12 -4
  35. package/dist/cjs/runtime-value-store.d.ts +7 -7
  36. package/dist/cjs/runtime-value-store.js +1 -1
  37. package/dist/cjs/sequence-order-marker.d.ts +57 -0
  38. package/dist/cjs/sequence-order-marker.js +44 -0
  39. package/dist/cjs/timeline-position-state.d.ts +2 -8
  40. package/dist/cjs/timeline-position-state.js +5 -7
  41. package/dist/cjs/use-buffer-state.js +1 -3
  42. package/dist/cjs/use-buffering.d.ts +1 -0
  43. package/dist/cjs/use-buffering.js +11 -0
  44. package/dist/cjs/use-media-in-timeline.d.ts +0 -1
  45. package/dist/cjs/use-media-in-timeline.js +15 -29
  46. package/dist/cjs/use-media-playback.js +48 -56
  47. package/dist/cjs/use-media-tag.js +25 -3
  48. package/dist/cjs/use-playing.d.ts +1 -0
  49. package/dist/cjs/use-playing.js +14 -0
  50. package/dist/cjs/use-sequence-registration.d.ts +5 -0
  51. package/dist/cjs/use-sequence-registration.js +37 -0
  52. package/dist/cjs/use-sync-external-store.d.ts +28 -0
  53. package/dist/cjs/use-sync-external-store.js +116 -0
  54. package/dist/cjs/version.d.ts +1 -1
  55. package/dist/cjs/version.js +1 -1
  56. package/dist/cjs/video/VideoForPreview.js +5 -1
  57. package/dist/cjs/wrap-remotion-context.d.ts +1 -12
  58. package/dist/cjs/wrap-remotion-context.js +1 -8
  59. package/dist/esm/index.mjs +1145 -919
  60. package/dist/esm/version.mjs +1 -1
  61. package/package.json +3 -3
@@ -5,10 +5,10 @@ const react_1 = require("react");
5
5
  const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
6
6
  const get_asset_file_name_js_1 = require("./get-asset-file-name.js");
7
7
  const get_timeline_duration_js_1 = require("./get-timeline-duration.js");
8
- const nonce_js_1 = require("./nonce.js");
9
8
  const SequenceContext_js_1 = require("./SequenceContext.js");
10
9
  const SequenceManager_js_1 = require("./SequenceManager.js");
11
10
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
11
+ const use_sequence_registration_js_1 = require("./use-sequence-registration.js");
12
12
  const use_video_config_js_1 = require("./use-video-config.js");
13
13
  const volume_prop_js_1 = require("./volume-prop.js");
14
14
  const didWarn = {};
@@ -63,14 +63,12 @@ const useBasicMediaInTimeline = ({ volume, mediaVolume, mediaType, src, displayN
63
63
  }
64
64
  }, [initialVolume, mediaType, src, volume]);
65
65
  const doesVolumeChange = typeof volume === 'function';
66
- const nonce = (0, nonce_js_1.useNonce)();
67
66
  const startMediaFrom = 0 - mediaStartsAt + (trimBefore !== null && trimBefore !== void 0 ? trimBefore : 0);
68
67
  const memoizedResult = (0, react_1.useMemo)(() => {
69
68
  return {
70
69
  volumes,
71
70
  duration,
72
71
  doesVolumeChange,
73
- nonce,
74
72
  finalDisplayName: displayName !== null && displayName !== void 0 ? displayName : (0, get_asset_file_name_js_1.getAssetDisplayName)(src),
75
73
  startMediaFrom,
76
74
  src,
@@ -81,7 +79,6 @@ const useBasicMediaInTimeline = ({ volume, mediaVolume, mediaType, src, displayN
81
79
  volumes,
82
80
  duration,
83
81
  doesVolumeChange,
84
- nonce,
85
82
  displayName,
86
83
  src,
87
84
  startMediaFrom,
@@ -92,13 +89,13 @@ const useBasicMediaInTimeline = ({ volume, mediaVolume, mediaType, src, displayN
92
89
  };
93
90
  exports.useBasicMediaInTimeline = useBasicMediaInTimeline;
94
91
  const useMediaInTimeline = ({ volume, mediaVolume, src, mediaType, playbackRate, displayName, id, getStack, showInTimeline, premountDisplay, postmountDisplay, loopDisplay, documentationLink, refForOutline, muted, }) => {
92
+ var _a, _b;
95
93
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
96
94
  const startsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
97
- const { registerSequence, unregisterSequence } = (0, react_1.useContext)(SequenceManager_js_1.SequenceManager);
98
95
  const sequenceRegistrationEnabled = (0, react_1.useContext)(SequenceManager_js_1.SequenceRegistrationContext);
99
96
  const { durationInFrames } = (0, use_video_config_js_1.useVideoConfig)();
100
97
  const mediaStartsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
101
- const { volumes, duration, doesVolumeChange, nonce, finalDisplayName } = (0, exports.useBasicMediaInTimeline)({
98
+ const { volumes, duration, doesVolumeChange, finalDisplayName } = (0, exports.useBasicMediaInTimeline)({
102
99
  volume,
103
100
  mediaVolume,
104
101
  mediaType,
@@ -113,21 +110,12 @@ const useMediaInTimeline = ({ volume, mediaVolume, src, mediaType, playbackRate,
113
110
  muted,
114
111
  });
115
112
  const { isStudio } = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
116
- (0, react_1.useEffect)(() => {
117
- var _a, _b;
118
- var _c;
113
+ const getSequenceForRegistration = (0, react_1.useCallback)(() => {
114
+ var _a;
119
115
  if (!src) {
120
116
  throw new Error('No src passed');
121
117
  }
122
- if (!isStudio &&
123
- !sequenceRegistrationEnabled &&
124
- ((_b = (_a = window.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.NODE_ENV) !== 'test') {
125
- return;
126
- }
127
- if (!showInTimeline) {
128
- return;
129
- }
130
- registerSequence({
118
+ return {
131
119
  effectRuntimeValues: null,
132
120
  type: mediaType,
133
121
  src,
@@ -135,13 +123,13 @@ const useMediaInTimeline = ({ volume, mediaVolume, src, mediaType, playbackRate,
135
123
  duration,
136
124
  from: 0,
137
125
  trimBefore: null,
138
- parent: (_c = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _c !== void 0 ? _c : null,
126
+ parent: (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _a !== void 0 ? _a : null,
139
127
  displayName: finalDisplayName,
140
128
  documentationLink,
141
129
  volume: volumes,
142
130
  muted,
143
131
  showInTimeline: true,
144
- nonce: nonce.get(),
132
+ timelineOrder: null,
145
133
  startMediaFrom: 0 - startsAt,
146
134
  mediaFrameAtSequenceZero: null,
147
135
  doesVolumeChange,
@@ -156,34 +144,32 @@ const useMediaInTimeline = ({ volume, mediaVolume, src, mediaType, playbackRate,
156
144
  isInsideSeries: false,
157
145
  frozenFrame: null,
158
146
  frozenMediaFrame: null,
159
- });
160
- return () => {
161
- unregisterSequence(id);
162
147
  };
163
148
  }, [
164
149
  duration,
165
150
  id,
166
151
  parentSequence,
167
152
  src,
168
- registerSequence,
169
- unregisterSequence,
170
153
  volumes,
171
154
  doesVolumeChange,
172
- nonce,
173
155
  mediaType,
174
156
  startsAt,
175
157
  playbackRate,
176
158
  getStack,
177
- showInTimeline,
178
159
  premountDisplay,
179
160
  postmountDisplay,
180
161
  loopDisplay,
181
162
  documentationLink,
182
163
  finalDisplayName,
183
- isStudio,
184
- sequenceRegistrationEnabled,
185
164
  refForOutline,
186
165
  muted,
187
166
  ]);
167
+ const registrationEnabled = isStudio ||
168
+ sequenceRegistrationEnabled ||
169
+ (typeof window !== 'undefined' && ((_b = (_a = window.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.NODE_ENV) === 'test');
170
+ (0, use_sequence_registration_js_1.useSequenceRegistration)({
171
+ getSequence: registrationEnabled && showInTimeline ? getSequenceForRegistration : null,
172
+ id,
173
+ });
188
174
  };
189
175
  exports.useMediaInTimeline = useMediaInTimeline;
@@ -4,7 +4,6 @@ exports.useMediaPlayback = void 0;
4
4
  const react_1 = require("react");
5
5
  const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
6
6
  const buffer_until_first_frame_js_1 = require("./buffer-until-first-frame.js");
7
- const buffering_js_1 = require("./buffering.js");
8
7
  const get_media_sync_action_js_1 = require("./get-media-sync-action.js");
9
8
  const log_level_context_js_1 = require("./log-level-context.js");
10
9
  const log_js_1 = require("./log.js");
@@ -13,6 +12,7 @@ const play_and_handle_not_allowed_error_js_1 = require("./play-and-handle-not-al
13
12
  const playback_logging_js_1 = require("./playback-logging.js");
14
13
  const seek_js_1 = require("./seek.js");
15
14
  const timeline_position_state_js_1 = require("./timeline-position-state.js");
15
+ const use_buffering_js_1 = require("./use-buffering.js");
16
16
  const use_current_frame_js_1 = require("./use-current-frame.js");
17
17
  const use_media_buffering_js_1 = require("./use-media-buffering.js");
18
18
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
@@ -20,21 +20,32 @@ const use_request_video_callback_time_js_1 = require("./use-request-video-callba
20
20
  const use_video_config_js_1 = require("./use-video-config.js");
21
21
  const get_current_time_js_1 = require("./video/get-current-time.js");
22
22
  const warn_about_non_seekable_media_js_1 = require("./warn-about-non-seekable-media.js");
23
+ // In Safari, amplified media can lag behind by around 0.4 seconds.
24
+ const DEFAULT_ACCEPTABLE_TIMESHIFT_WITH_AMPLIFICATION = 0.65;
25
+ const getPauseReason = ({ reason, isPremounting, isPostmounting, }) => {
26
+ if (reason === 'buffering') {
27
+ return 'player is buffering but media tag is not';
28
+ }
29
+ if (isPremounting) {
30
+ return 'media is premounting';
31
+ }
32
+ if (isPostmounting) {
33
+ return 'media is postmounting';
34
+ }
35
+ return 'Player is not playing';
36
+ };
23
37
  const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybackRate, preservePitch = true, onlyWarnForMediaSeekingError, acceptableTimeshift, pauseWhenBuffering, isPremounting, isPostmounting, onAutoPlayError, }) => {
24
38
  const { playbackRate: globalPlaybackRate } = (0, timeline_position_state_js_1.usePlaybackRate)();
25
39
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
26
40
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
27
- const [playing] = (0, timeline_position_state_js_1.usePlayingState)();
28
- const buffering = (0, react_1.useContext)(buffering_js_1.BufferingContextReact);
41
+ const playing = (0, timeline_position_state_js_1.usePlaying)();
42
+ const playerBuffering = (0, use_buffering_js_1.useBuffering)();
29
43
  const { fps } = (0, use_video_config_js_1.useVideoConfig)();
30
44
  const mediaStartsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
31
45
  const lastSeekDueToShift = (0, react_1.useRef)(null);
32
46
  const lastSeek = (0, react_1.useRef)(null);
33
47
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
34
48
  const mountTime = (0, log_level_context_js_1.useMountTime)();
35
- if (!buffering) {
36
- throw new Error('useMediaPlayback must be used inside a <BufferingContext>');
37
- }
38
49
  const isVariableFpsVideoMap = (0, react_1.useRef)({});
39
50
  const onVariableFpsVideoDetected = (0, react_1.useCallback)(() => {
40
51
  if (!src) {
@@ -79,62 +90,22 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
79
90
  const playbackRate = localPlaybackRate * globalPlaybackRate;
80
91
  const acceptableTimeShiftButLessThanDuration = (() => {
81
92
  var _a;
82
- // In Safari, it seems to lag behind mostly around ~0.4 seconds
83
- const DEFAULT_ACCEPTABLE_TIMESHIFT_WITH_NORMAL_PLAYBACK = 0.45;
84
- // If there is amplification, the acceptable timeshift is higher
85
- const DEFAULT_ACCEPTABLE_TIMESHIFT_WITH_AMPLIFICATION = DEFAULT_ACCEPTABLE_TIMESHIFT_WITH_NORMAL_PLAYBACK + 0.2;
86
- const defaultAcceptableTimeshift = DEFAULT_ACCEPTABLE_TIMESHIFT_WITH_AMPLIFICATION;
87
93
  // For short audio, a lower acceptable time shift is used
88
94
  if ((_a = mediaRef.current) === null || _a === void 0 ? void 0 : _a.duration) {
89
- return Math.min(mediaRef.current.duration, acceptableTimeshift !== null && acceptableTimeshift !== void 0 ? acceptableTimeshift : defaultAcceptableTimeshift);
95
+ return Math.min(mediaRef.current.duration, acceptableTimeshift !== null && acceptableTimeshift !== void 0 ? acceptableTimeshift : DEFAULT_ACCEPTABLE_TIMESHIFT_WITH_AMPLIFICATION);
90
96
  }
91
- return acceptableTimeshift !== null && acceptableTimeshift !== void 0 ? acceptableTimeshift : defaultAcceptableTimeshift;
97
+ return (acceptableTimeshift !== null && acceptableTimeshift !== void 0 ? acceptableTimeshift : DEFAULT_ACCEPTABLE_TIMESHIFT_WITH_AMPLIFICATION);
92
98
  })();
93
- const isPlayerBuffering = (0, buffering_js_1.useIsPlayerBuffering)(buffering);
94
- (0, react_1.useEffect)(() => {
95
- var _a, _b, _c, _d, _e;
96
- if ((_a = mediaRef.current) === null || _a === void 0 ? void 0 : _a.paused) {
97
- return;
98
- }
99
- if (!playing) {
100
- (0, playback_logging_js_1.playbackLogging)({
101
- logLevel,
102
- tag: 'pause',
103
- message: `Pausing ${(_b = mediaRef.current) === null || _b === void 0 ? void 0 : _b.src} because ${isPremounting ? 'media is premounting' : isPostmounting ? 'media is postmounting' : 'Player is not playing'}`,
104
- mountTime,
105
- });
106
- (_c = mediaRef.current) === null || _c === void 0 ? void 0 : _c.pause();
107
- return;
108
- }
109
- const isMediaTagBufferingOrStalled = isMediaTagBuffering || isBuffering();
110
- const playerBufferingNotStateButLive = buffering.buffering.current;
111
- if (playerBufferingNotStateButLive && !isMediaTagBufferingOrStalled) {
112
- (0, playback_logging_js_1.playbackLogging)({
113
- logLevel,
114
- tag: 'pause',
115
- message: `Pausing ${(_d = mediaRef.current) === null || _d === void 0 ? void 0 : _d.src} because player is buffering but media tag is not`,
116
- mountTime,
117
- });
118
- (_e = mediaRef.current) === null || _e === void 0 ? void 0 : _e.pause();
119
- }
120
- }, [
121
- isBuffering,
122
- isMediaTagBuffering,
123
- buffering,
124
- isPlayerBuffering,
125
- isPremounting,
126
- logLevel,
127
- mediaRef,
128
- mediaType,
129
- mountTime,
130
- playing,
131
- isPostmounting,
132
- ]);
133
99
  const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
134
100
  // This must be a useLayoutEffect, because afterwards, useVolume() looks at the playbackRate
135
101
  // and it is also in a useLayoutEffect.
136
102
  (0, react_1.useLayoutEffect)(() => {
137
103
  const playbackRateToSet = Math.max(0, playbackRate);
104
+ // Loading a resource resets playbackRate to defaultPlaybackRate.
105
+ if (mediaRef.current &&
106
+ mediaRef.current.defaultPlaybackRate !== playbackRateToSet) {
107
+ mediaRef.current.defaultPlaybackRate = playbackRateToSet;
108
+ }
138
109
  if (mediaRef.current &&
139
110
  mediaRef.current.playbackRate !== playbackRateToSet) {
140
111
  mediaRef.current.playbackRate = playbackRateToSet;
@@ -154,6 +125,27 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
154
125
  throw new Error(`No 'src' attribute was passed to the ${tagName} element.`);
155
126
  }
156
127
  const { current } = mediaRef;
128
+ const isMediaTagBufferingOrStalled = isMediaTagBuffering || isBuffering();
129
+ let pauseReason = null;
130
+ if (!playing) {
131
+ pauseReason = 'not-playing';
132
+ }
133
+ else if (playerBuffering && !isMediaTagBufferingOrStalled) {
134
+ pauseReason = 'buffering';
135
+ }
136
+ if (!current.paused && pauseReason !== null) {
137
+ (0, playback_logging_js_1.playbackLogging)({
138
+ logLevel,
139
+ tag: 'pause',
140
+ message: `Pausing ${current.src} because ${getPauseReason({
141
+ reason: pauseReason,
142
+ isPremounting,
143
+ isPostmounting,
144
+ })}`,
145
+ mountTime,
146
+ });
147
+ current.pause();
148
+ }
157
149
  const action = (0, get_media_sync_action_js_1.getMediaSyncAction)({
158
150
  duration: current.duration,
159
151
  currentTime: current.currentTime,
@@ -169,8 +161,8 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
169
161
  lastSeekDueToShift: lastSeekDueToShift.current,
170
162
  playing,
171
163
  playbackRate,
172
- mediaTagBufferingOrStalled: isMediaTagBuffering || isBuffering(),
173
- playerBuffering: buffering.buffering.current,
164
+ mediaTagBufferingOrStalled: isMediaTagBufferingOrStalled,
165
+ playerBuffering,
174
166
  absoluteFrame,
175
167
  onlyWarnForMediaSeekingError,
176
168
  isPremounting,
@@ -246,7 +238,6 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
246
238
  absoluteFrame,
247
239
  acceptableTimeShiftButLessThanDuration,
248
240
  bufferUntilFirstFrame,
249
- buffering.buffering,
250
241
  rvcCurrentTime,
251
242
  logLevel,
252
243
  desiredUnclampedTime,
@@ -256,6 +247,7 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
256
247
  mediaType,
257
248
  onlyWarnForMediaSeekingError,
258
249
  playbackRate,
250
+ playerBuffering,
259
251
  playing,
260
252
  src,
261
253
  onAutoPlayError,
@@ -4,10 +4,15 @@ exports.useMediaTag = void 0;
4
4
  const react_1 = require("react");
5
5
  const log_level_context_js_1 = require("./log-level-context.js");
6
6
  const play_and_handle_not_allowed_error_js_1 = require("./play-and-handle-not-allowed-error.js");
7
+ const playback_logging_js_1 = require("./playback-logging.js");
7
8
  const timeline_position_state_js_1 = require("./timeline-position-state.js");
9
+ const TimelineContext_js_1 = require("./TimelineContext.js");
8
10
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
9
11
  const useMediaTag = ({ mediaRef, id, mediaType, onAutoPlayError, isPremounting, isPostmounting, }) => {
10
- const { audioAndVideoTags, imperativePlaying } = (0, timeline_position_state_js_1.useTimelineContext)();
12
+ const { audioAndVideoTags, isPlaying } = (0, timeline_position_state_js_1.useTimelineContext)();
13
+ const { subscribePlaying } = (0, react_1.useContext)(TimelineContext_js_1.SetTimelineContext);
14
+ const isPlayingRef = (0, react_1.useRef)(isPlaying);
15
+ isPlayingRef.current = isPlaying;
11
16
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
12
17
  const mountTime = (0, log_level_context_js_1.useMountTime)();
13
18
  const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
@@ -15,7 +20,7 @@ const useMediaTag = ({ mediaRef, id, mediaType, onAutoPlayError, isPremounting,
15
20
  const tag = {
16
21
  id,
17
22
  play: (reason) => {
18
- if (!imperativePlaying.current) {
23
+ if (!isPlayingRef.current()) {
19
24
  // Don't play if for example in a <Freeze> state.
20
25
  return;
21
26
  }
@@ -34,7 +39,24 @@ const useMediaTag = ({ mediaRef, id, mediaType, onAutoPlayError, isPremounting,
34
39
  },
35
40
  };
36
41
  audioAndVideoTags.current.push(tag);
42
+ const unsubscribe = subscribePlaying((state) => {
43
+ if (state.playing) {
44
+ return;
45
+ }
46
+ const media = mediaRef.current;
47
+ if (!media || media.paused) {
48
+ return;
49
+ }
50
+ (0, playback_logging_js_1.playbackLogging)({
51
+ logLevel,
52
+ tag: 'pause',
53
+ message: `Pausing ${media.src} because Player is not playing`,
54
+ mountTime,
55
+ });
56
+ media.pause();
57
+ });
37
58
  return () => {
59
+ unsubscribe();
38
60
  audioAndVideoTags.current = audioAndVideoTags.current.filter((a) => a.id !== id);
39
61
  };
40
62
  }, [
@@ -43,12 +65,12 @@ const useMediaTag = ({ mediaRef, id, mediaType, onAutoPlayError, isPremounting,
43
65
  mediaRef,
44
66
  mediaType,
45
67
  onAutoPlayError,
46
- imperativePlaying,
47
68
  isPremounting,
48
69
  isPostmounting,
49
70
  logLevel,
50
71
  mountTime,
51
72
  env.isPlayer,
73
+ subscribePlaying,
52
74
  ]);
53
75
  };
54
76
  exports.useMediaTag = useMediaTag;
@@ -0,0 +1 @@
1
+ export declare const usePlaying: () => boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePlaying = void 0;
4
+ const react_1 = require("react");
5
+ const timeline_position_state_js_1 = require("./timeline-position-state.js");
6
+ const TimelineContext_js_1 = require("./TimelineContext.js");
7
+ const use_sync_external_store_js_1 = require("./use-sync-external-store.js");
8
+ const usePlaying = () => {
9
+ const { isPlaying } = (0, timeline_position_state_js_1.useTimelineContext)();
10
+ const { subscribePlaying } = (0, react_1.useContext)(TimelineContext_js_1.SetTimelineContext);
11
+ // Read the local Freeze override, but subscribe to the shared playing store.
12
+ return (0, use_sync_external_store_js_1.useSyncExternalStore)(subscribePlaying, isPlaying, isPlaying);
13
+ };
14
+ exports.usePlaying = usePlaying;
@@ -0,0 +1,5 @@
1
+ import type { TSequence } from './CompositionManager.js';
2
+ export declare const useSequenceRegistration: ({ getSequence, id, }: {
3
+ getSequence: (() => TSequence) | null;
4
+ id: string;
5
+ }) => void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSequenceRegistration = void 0;
4
+ const react_1 = require("react");
5
+ const SequenceManager_js_1 = require("./SequenceManager.js");
6
+ const useSequenceRegistration = ({ getSequence, id, }) => {
7
+ const { registerSequence, unregisterSequence, updateSequence } = (0, react_1.useContext)(SequenceManager_js_1.SequenceManager);
8
+ const getSequenceRef = (0, react_1.useRef)(getSequence);
9
+ getSequenceRef.current = getSequence;
10
+ const lastRegisteredGetterRef = (0, react_1.useRef)(null);
11
+ const registrationEnabled = getSequence !== null;
12
+ (0, react_1.useEffect)(() => {
13
+ if (!registrationEnabled) {
14
+ return;
15
+ }
16
+ const currentGetter = getSequenceRef.current;
17
+ if (currentGetter === null) {
18
+ throw new Error('Expected a sequence registration getter');
19
+ }
20
+ registerSequence(currentGetter());
21
+ lastRegisteredGetterRef.current = currentGetter;
22
+ return () => {
23
+ lastRegisteredGetterRef.current = null;
24
+ unregisterSequence(id);
25
+ };
26
+ }, [id, registerSequence, registrationEnabled, unregisterSequence]);
27
+ (0, react_1.useEffect)(() => {
28
+ if (getSequence === null ||
29
+ updateSequence === null ||
30
+ lastRegisteredGetterRef.current === getSequence) {
31
+ return;
32
+ }
33
+ updateSequence(getSequence());
34
+ lastRegisteredGetterRef.current = getSequence;
35
+ }, [getSequence, updateSequence]);
36
+ };
37
+ exports.useSequenceRegistration = useSequenceRegistration;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license React
3
+ *
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ *
24
+ * Adapted from use-sync-external-store 1.5.0.
25
+ */
26
+ type UseSyncExternalStore = <TSnapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => TSnapshot, getServerSnapshot?: () => TSnapshot) => TSnapshot;
27
+ export declare const useSyncExternalStore: UseSyncExternalStore;
28
+ export {};
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ /**
3
+ * @license React
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
25
+ * Adapted from use-sync-external-store 1.5.0.
26
+ */
27
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ var desc = Object.getOwnPropertyDescriptor(m, k);
30
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
31
+ desc = { enumerable: true, get: function() { return m[k]; } };
32
+ }
33
+ Object.defineProperty(o, k2, desc);
34
+ }) : (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ o[k2] = m[k];
37
+ }));
38
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
39
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
40
+ }) : function(o, v) {
41
+ o["default"] = v;
42
+ });
43
+ var __importStar = (this && this.__importStar) || (function () {
44
+ var ownKeys = function(o) {
45
+ ownKeys = Object.getOwnPropertyNames || function (o) {
46
+ var ar = [];
47
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
48
+ return ar;
49
+ };
50
+ return ownKeys(o);
51
+ };
52
+ return function (mod) {
53
+ if (mod && mod.__esModule) return mod;
54
+ var result = {};
55
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
56
+ __setModuleDefault(result, mod);
57
+ return result;
58
+ };
59
+ })();
60
+ var _a;
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.useSyncExternalStore = void 0;
63
+ const React = __importStar(require("react"));
64
+ const objectIs = typeof Object.is === 'function'
65
+ ? Object.is
66
+ : (first, second) => (first === second &&
67
+ (first !== 0 || 1 / first === 1 / second)) ||
68
+ (Number.isNaN(first) && Number.isNaN(second));
69
+ let didWarnAboutUncachedGetSnapshot = false;
70
+ const checkIfSnapshotChanged = (instance) => {
71
+ try {
72
+ return !objectIs(instance.value, instance.getSnapshot());
73
+ }
74
+ catch (_a) {
75
+ return true;
76
+ }
77
+ };
78
+ const useSyncExternalStoreShimClient = (subscribe, getSnapshot) => {
79
+ const value = getSnapshot();
80
+ if (process.env.NODE_ENV !== 'production' &&
81
+ !didWarnAboutUncachedGetSnapshot &&
82
+ !objectIs(value, getSnapshot())) {
83
+ // eslint-disable-next-line no-console
84
+ console.error('The result of getSnapshot should be cached to avoid an infinite loop');
85
+ didWarnAboutUncachedGetSnapshot = true;
86
+ }
87
+ const [{ instance }, forceUpdate] = React.useState({
88
+ instance: { value, getSnapshot },
89
+ });
90
+ React.useLayoutEffect(() => {
91
+ instance.value = value;
92
+ instance.getSnapshot = getSnapshot;
93
+ if (checkIfSnapshotChanged(instance)) {
94
+ forceUpdate({ instance });
95
+ }
96
+ }, [getSnapshot, instance, subscribe, value]);
97
+ React.useEffect(() => {
98
+ if (checkIfSnapshotChanged(instance)) {
99
+ forceUpdate({ instance });
100
+ }
101
+ return subscribe(() => {
102
+ if (checkIfSnapshotChanged(instance)) {
103
+ forceUpdate({ instance });
104
+ }
105
+ });
106
+ }, [instance, subscribe]);
107
+ React.useDebugValue(value);
108
+ return value;
109
+ };
110
+ const useSyncExternalStoreShimServer = (_subscribe, getSnapshot) => getSnapshot();
111
+ const shim = typeof window === 'undefined' ||
112
+ typeof window.document === 'undefined' ||
113
+ typeof window.document.createElement === 'undefined'
114
+ ? useSyncExternalStoreShimServer
115
+ : useSyncExternalStoreShimClient;
116
+ exports.useSyncExternalStore = (_a = React.useSyncExternalStore) !== null && _a !== void 0 ? _a : shim;
@@ -3,4 +3,4 @@
3
3
  * @see [Documentation](https://remotion.dev/docs/version)
4
4
  * @returns {string} The current version of the remotion package
5
5
  */
6
- export declare const VERSION = "4.0.519";
6
+ export declare const VERSION = "4.0.521";
@@ -7,4 +7,4 @@ exports.VERSION = void 0;
7
7
  * @see [Documentation](https://remotion.dev/docs/version)
8
8
  * @returns {string} The current version of the remotion package
9
9
  */
10
- exports.VERSION = '4.0.519';
10
+ exports.VERSION = '4.0.521';
@@ -43,11 +43,13 @@ const get_cross_origin_value_js_1 = require("../get-cross-origin-value.js");
43
43
  const log_level_context_js_1 = require("../log-level-context.js");
44
44
  const playback_logging_js_1 = require("../playback-logging.js");
45
45
  const prefetch_js_1 = require("../prefetch.js");
46
+ const sequence_order_marker_js_1 = require("../sequence-order-marker.js");
46
47
  const SequenceContext_js_1 = require("../SequenceContext.js");
47
48
  const use_amplification_js_1 = require("../use-amplification.js");
48
49
  const use_media_in_timeline_js_1 = require("../use-media-in-timeline.js");
49
50
  const use_media_playback_js_1 = require("../use-media-playback.js");
50
51
  const use_media_tag_js_1 = require("../use-media-tag.js");
52
+ const use_remotion_environment_js_1 = require("../use-remotion-environment.js");
51
53
  const use_video_config_js_1 = require("../use-video-config.js");
52
54
  const version_js_1 = require("../version.js");
53
55
  const volume_position_state_js_1 = require("../volume-position-state.js");
@@ -101,6 +103,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
101
103
  const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
102
104
  const { fps, durationInFrames } = (0, use_video_config_js_1.useVideoConfig)();
103
105
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
106
+ const { isStudio } = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
104
107
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
105
108
  const mountTime = (0, log_level_context_js_1.useMountTime)();
106
109
  const [timelineId] = (0, react_1.useState)(() => String(Math.random()));
@@ -281,6 +284,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
281
284
  requestsVideoFrame: Boolean(onVideoFrame),
282
285
  isClientSideRendering: false,
283
286
  });
284
- return (jsx_runtime_1.jsx("video", { ...nativeProps, ref: videoRef, muted: muted || playerMuted || userPreferredVolume <= 0, playsInline: true, src: actualSrc, loop: _remotionInternalNativeLoopPassed, style: actualStyle, disableRemotePlayback: true, crossOrigin: crossOriginValue, controls: false }));
287
+ const video = (jsx_runtime_1.jsx("video", { ...nativeProps, ref: videoRef, muted: muted || playerMuted || userPreferredVolume <= 0, playsInline: true, src: actualSrc, loop: _remotionInternalNativeLoopPassed, style: actualStyle, disableRemotePlayback: true, crossOrigin: crossOriginValue, controls: false }));
288
+ return isStudio ? (jsx_runtime_1.jsx(sequence_order_marker_js_1.SequenceOrderMarker, { sequenceId: timelineId, children: video })) : (video);
285
289
  };
286
290
  exports.VideoForPreview = (0, react_1.forwardRef)(VideoForDevelopmentRefForwardingFunction);
@@ -2,10 +2,8 @@ import React from 'react';
2
2
  export declare function useRemotionContexts(): {
3
3
  compositionManagerCtx: import("./CompositionManagerContext.js").CompositionManagerContext;
4
4
  timelineContext: import("./TimelineContext.js").TimelineContextValue | null;
5
- timelineImperativeContext: import("./TimelineContext.js").TimelineImperativeContextValue | null;
6
5
  setTimelineContext: import("./TimelineContext.js").SetTimelineContextValue;
7
6
  sequenceContext: import("./SequenceContext.js").SequenceContextType | null;
8
- nonceContext: import("./nonce.js").TNonceContext;
9
7
  canUseRemotionHooksContext: boolean;
10
8
  preloadContext: {
11
9
  [x: string]: string;
@@ -31,18 +29,9 @@ export declare function useRemotionContexts(): {
31
29
  sequenceManagerRefContext: import("./SequenceManager.js").SequenceManagerRef;
32
30
  visualModePropStatusesRefContext: import("./SequenceManager.js").VisualModePropStatusesRef;
33
31
  bufferManagerContext: {
34
- addBlock: (block: {
35
- id: string;
36
- }) => {
32
+ addBlock: () => {
37
33
  unblock: () => void;
38
34
  };
39
- listenForBuffering: (callback: () => void) => {
40
- remove: () => void;
41
- };
42
- listenForResume: (callback: () => void) => {
43
- remove: () => void;
44
- };
45
- buffering: React.RefObject<boolean>;
46
35
  } | null;
47
36
  logLevelContext: import("./log-level-context.js").LoggingContextValue;
48
37
  };