remotion 4.0.356 → 4.0.357

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.
@@ -28,7 +28,7 @@ const Fallback = () => {
28
28
  return null;
29
29
  };
30
30
  const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultProps, schema, ...compProps }) => {
31
- var _a, _b;
31
+ var _a, _b, _c;
32
32
  const compManager = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionSetters);
33
33
  const { registerComposition, unregisterComposition } = compManager;
34
34
  const video = (0, use_video_js_1.useVideo)();
@@ -41,6 +41,10 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
41
41
  const isPlayer = (0, is_player_js_1.useIsPlayer)();
42
42
  const environment = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
43
43
  const canUseComposition = (0, react_1.useContext)(CanUseRemotionHooks_js_1.CanUseRemotionHooks);
44
+ // Record seen composition IDs as early as possible so that overlays can access them
45
+ if (typeof window !== 'undefined') {
46
+ window.remotion_seenCompositionIds = Array.from(new Set([...((_a = window.remotion_seenCompositionIds) !== null && _a !== void 0 ? _a : []), id]));
47
+ }
44
48
  if (canUseComposition) {
45
49
  if (isPlayer) {
46
50
  throw new Error('<Composition> was mounted inside the `component` that was passed to the <Player>. See https://remotion.dev/docs/wrong-composition-mount for help.');
@@ -104,7 +108,7 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
104
108
  resolved.type !== 'success-and-refreshing')) {
105
109
  return null;
106
110
  }
107
- return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(loading_indicator_js_1.Loading, {}), children: (0, jsx_runtime_1.jsx)(Comp, { ...((_a = resolved.result.props) !== null && _a !== void 0 ? _a : {}) }) }) }), (0, portal_node_js_1.portalNode)());
111
+ return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(loading_indicator_js_1.Loading, {}), children: (0, jsx_runtime_1.jsx)(Comp, { ...((_b = resolved.result.props) !== null && _b !== void 0 ? _b : {}) }) }) }), (0, portal_node_js_1.portalNode)());
108
112
  }
109
113
  if (environment.isRendering && video && video.component === lazy) {
110
114
  const Comp = lazy;
@@ -113,7 +117,7 @@ const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultPro
113
117
  resolved.type !== 'success-and-refreshing')) {
114
118
  return null;
115
119
  }
116
- return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Fallback, {}), children: (0, jsx_runtime_1.jsx)(Comp, { ...((_b = resolved.result.props) !== null && _b !== void 0 ? _b : {}) }) }) }), (0, portal_node_js_1.portalNode)());
120
+ return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Fallback, {}), children: (0, jsx_runtime_1.jsx)(Comp, { ...((_c = resolved.result.props) !== null && _c !== void 0 ? _c : {}) }) }) }), (0, portal_node_js_1.portalNode)());
117
121
  }
118
122
  return null;
119
123
  };
@@ -75,10 +75,9 @@ export type InlineAudioAsset = {
75
75
  id: string;
76
76
  audio: number[];
77
77
  frame: number;
78
- sampleRate: number;
79
- numberOfChannels: number;
80
78
  timestamp: number;
81
79
  duration: number;
80
+ toneFrequency: number;
82
81
  };
83
82
  type DiscriminatedArtifact = {
84
83
  contentType: 'binary';
@@ -67,10 +67,10 @@ const AudioRefForwardingFunction = (props, ref) => {
67
67
  }
68
68
  const duration = durationFetched * fps;
69
69
  return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { layout: "none", durationInFrames: (0, calculate_loop_js_1.calculateLoopDuration)({
70
- endAt: trimAfterValue,
71
- mediaDuration: duration,
70
+ trimAfter: trimAfterValue,
71
+ mediaDurationInFrames: duration,
72
72
  playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
73
- startFrom: trimBeforeValue,
73
+ trimBefore: trimBeforeValue,
74
74
  }), children: (0, jsx_runtime_1.jsx)(exports.Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
75
75
  }
76
76
  if (typeof trimBeforeValue !== 'undefined' ||
@@ -12,6 +12,7 @@ const random_js_1 = require("../random.js");
12
12
  const use_amplification_js_1 = require("../use-amplification.js");
13
13
  const use_media_in_timeline_js_1 = require("../use-media-in-timeline.js");
14
14
  const use_media_playback_js_1 = require("../use-media-playback.js");
15
+ const use_media_tag_js_1 = require("../use-media-tag.js");
15
16
  const volume_position_state_js_1 = require("../volume-position-state.js");
16
17
  const volume_prop_js_1 = require("../volume-prop.js");
17
18
  const volume_safeguard_js_1 = require("../volume-safeguard.js");
@@ -92,7 +93,6 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
92
93
  (0, use_media_in_timeline_js_1.useMediaInTimeline)({
93
94
  volume,
94
95
  mediaVolume,
95
- mediaRef: audioRef,
96
96
  src,
97
97
  mediaType: 'audio',
98
98
  playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
@@ -102,9 +102,6 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
102
102
  showInTimeline,
103
103
  premountDisplay: (_b = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premountDisplay) !== null && _b !== void 0 ? _b : null,
104
104
  postmountDisplay: (_c = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmountDisplay) !== null && _c !== void 0 ? _c : null,
105
- onAutoPlayError: null,
106
- isPremounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting),
107
- isPostmounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmounting),
108
105
  });
109
106
  // putting playback before useVolume
110
107
  // because volume looks at playbackrate
@@ -120,6 +117,14 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
120
117
  pauseWhenBuffering,
121
118
  onAutoPlayError: null,
122
119
  });
