remotion 4.0.523 → 4.0.525

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 (34) hide show
  1. package/dist/cjs/TimelineContext.d.ts +1 -0
  2. package/dist/cjs/TimelineContext.js +1 -0
  3. package/dist/cjs/absolute-src.js +1 -1
  4. package/dist/cjs/animated-image/resolve-image-source.js +1 -1
  5. package/dist/cjs/audio/AudioForPreview.js +9 -6
  6. package/dist/cjs/audio/AudioForRendering.js +11 -8
  7. package/dist/cjs/audio/shared-audio-tags.d.ts +1 -0
  8. package/dist/cjs/audio/shared-audio-tags.js +4 -8
  9. package/dist/cjs/audio/use-media-audio-state.d.ts +17 -0
  10. package/dist/cjs/audio/use-media-audio-state.js +27 -0
  11. package/dist/cjs/font-face-registry.d.ts +19 -0
  12. package/dist/cjs/font-face-registry.js +48 -0
  13. package/dist/cjs/freeze.js +1 -0
  14. package/dist/cjs/internals.d.ts +7 -0
  15. package/dist/cjs/internals.js +3 -0
  16. package/dist/cjs/no-react.d.ts +3 -0
  17. package/dist/cjs/no-react.js +4 -0
  18. package/dist/cjs/timeline-position-state.d.ts +1 -0
  19. package/dist/cjs/timeline-position-state.js +5 -1
  20. package/dist/cjs/version.d.ts +1 -1
  21. package/dist/cjs/version.js +1 -1
  22. package/dist/cjs/video/OffthreadVideoForRendering.js +13 -11
  23. package/dist/cjs/video/VideoForPreview.js +8 -3
  24. package/dist/cjs/video/VideoForRendering.js +14 -11
  25. package/dist/esm/index.mjs +197 -153
  26. package/dist/esm/no-react.mjs +35 -2
  27. package/dist/esm/version.mjs +1 -1
  28. package/package.json +2 -2
  29. package/dist/cjs/interpolate-translate.d.ts +0 -8
  30. package/dist/cjs/interpolate-translate.js +0 -70
  31. package/dist/cjs/sequence-field-schema.d.ts +0 -425
  32. package/dist/cjs/sequence-field-schema.js +0 -133
  33. package/dist/cjs/wrap-in-schema.d.ts +0 -20
  34. package/dist/cjs/wrap-in-schema.js +0 -203
@@ -4,6 +4,7 @@ import { type PlayableMediaTag } from './timeline-position-state';
4
4
  export type TimelineContextValue = {
5
5
  frame: Record<string, number>;
6
6
  isPlaying: () => boolean;
7
+ isInsideFreeze: boolean;
7
8
  audioAndVideoTags: RefObject<PlayableMediaTag[]>;
8
9
  };
9
10
  export type PlaybackRateContextValue = {
@@ -70,6 +70,7 @@ const TimelineContextProvider = ({ children, frameState }) => {
70
70
  return {
71
71
  frame,
72
72
  isPlaying: readIsPlaying,
73
+ isInsideFreeze: false,
73
74
  audioAndVideoTags,
74
75
  };
75
76
  }, [frame, readIsPlaying]);
@@ -13,6 +13,6 @@ const getAbsoluteSrc = (relativeSrc) => {
13
13
  relativeSrc.startsWith('data:')) {
14
14
  return relativeSrc;
15
15
  }
16
- return new URL(relativeSrc, window.origin).href;
16
+ return new URL(relativeSrc, document.baseURI).href;
17
17
  };
18
18
  exports.getAbsoluteSrc = getAbsoluteSrc;
@@ -5,6 +5,6 @@ const resolveAnimatedImageSource = (src) => {
5
5
  if (typeof window === 'undefined') {
6
6
  return src;
7
7
  }
8
- return new URL(src, window.origin).href;
8
+ return new URL(src, document.baseURI).href;
9
9
  };
10
10
  exports.resolveAnimatedImageSource = resolveAnimatedImageSource;
@@ -53,6 +53,7 @@ const volume_prop_js_1 = require("../volume-prop.js");
53
53
  const volume_safeguard_js_1 = require("../volume-safeguard.js");
54
54
  const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
55
55
  const use_audio_frame_js_1 = require("./use-audio-frame.js");
56
+ const use_media_audio_state_js_1 = require("./use-media-audio-state.js");
56
57
  const AudioForDevelopmentForwardRefFunction = (props, ref) => {
57
58
  var _a, _b, _c;
58
59
  const [initialShouldPreMountAudioElements] = (0, react_2.useState)(props.shouldPreMountAudioTags);
@@ -68,7 +69,6 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
68
69
  throw new Error('typecheck error');
69
70
  }
70
71
  const [mediaVolume] = (0, volume_position_state_js_1.useMediaVolumeState)();
71
- const [playerMuted] = (0, volume_position_state_js_1.usePlayerMutedState)();
72
72
  const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
73
73
  if (!src) {
74
74
  throw new TypeError("No 'src' was passed to <Html5Audio>.");
@@ -82,6 +82,11 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
82
82
  volume,
83
83
  mediaVolume,
84
84
  });
85
+ const { isMutedForTimeline, isMutedForPlayback } = (0, use_media_audio_state_js_1.useMediaAudioState)({
86
+ muted: muted !== null && muted !== void 0 ? muted : false,
87
+ volume: userPreferredVolume,
88
+ audioEnabled: true,
89
+ });
85
90
  (0, volume_safeguard_js_1.warnAboutTooHighVolume)(userPreferredVolume);
86
91
  const crossOriginValue = (0, get_cross_origin_value_js_1.getCrossOriginValue)({
87
92
  crossOrigin,
@@ -90,7 +95,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
90
95
  });
91
96
  const propsToPass = (0, react_2.useMemo)(() => {
92
97
  return {
93
- muted: muted || playerMuted || userPreferredVolume <= 0,
98
+ muted: isMutedForPlayback,
94
99
  src: preloadedSrc,
95
100
  loop: _remotionInternalNativeLoopPassed,
96
101
  crossOrigin: crossOriginValue,
@@ -98,11 +103,9 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
98
103
  };
99
104
  }, [
100
105
  _remotionInternalNativeLoopPassed,
101
- playerMuted,
102
- muted,
106
+ isMutedForPlayback,
103
107
  nativeProps,
104
108
  preloadedSrc,
105
- userPreferredVolume,
106
109
  crossOriginValue,
107
110
  ]);
108
111
  // Generate a string that's as unique as possible for this asset
@@ -139,7 +142,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
139
142
  loopDisplay: undefined,
140
143
  documentationLink: 'https://www.remotion.dev/docs/html5-audio',
141
144
  refForOutline: null,
142
- muted: muted !== null && muted !== void 0 ? muted : false,
145
+ muted: isMutedForTimeline,
143
146
  });
144
147
  // putting playback before useVolume
145
148
  // because volume looks at playbackrate
@@ -10,10 +10,13 @@ const SequenceContext_js_1 = require("../SequenceContext.js");
10
10
  const timeline_position_state_js_1 = require("../timeline-position-state.js");
11
11
  const use_current_frame_js_1 = require("../use-current-frame.js");
12
12
  const use_delay_render_js_1 = require("../use-delay-render.js");
13
+ const use_media_enabled_js_1 = require("../use-media-enabled.js");
13
14
  const volume_prop_js_1 = require("../volume-prop.js");
14
15
  const volume_safeguard_js_1 = require("../volume-safeguard.js");
15
16
  const use_audio_frame_js_1 = require("./use-audio-frame.js");
17
+ const use_media_audio_state_js_1 = require("./use-media-audio-state.js");
16
18
  const AudioForRenderingRefForwardingFunction = (props, ref) => {
19
+ var _a;
17
20
  const audioRef = (0, react_1.useRef)(null);
18
21
  const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onNativeError, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, pauseWhenBuffering, audioStreamIndex, preservePitch: _preservePitch, ...nativeProps } = props;
19
22
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
@@ -39,6 +42,12 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
39
42
  mediaVolume: 1,
40
43
  });
41
44
  (0, volume_safeguard_js_1.warnAboutTooHighVolume)(volume);