120
+ (0, use_media_tag_js_1.useMediaTag)({
121
+ id: timelineId,
122
+ isPostmounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmounting),
123
+ isPremounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting),
124
+ mediaRef: audioRef,
125
+ mediaType: 'audio',
126
+ onAutoPlayError: null,
127
+ });
123
128
  (0, use_amplification_js_1.useVolume)({
124
129
  logLevel,
125
130
  mediaRef: audioRef,
@@ -1,6 +1,6 @@
1
- export declare const calculateLoopDuration: ({ endAt, mediaDuration, playbackRate, startFrom, }: {
2
- mediaDuration: number;
1
+ export declare const calculateLoopDuration: ({ trimAfter, mediaDurationInFrames, playbackRate, trimBefore, }: {
2
+ mediaDurationInFrames: number;
3
3
  playbackRate: number;
4
- startFrom: number | undefined;
5
- endAt: number | undefined;
4
+ trimBefore: number | undefined;
5
+ trimAfter: number | undefined;
6
6
  }) => number;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculateLoopDuration = void 0;
4
- const calculateLoopDuration = ({ endAt, mediaDuration, playbackRate, startFrom, }) => {
5
- let duration = mediaDuration;
6
- // Account for endAt
7
- if (typeof endAt !== 'undefined') {
8
- duration = endAt;
4
+ const calculateLoopDuration = ({ trimAfter, mediaDurationInFrames, playbackRate, trimBefore, }) => {
5
+ let duration = mediaDurationInFrames;
6
+ // Account for trimAfter
7
+ if (typeof trimAfter !== 'undefined') {
8
+ duration = trimAfter;
9
9
  }
10
- // Account for startFrom
11
- if (typeof startFrom !== 'undefined') {
12
- duration -= startFrom;
10
+ // Account for trimBefore
11
+ if (typeof trimBefore !== 'undefined') {
12
+ duration -= trimBefore;
13
13
  }
14
14
  const actualDuration = duration / playbackRate;
15
15
  return Math.floor(actualDuration);
@@ -22,6 +22,7 @@ declare global {
22
22
  };
23
23
  remotion_cancelledError: string | undefined;
24
24
  remotion_getCompositionNames: () => string[];
25
+ remotion_seenCompositionIds: string[];
25
26
  getStaticCompositions: () => Promise<VideoConfigWithSerializedProps[]>;
26
27
  remotion_calculateComposition: (compId: string) => Promise<VideoConfigWithSerializedProps>;
27
28
  remotion_setBundleMode: (bundleMode: BundleState) => void;
@@ -85,6 +85,19 @@ export declare const Internals: {
85
85
  readonly getRoot: () => import("react").FC<{}> | null;
86
86
  readonly useMediaVolumeState: () => readonly [number, (u: number) => void];
87
87
  readonly useMediaMutedState: () => readonly [boolean, (u: React.SetStateAction<boolean>) => void];
88
+ readonly useMediaInTimeline: ({ volume, mediaVolume, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, }: {
89
+ volume: import("./volume-prop.js").VolumeProp | undefined;
90
+ mediaVolume: number;
91
+ src: string | undefined;
92
+ mediaType: "audio" | "video";
93
+ playbackRate: number;
94
+ displayName: string | null;
95
+ id: string;
96
+ stack: string | null;
97
+ showInTimeline: boolean;
98
+ premountDisplay: number | null;
99
+ postmountDisplay: number | null;
100
+ }) => void;
88
101
  readonly useLazyComponent: <Props>({ compProps, componentName, noSuspense, }: {
89
102
  compProps: CompProps<Props>;
90
103
  componentName: string;
@@ -132,6 +145,12 @@ export declare const Internals: {
132
145
  readonly audioLatencyHint: AudioContextLatencyCategory;
133
146
  }>;
134
147
  readonly invalidCompositionErrorMessage: string;
148
+ readonly calculateLoopDuration: ({ trimAfter, mediaDurationInFrames, playbackRate, trimBefore, }: {
149
+ mediaDurationInFrames: number;
150
+ playbackRate: number;
151
+ trimBefore: number | undefined;
152
+ trimAfter: number | undefined;
153
+ }) => number;
135
154
  readonly isCompositionIdValid: (id: string) => RegExpMatchArray | null;
136
155
  readonly getPreviewDomElement: () => HTMLElement | null;
137
156
  readonly compositionsRef: import("react").RefObject<{
@@ -40,6 +40,7 @@ const AudioForPreview_js_1 = require("./audio/AudioForPreview.js");
40
40
  const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
41
41
  const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
42
42
  const buffering_js_1 = require("./buffering.js");
43
+ const calculate_loop_js_1 = require("./calculate-loop.js");
43
44
  const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
44
45
  const CompositionManager_js_1 = require("./CompositionManager.js");
45
46
  const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
@@ -71,6 +72,7 @@ const timeline_position_state_js_1 = require("./timeline-position-state.js");
71
72
  const truthy_js_1 = require("./truthy.js");
72
73
  const use_current_scale_js_1 = require("./use-current-scale.js");
73
74
  const use_lazy_component_js_1 = require("./use-lazy-component.js");
75
+ const use_media_in_timeline_js_1 = require("./use-media-in-timeline.js");
74
76
  const use_unsafe_video_config_js_1 = require("./use-unsafe-video-config.js");
75
77
  const use_video_js_1 = require("./use-video.js");
76
78
  const validate_media_props_js_1 = require("./validate-media-props.js");
@@ -110,6 +112,7 @@ exports.Internals = {
110
112
  getRoot: register_root_js_1.getRoot,
111
113
  useMediaVolumeState: volume_position_state_js_1.useMediaVolumeState,
112
114
  useMediaMutedState: volume_position_state_js_1.useMediaMutedState,
115
+ useMediaInTimeline: use_media_in_timeline_js_1.useMediaInTimeline,
113
116
  useLazyComponent: use_lazy_component_js_1.useLazyComponent,
114
117
  truthy: truthy_js_1.truthy,
115
118
  SequenceContext: SequenceContext_js_1.SequenceContext,
@@ -123,6 +126,7 @@ exports.Internals = {
123
126
  SharedAudioContext: shared_audio_tags_js_1.SharedAudioContext,
124
127
  SharedAudioContextProvider: shared_audio_tags_js_1.SharedAudioContextProvider,
125
128
  invalidCompositionErrorMessage: validate_composition_id_js_1.invalidCompositionErrorMessage,
129
+ calculateLoopDuration: calculate_loop_js_1.calculateLoopDuration,
126
130
  isCompositionIdValid: validate_composition_id_js_1.isCompositionIdValid,
127
131
  getPreviewDomElement: get_preview_dom_element_js_1.getPreviewDomElement,
128
132
  compositionsRef: CompositionManager_js_1.compositionsRef,
@@ -1,9 +1,7 @@
1
- import type { RefObject } from 'react';
2
1
  import type { VolumeProp } from './volume-prop.js';
3
- export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, onAutoPlayError, isPremounting, isPostmounting, }: {
2
+ export declare const useMediaInTimeline: ({ volume, mediaVolume, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, }: {
4
3
  volume: VolumeProp | undefined;
5
4
  mediaVolume: number;
6
- mediaRef: RefObject<HTMLAudioElement | HTMLVideoElement | null>;
7
5
  src: string | undefined;
8
6
  mediaType: "audio" | "video";
9
7
  playbackRate: number;
@@ -13,7 +11,4 @@ export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src,
13
11
  showInTimeline: boolean;
14
12
  premountDisplay: number | null;
15
13
  postmountDisplay: number | null;
16
- onAutoPlayError: null | (() => void);
17
- isPremounting: boolean;
18
- isPostmounting: boolean;
19
14
  }) => void;
@@ -6,9 +6,7 @@ const SequenceContext_js_1 = require("./SequenceContext.js");
6
6
  const SequenceManager_js_1 = require("./SequenceManager.js");
7
7
  const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
8
8
  const get_asset_file_name_js_1 = require("./get-asset-file-name.js");
9
- const log_level_context_js_1 = require("./log-level-context.js");
10
9
  const nonce_js_1 = require("./nonce.js");
11
- const play_and_handle_not_allowed_error_js_1 = require("./play-and-handle-not-allowed-error.js");
12
10
  const timeline_position_state_js_1 = require("./timeline-position-state.js");
13
11
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
14
12
  const use_video_config_js_1 = require("./use-video-config.js");
@@ -22,20 +20,17 @@ const warnOnce = (message) => {
22
20
  console.warn(message);
23
21
  didWarn[message] = true;
24
22
  };
25
- const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, onAutoPlayError, isPremounting, isPostmounting, }) => {
23
+ const useMediaInTimeline = ({ volume, mediaVolume, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, postmountDisplay, }) => {
26
24
  const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
27
- const { rootId, audioAndVideoTags } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
28
25
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
29
26
  const actualFrom = parentSequence
30
27
  ? parentSequence.relativeFrom + parentSequence.cumulatedFrom
31
28
  : 0;
32
- const { imperativePlaying } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
33
29
  const startsAt = (0, use_audio_frame_js_1.useMediaStartsAt)();
34
30
  const { registerSequence, unregisterSequence } = (0, react_1.useContext)(SequenceManager_js_1.SequenceManager);
35
31
  const [initialVolume] = (0, react_1.useState)(() => volume);
36
- const logLevel = (0, log_level_context_js_1.useLogLevel)();
37
- const mountTime = (0, log_level_context_js_1.useMountTime)();
38
32
  const nonce = (0, nonce_js_1.useNonce)();
33
+ const { rootId } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
39
34
  const duration = parentSequence
40
35
  ? Math.min(parentSequence.durationInFrames, videoConfig.durationInFrames)
41
36
  : videoConfig.durationInFrames;
@@ -63,9 +58,6 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
63
58
  const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
64
59
  (0, react_1.useEffect)(() => {
65
60
  var _a, _b, _c;
66
- if (!mediaRef.current) {
67
- return;
68
- }
69
61
  if (!src) {
70
62
  throw new Error('No src passed');
71
63
  }
@@ -111,7 +103,6 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
111
103
  volumes,
112
104
  doesVolumeChange,
113
105
  nonce,
114
- mediaRef,
115
106
  mediaType,
116
107
  startsAt,
117
108
  playbackRate,
@@ -122,44 +113,5 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
122
113
  postmountDisplay,
123
114
  env.isStudio,
124
115
  ]);
125
- (0, react_1.useEffect)(() => {
126
- const tag = {
127
- id,
128
- play: (reason) => {
129
- if (!imperativePlaying.current) {
130
- // Don't play if for example in a <Freeze> state.
131
- return;
132
- }
133
- if (isPremounting || isPostmounting) {
134
- return;
135
- }
136
- return (0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
137
- mediaRef,
138
- mediaType,
139
- onAutoPlayError,
140
- logLevel,
141
- mountTime,
142
- reason,
143
- isPlayer: env.isPlayer,
144
- });
145
- },
146
- };
147
- audioAndVideoTags.current.push(tag);
148
- return () => {
149
- audioAndVideoTags.current = audioAndVideoTags.current.filter((a) => a.id !== id);
150
- };
151
- }, [
152
- audioAndVideoTags,
153
- id,
154
- mediaRef,
155
- mediaType,
156
- onAutoPlayError,
157
- imperativePlaying,
158
- isPremounting,
159
- isPostmounting,
160
- logLevel,
161
- mountTime,
162
- env.isPlayer,
163
- ]);
164
116
  };
165
117
  exports.useMediaInTimeline = useMediaInTimeline;
@@ -0,0 +1,9 @@
1
+ import type { RefObject } from 'react';
2
+ export declare const useMediaTag: ({ mediaRef, id, mediaType, onAutoPlayError, isPremounting, isPostmounting, }: {
3
+ mediaRef: RefObject<HTMLAudioElement | HTMLVideoElement | null>;
4
+ id: string;
5
+ mediaType: "audio" | "video";
6
+ onAutoPlayError: null | (() => void);
7
+ isPremounting: boolean;
8
+ isPostmounting: boolean;
9
+ }) => void;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMediaTag = void 0;
4
+ const react_1 = require("react");
5
+ const log_level_context_js_1 = require("./log-level-context.js");
6
+ const play_and_handle_not_allowed_error_js_1 = require("./play-and-handle-not-allowed-error.js");
7
+ const timeline_position_state_js_1 = require("./timeline-position-state.js");
8
+ const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
9
+ const useMediaTag = ({ mediaRef, id, mediaType, onAutoPlayError, isPremounting, isPostmounting, }) => {
10
+ const { audioAndVideoTags, imperativePlaying } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
11
+ const logLevel = (0, log_level_context_js_1.useLogLevel)();
12
+ const mountTime = (0, log_level_context_js_1.useMountTime)();
13
+ const env = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
14
+ (0, react_1.useEffect)(() => {
15
+ const tag = {
16
+ id,
17
+ play: (reason) => {
18
+ if (!imperativePlaying.current) {
19
+ // Don't play if for example in a <Freeze> state.
20
+ return;
21
+ }
22
+ if (isPremounting || isPostmounting) {
23
+ return;
24
+ }
25
+ return (0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
26
+ mediaRef,
27
+ mediaType,
28
+ onAutoPlayError,
29
+ logLevel,
30
+ mountTime,
31
+ reason,
32
+ isPlayer: env.isPlayer,
33
+ });
34
+ },
35
+ };
36
+ audioAndVideoTags.current.push(tag);
37
+ return () => {
38
+ audioAndVideoTags.current = audioAndVideoTags.current.filter((a) => a.id !== id);
39
+ };
40
+ }, [
41
+ audioAndVideoTags,
42
+ id,
43
+ mediaRef,
44
+ mediaType,
45
+ onAutoPlayError,
46
+ imperativePlaying,
47
+ isPremounting,
48
+ isPostmounting,
49
+ logLevel,
50
+ mountTime,
51
+ env.isPlayer,
52
+ ]);
53
+ };
54
+ exports.useMediaTag = useMediaTag;
@@ -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.356";
6
+ export declare const VERSION = "4.0.357";
@@ -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.356';
10
+ exports.VERSION = '4.0.357';
@@ -49,10 +49,10 @@ const VideoForwardingFunction = (props, ref) => {
49
49
  }
50
50
  const mediaDuration = durationFetched * fps;
51
51
  return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { durationInFrames: (0, calculate_loop_js_1.calculateLoopDuration)({
52
- endAt: trimAfterValue,
53
- mediaDuration,
52
+ trimAfter: trimAfterValue,
53
+ mediaDurationInFrames: mediaDuration,
54
54
  playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
55
- startFrom: trimBeforeValue,
55
+ trimBefore: trimBeforeValue,
56
56
  }), layout: "none", name: name, children: (0, jsx_runtime_1.jsx)(exports.Video, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
57
57
  }
58
58
  if (typeof trimBeforeValue !== 'undefined' ||
@@ -15,6 +15,7 @@ const prefetch_js_1 = require("../prefetch.js");
15
15
  const use_amplification_js_1 = require("../use-amplification.js");
16
16
  const use_media_in_timeline_js_1 = require("../use-media-in-timeline.js");
17
17
  const use_media_playback_js_1 = require("../use-media-playback.js");
18
+ const use_media_tag_js_1 = require("../use-media-tag.js");
18
19
  const use_video_config_js_1 = require("../use-video-config.js");
19
20
  const version_js_1 = require("../version.js");
20
21
  const volume_position_state_js_1 = require("../volume-position-state.js");
@@ -65,7 +66,6 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
65
66
  });
66
67
  (0, volume_safeguard_js_1.warnAboutTooHighVolume)(userPreferredVolume);
67
68
  (0, use_media_in_timeline_js_1.useMediaInTimeline)({
68
- mediaRef: videoRef,
69
69
  volume,
70
70
  mediaVolume,
71
71
  mediaType: 'video',
@@ -77,9 +77,6 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
77
77
  showInTimeline,
78
78
  premountDisplay: (_c = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premountDisplay) !== null && _c !== void 0 ? _c : null,
79
79
  postmountDisplay: (_d = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.postmountDisplay) !== null && _d !== void 0 ? _d : null,
80
- onAutoPlayError: onAutoPlayError !== null && onAutoPlayError !== void 0 ? onAutoPlayError : null,
81
- isPremounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting),
82
- isPostmounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.postmounting),
83
80
  });
84
81
  // putting playback before useVolume
85
82
  // because volume looks at playbackrate
@@ -95,6 +92,14 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
95
92
  pauseWhenBuffering,
96
93
  onAutoPlayError: onAutoPlayError !== null && onAutoPlayError !== void 0 ? onAutoPlayError : null,
97
94
  });
95
+ (0, use_media_tag_js_1.useMediaTag)({
96
+ id: timelineId,
97
+ isPostmounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.postmounting),
98
+ isPremounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting),
99
+ mediaRef: videoRef,
100
+ mediaType: 'video',
101
+ onAutoPlayError: onAutoPlayError !== null && onAutoPlayError !== void 0 ? onAutoPlayError : null,
102
+ });
98
103
  (0, use_amplification_js_1.useVolume)({
99
104
  logLevel,
100
105
  mediaRef: videoRef,
@@ -105,7 +105,7 @@ function truthy(value) {
105
105
  }
106
106
 
107
107
  // src/version.ts
108
- var VERSION = "4.0.356";
108
+ var VERSION = "4.0.357";
109
109
 
110
110
  // src/multiple-versions-warning.ts
111
111
  var checkMultipleRemotionVersions = () => {
@@ -2283,7 +2283,7 @@ var Artifact = ({ filename, content, downloadBehavior }) => {
2283
2283
  };
2284
2284
  Artifact.Thumbnail = ArtifactThumbnail;
2285
2285
  // src/audio/Audio.tsx
2286
- import { forwardRef as forwardRef6, useCallback as useCallback11, useContext as useContext25 } from "react";
2286
+ import { forwardRef as forwardRef6, useCallback as useCallback11, useContext as useContext26 } from "react";
2287
2287
 
2288
2288
  // src/absolute-src.ts
2289
2289
  var getAbsoluteSrc = (relativeSrc) => {
@@ -2298,17 +2298,17 @@ var getAbsoluteSrc = (relativeSrc) => {
2298
2298
 
2299
2299
  // src/calculate-loop.ts
2300
2300
  var calculateLoopDuration = ({
2301
- endAt,
2302
- mediaDuration,
2301
+ trimAfter,
2302
+ mediaDurationInFrames,
2303
2303
  playbackRate,
2304
- startFrom
2304
+ trimBefore
2305
2305
  }) => {
2306
- let duration = mediaDuration;
2307
- if (typeof endAt !== "undefined") {
2308
- duration = endAt;
2306
+ let duration = mediaDurationInFrames;
2307
+ if (typeof trimAfter !== "undefined") {
2308
+ duration = trimAfter;
2309
2309
  }
2310
- if (typeof startFrom !== "undefined") {
2311
- duration -= startFrom;
2310
+ if (typeof trimBefore !== "undefined") {
2311
+ duration -= trimBefore;
2312
2312
  }
2313
2313
  const actualDuration = duration / playbackRate;
2314
2314
  return Math.floor(actualDuration);
@@ -2743,8 +2743,8 @@ var DurationsContextProvider = ({ children }) => {
2743
2743
  // src/audio/AudioForPreview.tsx
2744
2744
  import {
2745
2745
  forwardRef as forwardRef4,
2746
- useContext as useContext23,
2747
- useEffect as useEffect13,
2746
+ useContext as useContext24,
2747
+ useEffect as useEffect14,
2748
2748
  useImperativeHandle as useImperativeHandle5,
2749
2749
  useMemo as useMemo20,
2750
2750
  useRef as useRef11,
@@ -3443,7 +3443,6 @@ var warnOnce2 = (message) => {
3443
3443
  var useMediaInTimeline = ({
3444
3444
  volume,
3445
3445
  mediaVolume,
3446
- mediaRef,
3447
3446
  src,
3448
3447
  mediaType,
3449
3448
  playbackRate,
@@ -3452,22 +3451,16 @@ var useMediaInTimeline = ({
3452
3451
  stack,
3453
3452
  showInTimeline,
3454
3453
  premountDisplay,
3455
- postmountDisplay,
3456
- onAutoPlayError,
3457
- isPremounting,
3458
- isPostmounting
3454
+ postmountDisplay
3459
3455
  }) => {
3460
3456
  const videoConfig = useVideoConfig();
3461
- const { rootId, audioAndVideoTags } = useContext18(TimelineContext);
3462
3457
  const parentSequence = useContext18(SequenceContext);
3463
3458
  const actualFrom = parentSequence ? parentSequence.relativeFrom + parentSequence.cumulatedFrom : 0;
3464
- const { imperativePlaying } = useContext18(TimelineContext);
3465
3459
  const startsAt = useMediaStartsAt();
3466
3460
  const { registerSequence, unregisterSequence } = useContext18(SequenceManager);
3467
3461
  const [initialVolume] = useState11(() => volume);
3468
- const logLevel = useLogLevel();
3469
- const mountTime = useMountTime();
3470
3462
  const nonce = useNonce();
3463
+ const { rootId } = useContext18(TimelineContext);
3471
3464
  const duration = parentSequence ? Math.min(parentSequence.durationInFrames, videoConfig.durationInFrames) : videoConfig.durationInFrames;
3472
3465
  const doesVolumeChange = typeof volume === "function";
3473
3466
  const volumes = useMemo15(() => {
@@ -3489,9 +3482,6 @@ var useMediaInTimeline = ({
3489
3482
  }, [initialVolume, mediaType, src, volume]);
3490
3483
  const env = useRemotionEnvironment();
3491
3484
  useEffect8(() => {
3492
- if (!mediaRef.current) {
3493
- return;
3494
- }
3495
3485
  if (!src) {
3496
3486
  throw new Error("No src passed");
3497
3487
  }
@@ -3537,7 +3527,6 @@ var useMediaInTimeline = ({
3537
3527
  volumes,
3538
3528
  doesVolumeChange,
3539
3529
  nonce,
3540
- mediaRef,
3541
3530
  mediaType,
3542
3531
  startsAt,
3543
3532
  playbackRate,
@@ -3548,44 +3537,6 @@ var useMediaInTimeline = ({
3548
3537
  postmountDisplay,
3549
3538
  env.isStudio
3550
3539
  ]);
3551
- useEffect8(() => {
3552
- const tag = {
3553
- id,
3554
- play: (reason) => {
3555
- if (!imperativePlaying.current) {
3556
- return;
3557
- }
3558
- if (isPremounting || isPostmounting) {
3559
- return;
3560
- }
3561
- return playAndHandleNotAllowedError({
3562
- mediaRef,
3563
- mediaType,
3564
- onAutoPlayError,
3565
- logLevel,
3566
- mountTime,
3567
- reason,
3568
- isPlayer: env.isPlayer
3569
- });
3570
- }
3571
- };
3572
- audioAndVideoTags.current.push(tag);
3573
- return () => {
3574
- audioAndVideoTags.current = audioAndVideoTags.current.filter((a) => a.id !== id);
3575
- };
3576
- }, [
3577
- audioAndVideoTags,
3578
- id,
3579
- mediaRef,
3580
- mediaType,
3581
- onAutoPlayError,
3582
- imperativePlaying,
3583
- isPremounting,
3584
- isPostmounting,
3585
- logLevel,
3586
- mountTime,
3587
- env.isPlayer
3588
- ]);
3589
3540
  };
3590
3541
 
3591
3542
  // src/use-media-playback.ts
@@ -4462,8 +4413,62 @@ var useMediaPlayback = ({
4462
4413
  ]);
4463
4414
  };
4464
4415
 
4416
+ // src/use-media-tag.ts
4417
+ import { useContext as useContext22, useEffect as useEffect13 } from "react";
4418
+ var useMediaTag = ({
4419
+ mediaRef,
4420
+ id,
4421
+ mediaType,
4422
+ onAutoPlayError,
4423
+ isPremounting,
4424
+ isPostmounting
4425
+ }) => {
4426
+ const { audioAndVideoTags, imperativePlaying } = useContext22(TimelineContext);
4427
+ const logLevel = useLogLevel();
4428
+ const mountTime = useMountTime();
4429
+ const env = useRemotionEnvironment();
4430
+ useEffect13(() => {
4431
+ const tag = {
4432
+ id,
4433
+ play: (reason) => {
4434
+ if (!imperativePlaying.current) {
4435
+ return;
4436
+ }
4437
+ if (isPremounting || isPostmounting) {
4438
+ return;
4439
+ }
4440
+ return playAndHandleNotAllowedError({
4441
+ mediaRef,
4442
+ mediaType,
4443
+ onAutoPlayError,
4444
+ logLevel,
4445
+ mountTime,
4446
+ reason,
4447
+ isPlayer: env.isPlayer
4448
+ });
4449
+ }
4450
+ };
4451
+ audioAndVideoTags.current.push(tag);
4452
+ return () => {
4453
+ audioAndVideoTags.current = audioAndVideoTags.current.filter((a) => a.id !== id);
4454
+ };
4455
+ }, [
4456
+ audioAndVideoTags,
4457
+ id,
4458
+ mediaRef,
4459
+ mediaType,
4460
+ onAutoPlayError,
4461
+ imperativePlaying,
4462
+ isPremounting,
4463
+ isPostmounting,
4464
+ logLevel,
4465
+ mountTime,
4466
+ env.isPlayer
4467
+ ]);
4468
+ };
4469
+
4465
4470
  // src/volume-position-state.ts
4466
- import { createContext as createContext16, useContext as useContext22, useMemo as useMemo19 } from "react";
4471
+ import { createContext as createContext16, useContext as useContext23, useMemo as useMemo19 } from "react";
4467
4472
  var MediaVolumeContext = createContext16({
4468
4473
  mediaMuted: false,
4469
4474
  mediaVolume: 1
@@ -4477,15 +4482,15 @@ var SetMediaVolumeContext = createContext16({
4477
4482
  }
4478
4483
  });
4479
4484
  var useMediaVolumeState = () => {
4480
- const { mediaVolume } = useContext22(MediaVolumeContext);
4481
- const { setMediaVolume } = useContext22(SetMediaVolumeContext);
4485
+ const { mediaVolume } = useContext23(MediaVolumeContext);
4486
+ const { setMediaVolume } = useContext23(SetMediaVolumeContext);
4482
4487
  return useMemo19(() => {
4483
4488
  return [mediaVolume, setMediaVolume];
4484
4489
  }, [mediaVolume, setMediaVolume]);
4485
4490
  };
4486
4491
  var useMediaMutedState = () => {
4487
- const { mediaMuted } = useContext22(MediaVolumeContext);
4488
- const { setMediaMuted } = useContext22(SetMediaVolumeContext);
4492
+ const { mediaMuted } = useContext23(MediaVolumeContext);
4493
+ const { setMediaMuted } = useContext23(SetMediaVolumeContext);
4489
4494
  return useMemo19(() => {
4490
4495
  return [mediaMuted, setMediaMuted];
4491
4496
  }, [mediaMuted, setMediaMuted]);
@@ -4540,12 +4545,12 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4540
4545
  const [mediaVolume] = useMediaVolumeState();
4541
4546
  const [mediaMuted] = useMediaMutedState();
4542
4547
  const volumePropFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
4543
- const { hidden } = useContext23(SequenceVisibilityToggleContext);
4548
+ const { hidden } = useContext24(SequenceVisibilityToggleContext);
4544
4549
  if (!src) {
4545
4550
  throw new TypeError("No 'src' was passed to <Audio>.");
4546
4551
  }
4547
4552
  const preloadedSrc = usePreload(src);
4548
- const sequenceContext = useContext23(SequenceContext);
4553
+ const sequenceContext = useContext24(SequenceContext);
4549
4554
  const [timelineId] = useState14(() => String(Math.random()));
4550
4555
  const isSequenceHidden = hidden[timelineId] ?? false;
4551
4556
  const userPreferredVolume = evaluateVolume({
@@ -4584,7 +4589,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4584
4589
  props.muted,
4585
4590
  props.loop
4586
4591
  ]);
4587
- const context = useContext23(SharedAudioContext);
4592
+ const context = useContext24(SharedAudioContext);
4588
4593
  if (!context) {
4589
4594
  throw new Error("SharedAudioContext not found");
4590
4595
  }
@@ -4596,7 +4601,6 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4596
4601
  useMediaInTimeline({
4597
4602
  volume,
4598
4603
  mediaVolume,
4599
- mediaRef: audioRef,
4600
4604
  src,
4601
4605
  mediaType: "audio",
4602
4606
  playbackRate: playbackRate ?? 1,
@@ -4605,10 +4609,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4605
4609
  stack: _remotionInternalStack,
4606
4610
  showInTimeline,
4607
4611
  premountDisplay: sequenceContext?.premountDisplay ?? null,
4608
- postmountDisplay: sequenceContext?.postmountDisplay ?? null,
4609
- onAutoPlayError: null,
4610
- isPremounting: Boolean(sequenceContext?.premounting),
4611
- isPostmounting: Boolean(sequenceContext?.postmounting)
4612
+ postmountDisplay: sequenceContext?.postmountDisplay ?? null
4612
4613
  });
4613
4614
  useMediaPlayback({
4614
4615
  mediaRef: audioRef,
@@ -4622,6 +4623,14 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4622
4623
  pauseWhenBuffering,
4623
4624
  onAutoPlayError: null
4624
4625
  });
4626
+ useMediaTag({
4627
+ id: timelineId,
4628
+ isPostmounting: Boolean(sequenceContext?.postmounting),
4629
+ isPremounting: Boolean(sequenceContext?.premounting),
4630
+ mediaRef: audioRef,
4631
+ mediaType: "audio",
4632
+ onAutoPlayError: null
4633
+ });
4625
4634
  useVolume({
4626
4635
  logLevel,
4627
4636
  mediaRef: audioRef,
@@ -4634,7 +4643,7 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4634
4643
  }, [audioRef]);
4635
4644
  const currentOnDurationCallback = useRef11(onDuration);
4636
4645
  currentOnDurationCallback.current = onDuration;
4637
- useEffect13(() => {
4646
+ useEffect14(() => {
4638
4647
  const { current } = audioRef;
4639
4648
  if (!current) {
4640
4649
  return;
@@ -4666,8 +4675,8 @@ var AudioForPreview = forwardRef4(AudioForDevelopmentForwardRefFunction);
4666
4675
  // src/audio/AudioForRendering.tsx
4667
4676
  import {
4668
4677
  forwardRef as forwardRef5,
4669
- useContext as useContext24,
4670
- useEffect as useEffect14,
4678
+ useContext as useContext25,
4679
+ useEffect as useEffect15,
4671
4680
  useImperativeHandle as useImperativeHandle6,
4672
4681
  useLayoutEffect as useLayoutEffect6,
4673
4682
  useMemo as useMemo21,
@@ -4697,8 +4706,8 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
4697
4706
  const absoluteFrame = useTimelinePosition();
4698
4707
  const volumePropFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
4699
4708
  const frame = useCurrentFrame();
4700
- const sequenceContext = useContext24(SequenceContext);
4701
- const { registerRenderAsset, unregisterRenderAsset } = useContext24(RenderAssetManager);
4709
+ const sequenceContext = useContext25(SequenceContext);
4710
+ const { registerRenderAsset, unregisterRenderAsset } = useContext25(RenderAssetManager);
4702
4711
  const { delayRender: delayRender2, continueRender: continueRender2 } = useDelayRender();
4703
4712
  const id = useMemo21(() => `audio-${random(props.src ?? "")}-${sequenceContext?.relativeFrom}-${sequenceContext?.cumulatedFrom}-${sequenceContext?.durationInFrames}`, [
4704
4713
  props.src,
@@ -4715,7 +4724,7 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
4715
4724
  useImperativeHandle6(ref, () => {
4716
4725
  return audioRef.current;
4717
4726
  }, []);
4718
- useEffect14(() => {
4727
+ useEffect15(() => {
4719
4728
  if (!props.src) {
4720
4729
  throw new Error("No src passed");
4721
4730
  }
@@ -4810,7 +4819,7 @@ var AudioForRendering = forwardRef5(AudioForRenderingRefForwardingFunction);
4810
4819
  // src/audio/Audio.tsx
4811
4820
  import { jsx as jsx19 } from "react/jsx-runtime";
4812
4821
  var AudioRefForwardingFunction = (props, ref) => {
4813
- const audioContext = useContext25(SharedAudioContext);
4822
+ const audioContext = useContext26(SharedAudioContext);
4814
4823
  const {
4815
4824
  startFrom,
4816
4825
  endAt,
@@ -4826,7 +4835,7 @@ var AudioRefForwardingFunction = (props, ref) => {
4826
4835
  const { loop, ...propsOtherThanLoop } = props;
4827
4836
  const { fps } = useVideoConfig();
4828
4837
  const environment = useRemotionEnvironment();
4829
- const { durations, setDurations } = useContext25(DurationsContext);
4838
+ const { durations, setDurations } = useContext26(DurationsContext);
4830
4839
  if (typeof props.src !== "string") {
4831
4840
  throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
4832
4841
  }
@@ -4868,10 +4877,10 @@ var AudioRefForwardingFunction = (props, ref) => {
4868
4877
  return /* @__PURE__ */ jsx19(Loop, {
4869
4878
  layout: "none",
4870
4879
  durationInFrames: calculateLoopDuration({
4871
- endAt: trimAfterValue,
4872
- mediaDuration: duration,
4880
+ trimAfter: trimAfterValue,
4881
+ mediaDurationInFrames: duration,
4873
4882
  playbackRate: props.playbackRate ?? 1,
4874
- startFrom: trimBeforeValue
4883
+ trimBefore: trimBeforeValue
4875
4884
  }),
4876
4885
  children: /* @__PURE__ */ jsx19(Audio, {
4877
4886
  ...propsOtherThanLoop,
@@ -4921,11 +4930,11 @@ var AudioRefForwardingFunction = (props, ref) => {
4921
4930
  var Audio = forwardRef6(AudioRefForwardingFunction);
4922
4931
  addSequenceStackTraces(Audio);
4923
4932
  // src/Composition.tsx
4924
- import { Suspense, useContext as useContext27, useEffect as useEffect16 } from "react";
4933
+ import { Suspense, useContext as useContext28, useEffect as useEffect17 } from "react";
4925
4934
  import { createPortal } from "react-dom";
4926
4935
 
4927
4936
  // src/Folder.tsx
4928
- import { createContext as createContext17, useContext as useContext26, useEffect as useEffect15, useMemo as useMemo22 } from "react";
4937
+ import { createContext as createContext17, useContext as useContext27, useEffect as useEffect16, useMemo as useMemo22 } from "react";
4929
4938
 
4930
4939
  // src/validation/validate-folder-name.ts
4931
4940
  var getRegex = () => /^([a-zA-Z0-9-\u4E00-\u9FFF])+$/g;
@@ -4950,8 +4959,8 @@ var FolderContext = createContext17({
4950
4959
  parentName: null
4951
4960
  });
4952
4961
  var Folder = ({ name, children }) => {
4953
- const parent = useContext26(FolderContext);
4954
- const { registerFolder, unregisterFolder } = useContext26(CompositionSetters);
4962
+ const parent = useContext27(FolderContext);
4963
+ const { registerFolder, unregisterFolder } = useContext27(CompositionSetters);
4955
4964
  validateFolderName(name);
4956
4965
  const parentNameArr = [parent.parentName, parent.folderName].filter(truthy);
4957
4966
  const parentName = parentNameArr.length === 0 ? null : parentNameArr.join("/");
@@ -4961,7 +4970,7 @@ var Folder = ({ name, children }) => {
4961
4970
  parentName
4962
4971
  };
4963
4972
  }, [name, parentName]);
4964
- useEffect15(() => {
4973
+ useEffect16(() => {
4965
4974
  registerFolder(name, parentName);
4966
4975
  return () => {
4967
4976
  unregisterFolder(name, parentName);
@@ -5116,7 +5125,7 @@ var validateDefaultAndInputProps = (defaultProps, name, compositionId) => {
5116
5125
  import { jsx as jsx22 } from "react/jsx-runtime";
5117
5126
  var Fallback = () => {
5118
5127
  const { continueRender: continueRender2, delayRender: delayRender2 } = useDelayRender();
5119
- useEffect16(() => {
5128
+ useEffect17(() => {
5120
5129
  const fallback = delayRender2("Waiting for Root component to unsuspend");
5121
5130
  return () => continueRender2(fallback);
5122
5131
  }, [continueRender2, delayRender2]);
@@ -5132,7 +5141,7 @@ var InnerComposition = ({
5132
5141
  schema,
5133
5142
  ...compProps
5134
5143
  }) => {
5135
- const compManager = useContext27(CompositionSetters);
5144
+ const compManager = useContext28(CompositionSetters);
5136
5145
  const { registerComposition, unregisterComposition } = compManager;
5137
5146
  const video = useVideo();
5138
5147
  const lazy = useLazyComponent({
@@ -5143,15 +5152,18 @@ var InnerComposition = ({
5143
5152
  const nonce = useNonce();
5144
5153
  const isPlayer = useIsPlayer();
5145
5154
  const environment = useRemotionEnvironment();
5146
- const canUseComposition = useContext27(CanUseRemotionHooks);
5155
+ const canUseComposition = useContext28(CanUseRemotionHooks);
5156
+ if (typeof window !== "undefined") {
5157
+ window.remotion_seenCompositionIds = Array.from(new Set([...window.remotion_seenCompositionIds ?? [], id]));
5158
+ }
5147
5159
  if (canUseComposition) {
5148
5160
  if (isPlayer) {
5149
5161
  throw new Error("<Composition> was mounted inside the `component` that was passed to the <Player>. See https://remotion.dev/docs/wrong-composition-mount for help.");
5150
5162
  }
5151
5163
  throw new Error("<Composition> mounted inside another composition. See https://remotion.dev/docs/wrong-composition-mount for help.");
5152
5164
  }
5153
- const { folderName, parentName } = useContext27(FolderContext);
5154
- useEffect16(() => {
5165
+ const { folderName, parentName } = useContext28(FolderContext);
5166
+ useEffect17(() => {
5155
5167
  if (!id) {
5156
5168
  throw new Error("No id for composition passed.");
5157
5169
  }
@@ -5190,7 +5202,7 @@ var InnerComposition = ({
5190
5202
  registerComposition,
5191
5203
  unregisterComposition
5192
5204
  ]);
5193
- useEffect16(() => {
5205
+ useEffect17(() => {
5194
5206
  window.dispatchEvent(new CustomEvent(PROPS_UPDATED_EXTERNALLY, {
5195
5207
  detail: {
5196
5208
  resetUnsaved: id
@@ -5229,7 +5241,7 @@ var InnerComposition = ({
5229
5241
  return null;
5230
5242
  };
5231
5243
  var Composition = (props2) => {
5232
- const { onlyRenderComposition } = useContext27(CompositionSetters);
5244
+ const { onlyRenderComposition } = useContext28(CompositionSetters);
5233
5245
  if (onlyRenderComposition && onlyRenderComposition !== props2.id) {
5234
5246
  return null;
5235
5247
  }
@@ -5489,7 +5501,7 @@ var IFrame = forwardRef7(IFrameRefForwarding);
5489
5501
  import {
5490
5502
  forwardRef as forwardRef8,
5491
5503
  useCallback as useCallback13,
5492
- useContext as useContext28,
5504
+ useContext as useContext29,
5493
5505
  useImperativeHandle as useImperativeHandle7,
5494
5506
  useLayoutEffect as useLayoutEffect7,
5495
5507
  useRef as useRef13
@@ -5512,7 +5524,7 @@ var ImgRefForwarding = ({
5512
5524
  const imageRef = useRef13(null);
5513
5525
  const errors = useRef13({});
5514
5526
  const { delayPlayback } = useBufferState();
5515
- const sequenceContext = useContext28(SequenceContext);
5527
+ const sequenceContext = useContext29(SequenceContext);
5516
5528
  if (!src) {
5517
5529
  throw new Error('No "src" prop was passed to <Img>.');
5518
5530
  }
@@ -5861,7 +5873,7 @@ var waitForRoot = (fn) => {
5861
5873
 
5862
5874
  // src/RemotionRoot.tsx
5863
5875
  import {
5864
- useEffect as useEffect17,
5876
+ useEffect as useEffect18,
5865
5877
  useLayoutEffect as useLayoutEffect8,
5866
5878
  useMemo as useMemo25,
5867
5879
  useRef as useRef15,
@@ -5943,7 +5955,7 @@ var RemotionRoot = ({
5943
5955
  }
5944
5956
  };
5945
5957
  }, []);
5946
- useEffect17(() => {
5958
+ useEffect18(() => {
5947
5959
  if (typeof __webpack_module__ !== "undefined") {
5948
5960
  if (__webpack_module__.hot) {
5949
5961
  __webpack_module__.hot.addStatusHandler((status) => {
@@ -6079,8 +6091,8 @@ import { useCallback as useCallback16 } from "react";
6079
6091
  // src/video/OffthreadVideoForRendering.tsx
6080
6092
  import {
6081
6093
  useCallback as useCallback15,
6082
- useContext as useContext29,
6083
- useEffect as useEffect18,
6094
+ useContext as useContext30,
6095
+ useEffect as useEffect19,
6084
6096
  useLayoutEffect as useLayoutEffect9,
6085
6097
  useMemo as useMemo26,
6086
6098
  useState as useState18
@@ -6121,9 +6133,9 @@ var OffthreadVideoForRendering = ({
6121
6133
  const frame = useCurrentFrame();
6122
6134
  const volumePropsFrame = useFrameForVolumeProp(loopVolumeCurveBehavior);
6123
6135
  const videoConfig = useUnsafeVideoConfig();
6124
- const sequenceContext = useContext29(SequenceContext);
6136
+ const sequenceContext = useContext30(SequenceContext);
6125
6137
  const mediaStartsAt = useMediaStartsAt();
6126
- const { registerRenderAsset, unregisterRenderAsset } = useContext29(RenderAssetManager);
6138
+ const { registerRenderAsset, unregisterRenderAsset } = useContext30(RenderAssetManager);
6127
6139
  if (!src) {
6128
6140
  throw new TypeError("No `src` was passed to <OffthreadVideo>.");
6129
6141
  }
@@ -6142,7 +6154,7 @@ var OffthreadVideoForRendering = ({
6142
6154
  mediaVolume: 1
6143
6155
  });
6144
6156
  warnAboutTooHighVolume(volume);
6145
- useEffect18(() => {
6157
+ useEffect19(() => {
6146
6158
  if (!src) {
6147
6159
  throw new Error("No src passed");
6148
6160
  }
@@ -6303,8 +6315,8 @@ var OffthreadVideoForRendering = ({
6303
6315
  // src/video/VideoForPreview.tsx
6304
6316
  import {
6305
6317
  forwardRef as forwardRef9,
6306
- useContext as useContext30,
6307
- useEffect as useEffect20,
6318
+ useContext as useContext31,
6319
+ useEffect as useEffect21,
6308
6320
  useImperativeHandle as useImperativeHandle9,
6309
6321
  useMemo as useMemo27,
6310
6322
  useRef as useRef16,
@@ -6312,12 +6324,12 @@ import {
6312
6324
  } from "react";
6313
6325
 
6314
6326
  // src/video/emit-video-frame.ts
6315
- import { useEffect as useEffect19 } from "react";
6327
+ import { useEffect as useEffect20 } from "react";
6316
6328
  var useEmitVideoFrame = ({
6317
6329
  ref,
6318
6330
  onVideoFrame
6319
6331
  }) => {
6320
- useEffect19(() => {
6332
+ useEffect20(() => {
6321
6333
  const { current } = ref;
6322
6334
  if (!current) {
6323
6335
  return;
@@ -6343,7 +6355,7 @@ var useEmitVideoFrame = ({
6343
6355
  // src/video/VideoForPreview.tsx
6344
6356
  import { jsx as jsx28 } from "react/jsx-runtime";
6345
6357
  var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6346
- const context = useContext30(SharedAudioContext);
6358
+ const context = useContext31(SharedAudioContext);
6347
6359
  if (!context) {
6348
6360
  throw new Error("SharedAudioContext not found");
6349
6361
  }
@@ -6391,8 +6403,8 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6391
6403
  }
6392
6404
  const volumePropFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
6393
6405
  const { fps, durationInFrames } = useVideoConfig();
6394
- const parentSequence = useContext30(SequenceContext);
6395
- const { hidden } = useContext30(SequenceVisibilityToggleContext);
6406
+ const parentSequence = useContext31(SequenceContext);
6407
+ const { hidden } = useContext31(SequenceVisibilityToggleContext);
6396
6408
  const logLevel = useLogLevel();
6397
6409
  const mountTime = useMountTime();
6398
6410
  const [timelineId] = useState19(() => String(Math.random()));
@@ -6409,7 +6421,6 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6409
6421
  });
6410
6422
  warnAboutTooHighVolume(userPreferredVolume);
6411
6423
  useMediaInTimeline({
6412
- mediaRef: videoRef,
6413
6424
  volume,
6414
6425
  mediaVolume,
6415
6426
  mediaType: "video",
@@ -6420,10 +6431,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6420
6431
  stack: _remotionInternalStack,
6421
6432
  showInTimeline,
6422
6433
  premountDisplay: parentSequence?.premountDisplay ?? null,
6423
- postmountDisplay: parentSequence?.postmountDisplay ?? null,
6424
- onAutoPlayError: onAutoPlayError ?? null,
6425
- isPremounting: Boolean(parentSequence?.premounting),
6426
- isPostmounting: Boolean(parentSequence?.postmounting)
6434
+ postmountDisplay: parentSequence?.postmountDisplay ?? null
6427
6435
  });
6428
6436
  useMediaPlayback({
6429
6437
  mediaRef: videoRef,
@@ -6437,6 +6445,14 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6437
6445
  pauseWhenBuffering,
6438
6446
  onAutoPlayError: onAutoPlayError ?? null
6439
6447
  });
6448
+ useMediaTag({
6449
+ id: timelineId,
6450
+ isPostmounting: Boolean(parentSequence?.postmounting),
6451
+ isPremounting: Boolean(parentSequence?.premounting),
6452
+ mediaRef: videoRef,
6453
+ mediaType: "video",
6454
+ onAutoPlayError: onAutoPlayError ?? null
6455
+ });
6440
6456
  useVolume({
6441
6457
  logLevel,
6442
6458
  mediaRef: videoRef,
@@ -6462,7 +6478,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6462
6478
  tag: "video",
6463
6479
  mountTime
6464
6480
  }));
6465
- useEffect20(() => {
6481
+ useEffect21(() => {
6466
6482
  const { current } = videoRef;
6467
6483
  if (!current) {
6468
6484
  return;
@@ -6493,7 +6509,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6493
6509
  const currentOnDurationCallback = useRef16(onDuration);
6494
6510
  currentOnDurationCallback.current = onDuration;
6495
6511
  useEmitVideoFrame({ ref: videoRef, onVideoFrame });
6496
- useEffect20(() => {
6512
+ useEffect21(() => {
6497
6513
  const { current } = videoRef;
6498
6514
  if (!current) {
6499
6515
  return;
@@ -6510,7 +6526,7 @@ var VideoForDevelopmentRefForwardingFunction = (props2, ref) => {
6510
6526
  current.removeEventListener("loadedmetadata", onLoadedMetadata);
6511
6527
  };
6512
6528
  }, [src]);
6513
- useEffect20(() => {
6529
+ useEffect21(() => {
6514
6530
  const { current } = videoRef;
6515
6531
  if (!current) {
6516
6532
  return;
@@ -6845,6 +6861,7 @@ var Internals = {
6845
6861
  getRoot,
6846
6862
  useMediaVolumeState,
6847
6863
  useMediaMutedState,
6864
+ useMediaInTimeline,
6848
6865
  useLazyComponent,
6849
6866
  truthy,
6850
6867
  SequenceContext,
@@ -6858,6 +6875,7 @@ var Internals = {
6858
6875
  SharedAudioContext,
6859
6876
  SharedAudioContextProvider,
6860
6877
  invalidCompositionErrorMessage,
6878
+ calculateLoopDuration,
6861
6879
  isCompositionIdValid,
6862
6880
  getPreviewDomElement,
6863
6881
  compositionsRef,
@@ -7728,13 +7746,13 @@ var Still = (props2) => {
7728
7746
  return React34.createElement(Composition, newProps);
7729
7747
  };
7730
7748
  // src/video/Video.tsx
7731
- import { forwardRef as forwardRef12, useCallback as useCallback17, useContext as useContext32 } from "react";
7749
+ import { forwardRef as forwardRef12, useCallback as useCallback17, useContext as useContext33 } from "react";
7732
7750
 
7733
7751
  // src/video/VideoForRendering.tsx
7734
7752
  import {
7735
7753
  forwardRef as forwardRef11,
7736
- useContext as useContext31,
7737
- useEffect as useEffect21,
7754
+ useContext as useContext32,
7755
+ useEffect as useEffect22,
7738
7756
  useImperativeHandle as useImperativeHandle10,
7739
7757
  useLayoutEffect as useLayoutEffect10,
7740
7758
  useMemo as useMemo30,
@@ -7887,13 +7905,13 @@ var VideoForRenderingForwardFunction = ({
7887
7905
  const volumePropsFrame = useFrameForVolumeProp(loopVolumeCurveBehavior ?? "repeat");
7888
7906
  const videoConfig = useUnsafeVideoConfig();
7889
7907
  const videoRef = useRef17(null);
7890
- const sequenceContext = useContext31(SequenceContext);
7908
+ const sequenceContext = useContext32(SequenceContext);
7891
7909
  const mediaStartsAt = useMediaStartsAt();
7892
7910
  const environment = useRemotionEnvironment();
7893
7911
  const logLevel = useLogLevel();
7894
7912
  const mountTime = useMountTime();
7895
7913
  const { delayRender: delayRender2, continueRender: continueRender2 } = useDelayRender();
7896
- const { registerRenderAsset, unregisterRenderAsset } = useContext31(RenderAssetManager);
7914
+ const { registerRenderAsset, unregisterRenderAsset } = useContext32(RenderAssetManager);
7897
7915
  const id = useMemo30(() => `video-${random(props2.src ?? "")}-${sequenceContext?.cumulatedFrom}-${sequenceContext?.relativeFrom}-${sequenceContext?.durationInFrames}`, [
7898
7916
  props2.src,
7899
7917
  sequenceContext?.cumulatedFrom,
@@ -7909,7 +7927,7 @@ var VideoForRenderingForwardFunction = ({
7909
7927
  mediaVolume: 1
7910
7928
  });
7911
7929
  warnAboutTooHighVolume(volume);
7912
- useEffect21(() => {
7930
+ useEffect22(() => {
7913
7931
  if (!props2.src) {
7914
7932
  throw new Error("No src passed");
7915
7933
  }
@@ -7952,7 +7970,7 @@ var VideoForRenderingForwardFunction = ({
7952
7970
  useImperativeHandle10(ref, () => {
7953
7971
  return videoRef.current;
7954
7972
  }, []);
7955
- useEffect21(() => {
7973
+ useEffect22(() => {
7956
7974
  if (!window.remotion_videoEnabled) {
7957
7975
  return;
7958
7976
  }
@@ -8097,7 +8115,7 @@ var VideoForwardingFunction = (props2, ref) => {
8097
8115
  const { loop, ...propsOtherThanLoop } = props2;
8098
8116
  const { fps } = useVideoConfig();
8099
8117
  const environment = useRemotionEnvironment();
8100
- const { durations, setDurations } = useContext32(DurationsContext);
8118
+ const { durations, setDurations } = useContext33(DurationsContext);
8101
8119
  if (typeof ref === "string") {
8102
8120
  throw new Error("string refs are not supported");
8103
8121
  }
@@ -8128,10 +8146,10 @@ var VideoForwardingFunction = (props2, ref) => {
8128
8146
  const mediaDuration = durationFetched * fps;
8129
8147
  return /* @__PURE__ */ jsx34(Loop, {
8130
8148
  durationInFrames: calculateLoopDuration({
8131
- endAt: trimAfterValue,
8132
- mediaDuration,
8149
+ trimAfter: trimAfterValue,
8150
+ mediaDurationInFrames: mediaDuration,
8133
8151
  playbackRate: props2.playbackRate ?? 1,
8134
- startFrom: trimBeforeValue
8152
+ trimBefore: trimBeforeValue
8135
8153
  }),
8136
8154
  layout: "none",
8137
8155
  name,
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.356";
2
+ var VERSION = "4.0.357";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
4
4
  },
5
5
  "name": "remotion",
6
- "version": "4.0.356",
6
+ "version": "4.0.357",
7
7
  "description": "Make videos programmatically",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "webpack": "5.96.1",
29
29
  "zod": "3.22.3",
30
30
  "eslint": "9.19.0",
31
- "@remotion/eslint-config-internal": "4.0.356"
31
+ "@remotion/eslint-config-internal": "4.0.357"
32
32
  },
33
33
  "keywords": [
34
34
  "video",