45
+ const audioEnabled = (0, use_media_enabled_js_1.useAudioEnabled)();
46
+ const { shouldUseAudio } = (0, use_media_audio_state_js_1.useMediaAudioState)({
47
+ muted: (_a = props.muted) !== null && _a !== void 0 ? _a : false,
48
+ volume,
49
+ audioEnabled,
50
+ });
42
51
  (0, react_1.useImperativeHandle)(ref, () => {
43
52
  return audioRef.current;
44
53
  }, []);
@@ -47,13 +56,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
47
56
  if (!props.src) {
48
57
  throw new Error('No src passed');
49
58
  }
50
- if (!window.remotion_audioEnabled) {
51
- return;
52
- }
53
- if (props.muted) {
54
- return;
55
- }
56
- if (volume <= 0) {
59
+ if (!shouldUseAudio) {
57
60
  return;
58
61
  }
59
62
  registerRenderAsset({
@@ -70,7 +73,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
70
73
  });
71
74
  return () => unregisterRenderAsset(id);
72
75
  }, [
73
- props.muted,
76
+ shouldUseAudio,
74
77
  props.src,
75
78
  registerRenderAsset,
76
79
  absoluteFrame,
@@ -49,6 +49,7 @@ export type AudioSyncAnchorEmitter = {
49
49
  };
50
50
  };
51
51
  type SharedAudioContextValue = {
52
+ sampleRate: number;
52
53
  audioContext: AudioContext | null;
53
54
  getAudioContextState: () => RemotionAudioContextState | null;
54
55
  gainNode: GainNode | null;
@@ -67,8 +67,8 @@ const didPropChange = (key, newProp, prevProp) => {
67
67
  if (key === 'src' &&
68
68
  !prevProp.startsWith('data:') &&
69
69
  !newProp.startsWith('data:')) {
70
- return (new URL(prevProp, window.origin).toString() !==
71
- new URL(newProp, window.origin).toString());
70
+ return (new URL(prevProp, document.baseURI).toString() !==
71
+ new URL(newProp, document.baseURI).toString());
72
72
  }
73
73
  if (prevProp === newProp) {
74
74
  return false;
@@ -91,12 +91,6 @@ const shouldSaveForLater = (state) => {
91
91
  const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled, previewSampleRate, _experimentalKeepAudioContextAlive, }) => {
92
92
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
93
93
  const sampleRate = previewSampleRate !== null && previewSampleRate !== void 0 ? previewSampleRate : 48000;
94
- (0, react_1.useEffect)(() => {
95
- if (typeof window === 'undefined') {
96
- return;
97
- }
98
- window.remotion_sampleRate = sampleRate;
99
- }, [sampleRate]);
100
94
  const ctxAndGain = (0, use_audio_context_js_1.useSingletonAudioContext)({
101
95
  logLevel,
102
96
  latencyHint: audioLatencyHint,
@@ -323,6 +317,7 @@ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled,
323
317
  const audioContextValue = (0, react_1.useMemo)(() => {
324
318
  var _a, _b;
325
319
  return {
320
+ sampleRate,
326
321
  audioContext: (_a = ctxAndGain === null || ctxAndGain === void 0 ? void 0 : ctxAndGain.audioContext) !== null && _a !== void 0 ? _a : null,
327
322
  getAudioContextState: () => {
328
323
  var _a;
@@ -340,6 +335,7 @@ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled,
340
335
  _experimentalKeepAudioContextAlive,
341
336
  };
342
337
  }, [
338
+ sampleRate,
343
339
  ctxAndGain,
344
340
  audioSyncAnchor,
345
341
  audioSyncAnchorEmitter,
@@ -0,0 +1,17 @@
1
+ export type MediaAudioState = {
2
+ readonly isMutedForTimeline: boolean;
3
+ readonly isMutedForPlayback: boolean;
4
+ readonly shouldUseAudio: boolean;
5
+ };
6
+ export declare const resolveMediaAudioState: ({ muted, playerMuted, volume, isInsideFreeze, audioEnabled, }: {
7
+ readonly muted: boolean;
8
+ readonly playerMuted: boolean;
9
+ readonly volume: number | null;
10
+ readonly isInsideFreeze: boolean;
11
+ readonly audioEnabled: boolean;
12
+ }) => MediaAudioState;
13
+ export declare const useMediaAudioState: ({ muted, volume, audioEnabled, }: {
14
+ readonly muted: boolean;
15
+ readonly volume: number | null;
16
+ readonly audioEnabled: boolean;
17
+ }) => MediaAudioState;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMediaAudioState = exports.resolveMediaAudioState = void 0;
4
+ const timeline_position_state_js_1 = require("../timeline-position-state.js");
5
+ const volume_position_state_js_1 = require("../volume-position-state.js");
6
+ const resolveMediaAudioState = ({ muted, playerMuted, volume, isInsideFreeze, audioEnabled, }) => {
7
+ const isMutedForTimeline = muted || isInsideFreeze;
8
+ const isMutedForPlayback = isMutedForTimeline || playerMuted || (volume !== null && volume <= 0);
9
+ return {
10
+ isMutedForTimeline,
11
+ isMutedForPlayback,
12
+ shouldUseAudio: audioEnabled && !isMutedForPlayback,
13
+ };
14
+ };
15
+ exports.resolveMediaAudioState = resolveMediaAudioState;
16
+ const useMediaAudioState = ({ muted, volume, audioEnabled, }) => {
17
+ const [playerMuted] = (0, volume_position_state_js_1.usePlayerMutedState)();
18
+ const isInsideFreeze = (0, timeline_position_state_js_1.useIsInsideFreeze)();
19
+ return (0, exports.resolveMediaAudioState)({
20
+ muted,
21
+ playerMuted,
22
+ volume,
23
+ isInsideFreeze,
24
+ audioEnabled,
25
+ });
26
+ };
27
+ exports.useMediaAudioState = useMediaAudioState;
@@ -0,0 +1,19 @@
1
+ export type RegisteredFontFace = {
2
+ ascentOverride: string | null;
3
+ descentOverride: string | null;
4
+ display: 'auto' | 'block' | 'fallback' | 'optional' | 'swap' | null;
5
+ featureSettings: string | null;
6
+ fontFamily: string;
7
+ fontData: ArrayBuffer;
8
+ fontUrl: string;
9
+ format: 'woff2' | 'woff' | 'opentype' | 'truetype';
10
+ lineGapOverride: string | null;
11
+ style: string | null;
12
+ weight: string | null;
13
+ stretch: string | null;
14
+ unicodeRange: string | null;
15
+ variant: string | null;
16
+ };
17
+ export declare const fetchFontData: (fontUrl: string) => Promise<ArrayBuffer>;
18
+ export declare const registerFontFace: (fontFace: RegisteredFontFace) => void;
19
+ export declare const getRegisteredFontFaces: () => RegisteredFontFace[];
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRegisteredFontFaces = exports.registerFontFace = exports.fetchFontData = void 0;
4
+ const registeredFontFaces = [];
5
+ const fontDataByUrl = new Map();
6
+ const fetchFontData = (fontUrl) => {
7
+ const cached = fontDataByUrl.get(fontUrl);
8
+ if (cached) {
9
+ return cached;
10
+ }
11
+ const promise = fetch(fontUrl)
12
+ .then((response) => {
13
+ if (!response.ok) {
14
+ throw new Error(`Failed to load font ${JSON.stringify(fontUrl)}: ${response.status} ${response.statusText}`);
15
+ }
16
+ return response.arrayBuffer();
17
+ })
18
+ .catch((error) => {
19
+ fontDataByUrl.delete(fontUrl);
20
+ throw error;
21
+ });
22
+ fontDataByUrl.set(fontUrl, promise);
23
+ return promise;
24
+ };
25
+ exports.fetchFontData = fetchFontData;
26
+ const registerFontFace = (fontFace) => {
27
+ if (registeredFontFaces.some((registered) => registered.ascentOverride === fontFace.ascentOverride &&
28
+ registered.descentOverride === fontFace.descentOverride &&
29
+ registered.display === fontFace.display &&
30
+ registered.featureSettings === fontFace.featureSettings &&
31
+ registered.fontFamily === fontFace.fontFamily &&
32
+ registered.fontUrl === fontFace.fontUrl &&
33
+ registered.format === fontFace.format &&
34
+ registered.lineGapOverride === fontFace.lineGapOverride &&
35
+ registered.style === fontFace.style &&
36
+ registered.weight === fontFace.weight &&
37
+ registered.stretch === fontFace.stretch &&
38
+ registered.unicodeRange === fontFace.unicodeRange &&
39
+ registered.variant === fontFace.variant)) {
40
+ return;
41
+ }
42
+ registeredFontFaces.push(fontFace);
43
+ };
44
+ exports.registerFontFace = registerFontFace;
45
+ const getRegisteredFontFaces = () => {
46
+ return registeredFontFaces.slice();
47
+ };
48
+ exports.getRegisteredFontFaces = getRegisteredFontFaces;
@@ -46,6 +46,7 @@ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
46
46
  return {
47
47
  ...timelineContext,
48
48
  isPlaying: () => false,
49
+ isInsideFreeze: true,
49
50
  frame: {
50
51
  [videoConfig.id]: frameToFreeze + relativeFrom,
51
52
  },
@@ -42,6 +42,12 @@ export declare const Internals: {
42
42
  readonly useFrameForVolumeProp: (behavior: import("./index.js").LoopVolumeCurveBehavior) => number;
43
43
  readonly useTimelinePosition: () => number;
44
44
  readonly useAbsoluteTimelinePosition: () => number;
45
+ readonly useIsInsideFreeze: () => boolean;
46
+ readonly useMediaAudioState: ({ muted, volume, audioEnabled, }: {
47
+ readonly muted: boolean;
48
+ readonly volume: number | null;
49
+ readonly audioEnabled: boolean;
50
+ }) => import("./audio/use-media-audio-state.js").MediaAudioState;
45
51
  readonly evaluateVolume: ({ frame, volume, mediaVolume, }: {
46
52
  frame: number;
47
53
  volume: import("./volume-prop.js").VolumeProp | undefined;
@@ -816,6 +822,7 @@ export declare const Internals: {
816
822
  readonly SetMediaVolumeContext: import("react").Context<SetMediaVolumeContextValue>;
817
823
  readonly getRemotionEnvironment: () => RemotionEnvironment;
818
824
  readonly SharedAudioContext: import("react").Context<{
825
+ sampleRate: number;
819
826
  audioContext: AudioContext | null;
820
827
  getAudioContextState: () => RemotionAudioContextState | null;
821
828
  gainNode: GainNode | null;
@@ -41,6 +41,7 @@ const get_duration_in_seconds_js_1 = require("./animated-image/get-duration-in-s
41
41
  const AudioForPreview_js_1 = require("./audio/AudioForPreview.js");
42
42
  const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
43
43
  const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
44
+ const use_media_audio_state_js_1 = require("./audio/use-media-audio-state.js");
44
45
  const buffering_js_1 = require("./buffering.js");
45
46
  const calculate_media_duration_js_1 = require("./calculate-media-duration.js");
46
47
  const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
@@ -143,6 +144,8 @@ exports.Internals = {
143
144
  useFrameForVolumeProp: use_audio_frame_js_1.useFrameForVolumeProp,
144
145
  useTimelinePosition: TimelinePosition.useTimelinePosition,
145
146
  useAbsoluteTimelinePosition: TimelinePosition.useAbsoluteTimelinePosition,
147
+ useIsInsideFreeze: TimelinePosition.useIsInsideFreeze,
148
+ useMediaAudioState: use_media_audio_state_js_1.useMediaAudioState,
146
149
  evaluateVolume: volume_prop_js_1.evaluateVolume,
147
150
  getAbsoluteSrc: absolute_src_js_1.getAbsoluteSrc,
148
151
  getAnimatedImageDurationInSeconds: get_duration_in_seconds_js_1.getAnimatedImageDurationInSeconds,
@@ -273,4 +273,7 @@ export declare const NoReactInternals: {
273
273
  };
274
274
  parseScaleValue: (value: unknown) => import("./scale-value").ScaleValue;
275
275
  serializeScaleValue: ([x, y, z]: import("./scale-value").ScaleValue) => string | number;
276
+ getRegisteredFontFaces: () => import("./font-face-registry").RegisteredFontFace[];
277
+ registerFontFace: (fontFace: import("./font-face-registry").RegisteredFontFace) => void;
278
+ fetchFontData: (fontUrl: string) => Promise<ArrayBuffer>;
276
279
  };
@@ -9,6 +9,7 @@ const random_js_1 = require("./random.js");
9
9
  Object.defineProperty(exports, "random", { enumerable: true, get: function () { return random_js_1.random; } });
10
10
  const delay_render_constants_1 = require("./delay-render-constants");
11
11
  const find_props_to_delete_1 = require("./find-props-to-delete");
12
+ const font_face_registry_1 = require("./font-face-registry");
12
13
  const input_props_serialization_1 = require("./input-props-serialization");
13
14
  const input_props_serialization_js_1 = require("./input-props-serialization.js");
14
15
  const interactivity_schema_1 = require("./interactivity-schema");
@@ -56,4 +57,7 @@ exports.NoReactInternals = {
56
57
  sequenceSchema: interactivity_schema_1.sequenceSchema,
57
58
  parseScaleValue: scale_value_1.parseScaleValue,
58
59
  serializeScaleValue: scale_value_1.serializeScaleValue,
60
+ getRegisteredFontFaces: font_face_registry_1.getRegisteredFontFaces,
61
+ registerFontFace: font_face_registry_1.registerFontFace,
62
+ fetchFontData: font_face_registry_1.fetchFontData,
59
63
  };
@@ -11,6 +11,7 @@ export declare const clampFrameToCompositionRange: (frame: number, durationInFra
11
11
  export declare const useTimelineContext: () => TimelineContextValue;
12
12
  export declare const usePlaybackRate: () => PlaybackRateContextValue;
13
13
  export declare const useTimelinePosition: () => number;
14
+ export declare const useIsInsideFreeze: () => boolean;
14
15
  export declare const useAbsoluteTimelinePosition: () => number;
15
16
  export declare const useTimelineSetFrame: () => (u: import("react").SetStateAction<Record<string, number>>) => void;
16
17
  export { usePlaying } from './use-playing.js';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBuffering = exports.usePlaying = exports.useTimelineSetFrame = exports.useAbsoluteTimelinePosition = exports.useTimelinePosition = exports.usePlaybackRate = exports.useTimelineContext = exports.clampFrameToCompositionRange = exports.getFrameForComposition = exports.getInitialFrameState = exports.persistCurrentFrame = void 0;
3
+ exports.useBuffering = exports.usePlaying = exports.useTimelineSetFrame = exports.useAbsoluteTimelinePosition = exports.useIsInsideFreeze = exports.useTimelinePosition = exports.usePlaybackRate = exports.useTimelineContext = exports.clampFrameToCompositionRange = exports.getFrameForComposition = exports.getInitialFrameState = exports.persistCurrentFrame = void 0;
4
4
  const react_1 = require("react");
5
5
  const TimelineContext_js_1 = require("./TimelineContext.js");
6
6
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
@@ -69,6 +69,10 @@ const useTimelinePosition = () => {
69
69
  return useTimelinePositionFromContext(state);
70
70
  };
71
71
  exports.useTimelinePosition = useTimelinePosition;
72
+ const useIsInsideFreeze = () => {
73
+ return (0, exports.useTimelineContext)().isInsideFreeze;
74
+ };
75
+ exports.useIsInsideFreeze = useIsInsideFreeze;
72
76
  const useAbsoluteTimelinePosition = () => {
73
77
  const state = (0, react_1.useContext)(TimelineContext_js_1.AbsoluteTimeContext);
74
78
  if (state === null) {
@@ -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.523";
6
+ export declare const VERSION = "4.0.525";
@@ -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.523';
10
+ exports.VERSION = '4.0.525';
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const absolute_src_js_1 = require("../absolute-src.js");
7
7
  const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
8
+ const use_media_audio_state_js_1 = require("../audio/use-media-audio-state.js");
8
9
  const cancel_render_js_1 = require("../cancel-render.js");
9
10
  const default_css_js_1 = require("../default-css.js");
10
11
  const Img_js_1 = require("../Img.js");
@@ -15,6 +16,7 @@ const timeline_position_state_js_1 = require("../timeline-position-state.js");
15
16
  const truthy_js_1 = require("../truthy.js");
16
17
  const use_current_frame_js_1 = require("../use-current-frame.js");
17
18
  const use_delay_render_js_1 = require("../use-delay-render.js");
19
+ const use_media_enabled_js_1 = require("../use-media-enabled.js");
18
20
  const use_unsafe_video_config_js_1 = require("../use-unsafe-video-config.js");
19
21
  const volume_prop_js_1 = require("../volume-prop.js");
20
22
  const volume_safeguard_js_1 = require("../volume-safeguard.js");
@@ -42,27 +44,27 @@ crossOrigin, audioStreamIndex, preservePitch: _preservePitch, ...props }) => {
42
44
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
43
45
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
44
46
  ]);
45
- if (!videoConfig) {
46
- throw new Error('No video config found');
47
- }
48
47
  const volume = (0, volume_prop_js_1.evaluateVolume)({
49
48
  volume: volumeProp,
50
49
  frame: volumePropsFrame,
51
50
  mediaVolume: 1,
52
51
  });
53
52
  (0, volume_safeguard_js_1.warnAboutTooHighVolume)(volume);
53
+ const audioEnabled = (0, use_media_enabled_js_1.useAudioEnabled)();
54
+ const { shouldUseAudio } = (0, use_media_audio_state_js_1.useMediaAudioState)({
55
+ muted,
56
+ volume,
57
+ audioEnabled,
58
+ });
59
+ if (!videoConfig) {
60
+ throw new Error('No video config found');
61
+ }
54
62
  (0, react_1.useEffect)(() => {
55
63
  var _a;
56
64
  if (!src) {
57
65
  throw new Error('No src passed');
58
66
  }
59
- if (!window.remotion_audioEnabled) {
60
- return;
61
- }
62
- if (muted) {
63
- return;
64
- }
65
- if (volume <= 0) {
67
+ if (!shouldUseAudio) {
66
68
  return;
67
69
  }
68
70
  registerRenderAsset({
@@ -79,7 +81,7 @@ crossOrigin, audioStreamIndex, preservePitch: _preservePitch, ...props }) => {
79
81
  });
80
82
  return () => unregisterRenderAsset(id);
81
83
  }, [
82
- muted,
84
+ shouldUseAudio,
83
85
  src,
84
86
  registerRenderAsset,
85
87
  id,
@@ -39,6 +39,7 @@ const react_1 = __importStar(require("react"));
39
39
  const shared_audio_tags_js_1 = require("../audio/shared-audio-tags.js");
40
40
  const shared_element_source_node_js_1 = require("../audio/shared-element-source-node.js");
41
41
  const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
42
+ const use_media_audio_state_js_1 = require("../audio/use-media-audio-state.js");
42
43
  const get_cross_origin_value_js_1 = require("../get-cross-origin-value.js");
43
44
  const log_level_context_js_1 = require("../log-level-context.js");
44
45
  const playback_logging_js_1 = require("../playback-logging.js");
@@ -111,12 +112,16 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
111
112
  throw new Error('acceptableTimeShift has been removed. Use acceptableTimeShiftInSeconds instead.');
112
113
  }
113
114
  const [mediaVolume] = (0, volume_position_state_js_1.useMediaVolumeState)();
114
- const [playerMuted] = (0, volume_position_state_js_1.usePlayerMutedState)();
115
115
  const userPreferredVolume = (0, volume_prop_js_1.evaluateVolume)({
116
116
  frame: volumePropFrame,
117
117
  volume,
118
118
  mediaVolume,
119
119
  });
120
+ const { isMutedForTimeline, isMutedForPlayback } = (0, use_media_audio_state_js_1.useMediaAudioState)({
121
+ muted: muted !== null && muted !== void 0 ? muted : false,
122
+ volume: userPreferredVolume,
123
+ audioEnabled: true,
124
+ });
120
125
  (0, volume_safeguard_js_1.warnAboutTooHighVolume)(userPreferredVolume);
121
126
  const getStack = (0, react_1.useCallback)(() => {
122
127
  return _remotionInternalStack !== null && _remotionInternalStack !== void 0 ? _remotionInternalStack : null;
@@ -138,7 +143,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
138
143
  ? 'https://www.remotion.dev/docs/offthreadvideo'
139
144
  : 'https://www.remotion.dev/docs/html5-video',
140
145
  refForOutline: videoRef,
141
- muted: muted !== null && muted !== void 0 ? muted : false,
146
+ muted: isMutedForTimeline,
142
147
  });
143
148
  // putting playback before useVolume
144
149
  // because volume looks at playbackrate
@@ -284,7 +289,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
284
289
  requestsVideoFrame: Boolean(onVideoFrame),
285
290
  isClientSideRendering: false,
286
291
  });
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 }));
292
+ const video = (jsx_runtime_1.jsx("video", { ...nativeProps, ref: videoRef, muted: isMutedForPlayback, playsInline: true, src: actualSrc, loop: _remotionInternalNativeLoopPassed, style: actualStyle, disableRemotePlayback: true, crossOrigin: crossOriginValue, controls: false }));
288
293
  return isStudio ? (jsx_runtime_1.jsx(sequence_order_marker_js_1.SequenceOrderMarker, { sequenceId: timelineId, children: video })) : (video);
289
294
  };
290
295
  exports.VideoForPreview = (0, react_1.forwardRef)(VideoForDevelopmentRefForwardingFunction);
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const absolute_src_js_1 = require("../absolute-src.js");
7
7
  const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
8
+ const use_media_audio_state_js_1 = require("../audio/use-media-audio-state.js");
8
9
  const is_approximately_the_same_js_1 = require("../is-approximately-the-same.js");
9
10
  const log_level_context_js_1 = require("../log-level-context.js");
10
11
  const random_js_1 = require("../random.js");
@@ -13,6 +14,7 @@ const SequenceContext_js_1 = require("../SequenceContext.js");
13
14
  const timeline_position_state_js_1 = require("../timeline-position-state.js");
14
15
  const use_current_frame_js_1 = require("../use-current-frame.js");
15
16
  const use_delay_render_js_1 = require("../use-delay-render.js");
17
+ const use_media_enabled_js_1 = require("../use-media-enabled.js");
16
18
  const use_remotion_environment_js_1 = require("../use-remotion-environment.js");
17
19
  const use_unsafe_video_config_js_1 = require("../use-unsafe-video-config.js");
18
20
  const volume_prop_js_1 = require("../volume-prop.js");
@@ -22,6 +24,7 @@ const get_current_time_js_1 = require("./get-current-time.js");
22
24
  const MediaPlaybackError_js_1 = require("./MediaPlaybackError.js");
23
25
  const seek_until_right_js_1 = require("./seek-until-right.js");
24
26
  const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAmplificationDuringRender, playbackRate, onDuration, toneFrequency, name, acceptableTimeShiftInSeconds, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, audioStreamIndex, onVideoFrame, preservePitch: _preservePitch, ...props }, ref) => {
27
+ var _a;
25
28
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
26
29
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
27
30
  const volumePropsFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
@@ -45,27 +48,27 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
45
48
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
46
49
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
47
50
  ]);
48
- if (!videoConfig) {
49
- throw new Error('No video config found');
50
- }
51
51
  const volume = (0, volume_prop_js_1.evaluateVolume)({
52
52
  volume: volumeProp,
53
53
  frame: volumePropsFrame,
54
54
  mediaVolume: 1,
55
55
  });
56
56
  (0, volume_safeguard_js_1.warnAboutTooHighVolume)(volume);
57
+ const audioEnabled = (0, use_media_enabled_js_1.useAudioEnabled)();
58
+ const { shouldUseAudio } = (0, use_media_audio_state_js_1.useMediaAudioState)({
59
+ muted: (_a = props.muted) !== null && _a !== void 0 ? _a : false,
60
+ volume,
61
+ audioEnabled,
62
+ });
63
+ if (!videoConfig) {
64
+ throw new Error('No video config found');
65
+ }
57
66
  (0, react_1.useEffect)(() => {
58
67
  var _a;
59
68
  if (!props.src) {
60
69
  throw new Error('No src passed');
61
70
  }
62
- if (props.muted) {
63
- return;
64
- }
65
- if (volume <= 0) {
66
- return;
67
- }
68
- if (!window.remotion_audioEnabled) {
71
+ if (!shouldUseAudio) {
69
72
  return;
70
73
  }
71
74
  registerRenderAsset({
@@ -82,7 +85,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
82
85
  });
83
86
  return () => unregisterRenderAsset(id);
84
87
  }, [
85
- props.muted,
88
+ shouldUseAudio,
86
89
  props.src,
87
90
  registerRenderAsset,
88
91
  id,