@remotion/player 4.0.534 → 4.0.536

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.
@@ -52,6 +52,7 @@ export type PlayerProps<Schema extends AnyZodObject, Props extends Record<string
52
52
  readonly showPlaybackRateControl?: boolean | number[];
53
53
  readonly posterFillMode?: PosterFillMode;
54
54
  readonly bufferStateDelayInMilliseconds?: number;
55
+ readonly defaultPremountInSeconds?: number;
55
56
  readonly hideControlsWhenPointerDoesntMove?: boolean | number;
56
57
  readonly overflowVisible?: boolean;
57
58
  readonly browserMediaControlsBehavior?: BrowserMediaControlsBehavior;
@@ -59,15 +59,22 @@ const componentOrNullIfLazy = (props) => {
59
59
  };
60
60
  exports.componentOrNullIfLazy = componentOrNullIfLazy;
61
61
  const TimelineSequenceObserverComponent = ({ onTimelineSequenceChange }) => {
62
- const sequences = remotion_1.Internals.useSequenceManagerSequences();
63
- (0, react_1.useEffect)(() => {
64
- onTimelineSequenceChange(sequences);
65
- }, [onTimelineSequenceChange, sequences]);
62
+ const registry = react_1.default.useContext(remotion_1.Internals.SequenceRegistryContext);
63
+ (0, react_1.useLayoutEffect)(() => {
64
+ if (registry === null) {
65
+ throw new Error('Timeline sequence observer requires a sequence registry');
66
+ }
67
+ const publish = () => onTimelineSequenceChange(registry.getSnapshot());
68
+ const unsubscribe = registry.subscribe(publish);
69
+ publish();
70
+ return unsubscribe;
71
+ }, [onTimelineSequenceChange, registry]);
66
72
  return null;
67
73
  };
68
74
  const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = no_react_1.NoReactInternals.ENABLE_V5_BREAKING_CHANGES
69
75
  ? 0
70
- : 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, renderVolumeSlider, renderCustomControls, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'playback', sampleRate = 48000, volumePersistenceKey, initialVolume, _experimentalKeepAudioContextAlive = false, ...componentProps }, ref) => {
76
+ : 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, renderVolumeSlider, renderCustomControls, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, defaultPremountInSeconds = no_react_1.NoReactInternals.DEFAULT_PREMOUNT_IN_SECONDS, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'playback', sampleRate = 48000, volumePersistenceKey, initialVolume, _experimentalKeepAudioContextAlive = false, ...componentProps }, ref) => {
77
+ no_react_1.NoReactInternals.validateDefaultPremountInSeconds(defaultPremountInSeconds);
71
78
  if (typeof window !== 'undefined') {
72
79
  window.remotion_isPlayer = true;
73
80
  }
@@ -251,11 +258,8 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
251
258
  const player = (jsx_runtime_1.jsx(remotion_1.Internals.IsPlayerContextProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx_runtime_1.jsx(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, playbackRateContext: playbackRateContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, sampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, volumePersistenceKey: volumePersistenceKey, initialVolume: initialVolume, inputProps: actualInputProps, audioEnabled: true, children: jsx_runtime_1.jsx(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: jsx_runtime_1.jsx(PlayerUI_js_1.default, { ref: rootRef, posterFillMode: posterFillMode, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: actualInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
252
259
  ? clickToPlay
253
260
  : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: currentPlaybackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), showPosterWhenBuffering: Boolean(showPosterWhenBuffering), showPosterWhenBufferingAndPaused: Boolean(showPosterWhenBufferingAndPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null, renderMuteButton: renderMuteButton !== null && renderMuteButton !== void 0 ? renderMuteButton : null, renderVolumeSlider: renderVolumeSlider !== null && renderVolumeSlider !== void 0 ? renderVolumeSlider : null, renderCustomControls: renderCustomControls !== null && renderCustomControls !== void 0 ? renderCustomControls : null, alwaysShowControls: alwaysShowControls, showPlaybackRateControl: showPlaybackRateControl, bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds !== null && bufferStateDelayInMilliseconds !== void 0 ? bufferStateDelayInMilliseconds : 300, hideControlsWhenPointerDoesntMove: hideControlsWhenPointerDoesntMove, overflowVisible: overflowVisible, browserMediaControlsBehavior: browserMediaControlsBehavior, overrideInternalClassName: overrideInternalClassName !== null && overrideInternalClassName !== void 0 ? overrideInternalClassName : undefined, noSuspense: Boolean(noSuspense) }) }) }) }) }));
254
- if (!onTimelineSequenceChange) {
255
- return player;
256
- }
257
- return (jsx_runtime_1.jsx(remotion_1.Internals.SequenceRegistrationContext.Provider, { value: true, children: jsx_runtime_1.jsxs(remotion_1.Internals.SequenceManagerProvider, { children: [
258
- jsx_runtime_1.jsx(TimelineSequenceObserverComponent, { onTimelineSequenceChange: onTimelineSequenceChange }), player] }) }));
261
+ return (jsx_runtime_1.jsx(remotion_1.Internals.DefaultPremountContext.Provider, { value: defaultPremountInSeconds, children: onTimelineSequenceChange ? (jsx_runtime_1.jsx(remotion_1.Internals.SequenceRegistrationContext.Provider, { value: true, children: jsx_runtime_1.jsxs(remotion_1.Internals.SequenceManagerProvider, { children: [
262
+ jsx_runtime_1.jsx(TimelineSequenceObserverComponent, { onTimelineSequenceChange: onTimelineSequenceChange }), player] }) })) : (player) }));
259
263
  };
260
264
  const forward = react_1.forwardRef;
261
265
  /*
@@ -86,6 +86,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
86
86
  }, [player]);
87
87
  const { playerMuted, mediaVolume } = (0, react_1.useContext)(remotion_1.Internals.MediaVolumeContext);
88
88
  const canvasOverlay = (0, react_1.useContext)(canvas_overlay_context_js_1.CanvasOverlayContext);
89
+ const canvasContentRef = (0, react_1.useRef)(null);
89
90
  (0, react_1.useEffect)(() => {
90
91
  player.emitter.dispatchVolumeChange(mediaVolume);
91
92
  }, [player.emitter, mediaVolume]);
@@ -209,6 +210,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
209
210
  });
210
211
  }, [canvasSize, config]);
211
212
  const scale = (_b = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _b !== void 0 ? _b : 1;
213
+ const canvasContent = (0, react_1.useMemo)(() => ({ rootRef: canvasContentRef, scale }), [scale]);
212
214
  const initialScaleIgnored = (0, react_1.useRef)(false);
213
215
  (0, react_1.useEffect)(() => {
214
216
  if (!initialScaleIgnored.current) {
@@ -449,11 +451,12 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
449
451
  const { left, top, width, height, ...outerWithoutScale } = outer;
450
452
  const content = (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
451
453
  jsx_runtime_1.jsxs("div", { style: outer, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: [
452
- jsx_runtime_1.jsxs("div", { style: containerStyle, className: (0, player_css_classname_js_1.playerCssClassname)(overrideInternalClassName), children: [VideoComponent ? (jsx_runtime_1.jsx(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: jsx_runtime_1.jsx(remotion_1.Internals.CurrentScaleContext.Provider, { value: currentScale, children: jsx_runtime_1.jsx(canvas_overlay_context_js_1.CanvasOverlayContext.Provider, { value: null, children: jsx_runtime_1.jsx(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.props) !== null && _c !== void 0 ? _c : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) }) }) })) : null, shouldShowPoster && posterFillMode === 'composition-size' ? (jsx_runtime_1.jsx("div", { style: {
454
+ jsx_runtime_1.jsxs("div", { ref: canvasContentRef, style: containerStyle, className: (0, player_css_classname_js_1.playerCssClassname)(overrideInternalClassName), children: [VideoComponent ? (jsx_runtime_1.jsx(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: jsx_runtime_1.jsx(remotion_1.Internals.CurrentScaleContext.Provider, { value: currentScale, children: jsx_runtime_1.jsx(canvas_overlay_context_js_1.CanvasOverlayContext.Provider, { value: null, children: jsx_runtime_1.jsx(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.props) !== null && _c !== void 0 ? _c : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) }) }) })) : null, shouldShowPoster && posterFillMode === 'composition-size' ? (jsx_runtime_1.jsx("div", { style: {
453
455
  ...outerWithoutScale,
454
456
  width: config.width,
455
457
  height: config.height,
456
- }, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null] }), jsx_runtime_1.jsx(license_blacklist_js_1.RenderWarningIfBlacklist, {}), canvasOverlay] }), shouldShowPoster && posterFillMode === 'player-size' ? (jsx_runtime_1.jsx("div", { style: outer, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? (jsx_runtime_1.jsx(PlayerControls_js_1.Controls, { fps: config.fps, playing: playing, toggle: toggle, durationInFrames: config.durationInFrames, containerRef: container, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, inFrame: inFrame, outFrame: outFrame, initiallyShowControls: initiallyShowControls, canvasSize: canvasSize, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton, alwaysShowControls: alwaysShowControls, showPlaybackRateControl: showPlaybackRateControl, buffering: showBufferIndicator, hideControlsWhenPointerDoesntMove: hideControlsWhenPointerDoesntMove, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, onPointerDown: clickToPlay
458
+ }, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null] }), jsx_runtime_1.jsx(license_blacklist_js_1.RenderWarningIfBlacklist, {}), jsx_runtime_1.jsx(canvas_overlay_context_js_1.CanvasContentContext.Provider, { value: canvasContent, children: canvasOverlay })
459
+ ] }), shouldShowPoster && posterFillMode === 'player-size' ? (jsx_runtime_1.jsx("div", { style: outer, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? (jsx_runtime_1.jsx(PlayerControls_js_1.Controls, { fps: config.fps, playing: playing, toggle: toggle, durationInFrames: config.durationInFrames, containerRef: container, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, inFrame: inFrame, outFrame: outFrame, initiallyShowControls: initiallyShowControls, canvasSize: canvasSize, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton, alwaysShowControls: alwaysShowControls, showPlaybackRateControl: showPlaybackRateControl, buffering: showBufferIndicator, hideControlsWhenPointerDoesntMove: hideControlsWhenPointerDoesntMove, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, onPointerDown: clickToPlay
457
460
  ? handlePointerDown
458
461
  : undefined, renderMuteButton: renderMuteButton, renderVolumeSlider: renderVolumeSlider, renderCustomControls: renderCustomControls })) : null] }));
459
462
  if (noSuspense || (is_node_js_1.IS_NODE && !doesReactVersionSupportSuspense)) {
@@ -93,6 +93,6 @@ const SharedPlayerContexts = ({ children, timelineContext, playbackRateContext,
93
93
  isReadOnlyStudio: false,
94
94
  };
95
95
  }, []);
96
- return (jsx_runtime_1.jsx(remotion_1.Internals.RemotionEnvironmentContext.Provider, { value: env, children: jsx_runtime_1.jsx(remotion_1.Internals.LogLevelContext.Provider, { value: logLevelContext, children: jsx_runtime_1.jsx(remotion_1.Internals.CanUseRemotionHooksProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.AbsoluteTimeContext.Provider, { value: timelineContext, children: jsx_runtime_1.jsx(remotion_1.Internals.PlaybackRateContext.Provider, { value: playbackRateContext, children: jsx_runtime_1.jsx(remotion_1.Internals.TimelineContext.Provider, { value: timelineContext, children: jsx_runtime_1.jsx(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: jsx_runtime_1.jsx(remotion_1.Internals.PrefetchProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.DurationsContextProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: jsx_runtime_1.jsx(remotion_1.Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: jsx_runtime_1.jsx(remotion_1.Internals.BufferingProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: shouldCreateAudioContext, previewSampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, children: jsx_runtime_1.jsx(remotion_1.Internals.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }));
96
+ return (jsx_runtime_1.jsx(remotion_1.Internals.RemotionEnvironmentContext.Provider, { value: env, children: jsx_runtime_1.jsx(remotion_1.Internals.LogLevelContext.Provider, { value: logLevelContext, children: jsx_runtime_1.jsx(remotion_1.Internals.CanUseRemotionHooksProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.AbsoluteTimeContext.Provider, { value: timelineContext, children: jsx_runtime_1.jsx(remotion_1.Internals.PlaybackRateContext.Provider, { value: playbackRateContext, children: jsx_runtime_1.jsx(remotion_1.Internals.TimelineContext.Provider, { value: timelineContext, children: jsx_runtime_1.jsx(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: jsx_runtime_1.jsx(remotion_1.Internals.VideoProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.PrefetchProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.DurationsContextProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: jsx_runtime_1.jsx(remotion_1.Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: jsx_runtime_1.jsx(remotion_1.Internals.BufferingProvider, { children: jsx_runtime_1.jsx(remotion_1.Internals.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: shouldCreateAudioContext, previewSampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, children: jsx_runtime_1.jsx(remotion_1.Internals.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
97
97
  };
98
98
  exports.SharedPlayerContexts = SharedPlayerContexts;
@@ -1,2 +1,6 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ReactNode, RefObject } from 'react';
2
2
  export declare const CanvasOverlayContext: import("react").Context<ReactNode>;
3
+ export declare const CanvasContentContext: import("react").Context<{
4
+ readonly rootRef: RefObject<HTMLDivElement | null>;
5
+ readonly scale: number;
6
+ } | null>;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CanvasOverlayContext = void 0;
3
+ exports.CanvasContentContext = exports.CanvasOverlayContext = void 0;
4
4
  const react_1 = require("react");
5
5
  // Canvas supplies its authoring UI here so it shares the Player's timeline,
6
6
  // clipping and fullscreen container without wrapping the user's composition.
7
7
  exports.CanvasOverlayContext = (0, react_1.createContext)(null);
8
+ // The SDK measures against the unscaled composition and projects into the overlay.
9
+ exports.CanvasContentContext = (0, react_1.createContext)(null);
@@ -54,4 +54,8 @@ export declare const PlayerInternals: {
54
54
  }>;
55
55
  TimelineSequenceObserverContext: import("react").Context<import("./timeline-sequence-observer-context.js").TimelineSequenceObserver | null>;
56
56
  CanvasOverlayContext: import("react").Context<import("react").ReactNode>;
57
+ CanvasContentContext: import("react").Context<{
58
+ readonly rootRef: import("react").RefObject<HTMLDivElement | null>;
59
+ readonly scale: number;
60
+ } | null>;
57
61
  };
package/dist/cjs/index.js CHANGED
@@ -30,4 +30,5 @@ exports.PlayerInternals = {
30
30
  BufferingIndicator: BufferingIndicator_js_1.BufferingIndicator,
31
31
  TimelineSequenceObserverContext: timeline_sequence_observer_context_js_1.TimelineSequenceObserverContext,
32
32
  CanvasOverlayContext: canvas_overlay_context_js_1.CanvasOverlayContext,
33
+ CanvasContentContext: canvas_overlay_context_js_1.CanvasContentContext,
33
34
  };
@@ -1,4 +1,3 @@
1
- export declare const ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
2
1
  export declare const setGlobalTimeAnchor: ({ audioContext, audioSyncAnchor, absoluteTimeInSeconds, globalPlaybackRate, logLevel, force, }: {
3
2
  audioContext: AudioContext;
4
3
  audioSyncAnchor: {
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setGlobalTimeAnchor = exports.ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = void 0;
3
+ exports.setGlobalTimeAnchor = void 0;
4
4
  const remotion_1 = require("remotion");
5
- exports.ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
6
5
  const setGlobalTimeAnchor = ({ audioContext, audioSyncAnchor, absoluteTimeInSeconds, globalPlaybackRate, logLevel, force, }) => {
7
6
  const newAnchor = audioContext.currentTime - absoluteTimeInSeconds / globalPlaybackRate;
8
7
  const shift = newAnchor - audioSyncAnchor.value;
9
- const { outputLatency } = audioContext;
10
- const safeOutputLatency = outputLatency === 0 ? 0.3 : outputLatency;
11
- const latency = audioContext.baseLatency + safeOutputLatency;
8
+ const tolerance = remotion_1.Internals.getAudioSyncAnchorTolerance(audioContext);
12
9
  // Skip small shifts to avoid audio glitches from frame-quantized re-anchoring
13
- if (Math.abs(shift) < exports.ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT + latency && !force) {
10
+ if (Math.abs(shift) < tolerance && !force) {
14
11
  return false;
15
12
  }
16
13
  // If force is true, but shift is zero, no change is needed
@@ -30,7 +30,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
30
30
  const setFrameFromPlayback = remotion_1.Internals.Timeline.useTimelineSetFrameWithoutSeek();
31
31
  const sharedAudioContext = (0, react_2.useContext)(remotion_1.Internals.SharedAudioContext);
32
32
  const { setPlayerMuted } = (0, react_2.useContext)(remotion_1.Internals.SetMediaVolumeContext);
33
- const { isBuffering, subscribeBuffering } = (0, react_2.useContext)(remotion_1.Internals.SetTimelineContext);
33
+ const { isBuffering, subscribeBuffering, seek } = (0, react_2.useContext)(remotion_1.Internals.SetTimelineContext);
34
34
  const logLevel = remotion_1.Internals.useLogLevel();
35
35
  // requestAnimationFrame() does not work if the tab is not active.
36
36
  // This means that audio will keep playing even if it has ended.
@@ -112,6 +112,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
112
112
  ]);
113
113
  (0, react_2.useEffect)(() => {
114
114
  var _a;
115
+ var _b;
115
116
  if (!config) {
116
117
  return;
117
118
  }
@@ -147,6 +148,8 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
147
148
  let reqAnimFrameCall = null;
148
149
  let startedTime = performance.now();
149
150
  let framesAdvanced = 0;
151
+ let playbackFrame = getCurrentFrame();
152
+ let lastSeekRevision = (_b = seek === null || seek === void 0 ? void 0 : seek.revision.current) !== null && _b !== void 0 ? _b : null;
150
153
  const cancelQueuedFrame = () => {
151
154
  if (reqAnimFrameCall !== null) {
152
155
  if (reqAnimFrameCall.type === 'raf') {
@@ -163,6 +166,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
163
166
  };
164
167
  const callback = () => {
165
168
  var _a, _b;
169
+ var _c;
166
170
  if (hasBeenStopped) {
167
171
  return;
168
172
  }
@@ -176,7 +180,13 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
176
180
  const time = performance.now() - startedTime;
177
181
  const actualLastFrame = outFrame !== null && outFrame !== void 0 ? outFrame : config.durationInFrames - 1;
178
182
  const actualFirstFrame = inFrame !== null && inFrame !== void 0 ? inFrame : 0;
179
- const currentFrame = getCurrentFrame();
183
+ const seekRevision = (_c = seek === null || seek === void 0 ? void 0 : seek.revision.current) !== null && _c !== void 0 ? _c : null;
184
+ if (seekRevision !== lastSeekRevision) {
185
+ playbackFrame = getCurrentFrame();
186
+ lastSeekRevision = seekRevision;
187
+ }
188
+ // React may not have committed the previous playback update yet.
189
+ const currentFrame = playbackFrame;
180
190
  const { nextFrame, framesToAdvance, hasEnded } = (0, calculate_next_frame_js_1.calculateNextFrame)({
181
191
  time,
182
192
  currentFrame,
@@ -188,10 +198,15 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
188
198
  shouldLoop: loop,
189
199
  });
190
200
  framesAdvanced += framesToAdvance;
191
- if (nextFrame !== getCurrentFrame() &&
192
- (!hasEnded || moveToBeginningWhenEnded) &&
193
- !isBuffering()) {
194
- setFrameFromPlayback((c) => ({ ...c, [config.id]: nextFrame }));
201
+ // A late callback can skip the endpoint. Hold that exact frame on end.
202
+ const frameToDisplay = hasEnded && !moveToBeginningWhenEnded
203
+ ? playbackRate > 0
204
+ ? actualLastFrame
205
+ : actualFirstFrame
206
+ : nextFrame;
207
+ if (frameToDisplay !== currentFrame && !isBuffering()) {
208
+ playbackFrame = frameToDisplay;
209
+ setFrameFromPlayback((c) => ({ ...c, [config.id]: frameToDisplay }));
195
210
  }
196
211
  if (hasEnded) {
197
212
  stop();
@@ -289,6 +304,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
289
304
  sharedAudioContext,
290
305
  setPlayerMuted,
291
306
  subscribeBuffering,
307
+ seek,
292
308
  logLevel,
293
309
  muted,
294
310
  ]);
@@ -350,6 +350,7 @@ var calculateOuter = ({
350
350
  // src/canvas-overlay-context.ts
351
351
  import { createContext as createContext2 } from "react";
352
352
  var CanvasOverlayContext = createContext2(null);
353
+ var CanvasContentContext = createContext2(null);
353
354
 
354
355
  // src/emitter-context.ts
355
356
  import React from "react";
@@ -910,7 +911,6 @@ var useIsBackgrounded = () => {
910
911
 
911
912
  // src/set-global-time-anchor.ts
912
913
  import { Internals as Internals5 } from "remotion";
913
- var ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT = 0.1;
914
914
  var setGlobalTimeAnchor = ({
915
915
  audioContext,
916
916
  audioSyncAnchor,
@@ -921,10 +921,8 @@ var setGlobalTimeAnchor = ({
921
921
  }) => {
922
922
  const newAnchor = audioContext.currentTime - absoluteTimeInSeconds / globalPlaybackRate;
923
923
  const shift = newAnchor - audioSyncAnchor.value;
924
- const { outputLatency } = audioContext;
925
- const safeOutputLatency = outputLatency === 0 ? 0.3 : outputLatency;
926
- const latency = audioContext.baseLatency + safeOutputLatency;
927
- if (Math.abs(shift) < ALLOWED_GLOBAL_TIME_ANCHOR_SHIFT + latency && !force) {
924
+ const tolerance = Internals5.getAudioSyncAnchorTolerance(audioContext);
925
+ if (Math.abs(shift) < tolerance && !force) {
928
926
  return false;
929
927
  }
930
928
  if (Math.abs(shift) < Number.EPSILON) {
@@ -962,7 +960,7 @@ var usePlayback = ({
962
960
  const setFrameFromPlayback = Internals6.Timeline.useTimelineSetFrameWithoutSeek();
963
961
  const sharedAudioContext = useContext3(Internals6.SharedAudioContext);
964
962
  const { setPlayerMuted } = useContext3(Internals6.SetMediaVolumeContext);
965
- const { isBuffering, subscribeBuffering } = useContext3(Internals6.SetTimelineContext);
963
+ const { isBuffering, subscribeBuffering, seek } = useContext3(Internals6.SetTimelineContext);
966
964
  const logLevel = Internals6.useLogLevel();
967
965
  const isBackgroundedRef = useIsBackgrounded();
968
966
  const lastTimeUpdateTimestamp = useRef4(0);
@@ -1061,6 +1059,8 @@ var usePlayback = ({
1061
1059
  let reqAnimFrameCall = null;
1062
1060
  let startedTime = performance.now();
1063
1061
  let framesAdvanced = 0;
1062
+ let playbackFrame = getCurrentFrame();
1063
+ let lastSeekRevision = seek?.revision.current ?? null;
1064
1064
  const cancelQueuedFrame = () => {
1065
1065
  if (reqAnimFrameCall !== null) {
1066
1066
  if (reqAnimFrameCall.type === "raf") {
@@ -1088,7 +1088,12 @@ var usePlayback = ({
1088
1088
  const time = performance.now() - startedTime;
1089
1089
  const actualLastFrame = outFrame ?? config.durationInFrames - 1;
1090
1090
  const actualFirstFrame = inFrame ?? 0;
1091
- const currentFrame = getCurrentFrame();
1091
+ const seekRevision = seek?.revision.current ?? null;
1092
+ if (seekRevision !== lastSeekRevision) {
1093
+ playbackFrame = getCurrentFrame();
1094
+ lastSeekRevision = seekRevision;
1095
+ }
1096
+ const currentFrame = playbackFrame;
1092
1097
  const { nextFrame, framesToAdvance, hasEnded } = calculateNextFrame({
1093
1098
  time,
1094
1099
  currentFrame,
@@ -1100,8 +1105,10 @@ var usePlayback = ({
1100
1105
  shouldLoop: loop
1101
1106
  });
1102
1107
  framesAdvanced += framesToAdvance;
1103
- if (nextFrame !== getCurrentFrame() && (!hasEnded || moveToBeginningWhenEnded) && !isBuffering()) {
1104
- setFrameFromPlayback((c) => ({ ...c, [config.id]: nextFrame }));
1108
+ const frameToDisplay = hasEnded && !moveToBeginningWhenEnded ? playbackRate > 0 ? actualLastFrame : actualFirstFrame : nextFrame;
1109
+ if (frameToDisplay !== currentFrame && !isBuffering()) {
1110
+ playbackFrame = frameToDisplay;
1111
+ setFrameFromPlayback((c) => ({ ...c, [config.id]: frameToDisplay }));
1105
1112
  }
1106
1113
  if (hasEnded) {
1107
1114
  stop();
@@ -1190,6 +1197,7 @@ var usePlayback = ({
1190
1197
  sharedAudioContext,
1191
1198
  setPlayerMuted,
1192
1199
  subscribeBuffering,
1200
+ seek,
1193
1201
  logLevel,
1194
1202
  muted
1195
1203
  ]);
@@ -2575,7 +2583,7 @@ if (reactVersion === "0") {
2575
2583
  var doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
2576
2584
  var PlayerUI = ({
2577
2585
  controls,
2578
- style: style2,
2586
+ style,
2579
2587
  loop,
2580
2588
  autoPlay,
2581
2589
  allowFullscreen,
@@ -2588,7 +2596,7 @@ var PlayerUI = ({
2588
2596
  playbackRate,
2589
2597
  renderLoading,
2590
2598
  renderPoster,
2591
- className: className2,
2599
+ className,
2592
2600
  moveToBeginningWhenEnded,
2593
2601
  showPosterWhenUnplayed,
2594
2602
  showPosterWhenEnded,
@@ -2643,6 +2651,7 @@ var PlayerUI = ({
2643
2651
  }, [player]);
2644
2652
  const { playerMuted, mediaVolume } = useContext4(Internals11.MediaVolumeContext);
2645
2653
  const canvasOverlay = useContext4(CanvasOverlayContext);
2654
+ const canvasContentRef = useRef10(null);
2646
2655
  useEffect12(() => {
2647
2656
  player.emitter.dispatchVolumeChange(mediaVolume);
2648
2657
  }, [player.emitter, mediaVolume]);
@@ -2751,6 +2760,7 @@ var PlayerUI = ({
2751
2760
  });
2752
2761
  }, [canvasSize, config]);
2753
2762
  const scale = layout?.scale ?? 1;
2763
+ const canvasContent = useMemo12(() => ({ rootRef: canvasContentRef, scale }), [scale]);
2754
2764
  const initialScaleIgnored = useRef10(false);
2755
2765
  useEffect12(() => {
2756
2766
  if (!initialScaleIgnored.current) {
@@ -2883,15 +2893,15 @@ var PlayerUI = ({
2883
2893
  return calculateOuterStyle({
2884
2894
  canvasSize,
2885
2895
  config,
2886
- style: style2,
2896
+ style,
2887
2897
  overflowVisible,
2888
2898
  layout
2889
2899
  });
2890
- }, [canvasSize, config, layout, overflowVisible, style2]);
2900
+ }, [canvasSize, config, layout, overflowVisible, style]);
2891
2901
  const outer = useMemo12(() => {
2892
2902
  return calculateOuter({ config, layout, scale, overflowVisible });
2893
2903
  }, [config, layout, overflowVisible, scale]);
2894
- const containerStyle3 = useMemo12(() => {
2904
+ const containerStyle = useMemo12(() => {
2895
2905
  return calculateContainerStyle({
2896
2906
  config,
2897
2907
  layout,
@@ -2981,7 +2991,8 @@ var PlayerUI = ({
2981
2991
  onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined,
2982
2992
  children: [
2983
2993
  /* @__PURE__ */ jsxs9("div", {
2984
- style: containerStyle3,
2994
+ ref: canvasContentRef,
2995
+ style: containerStyle,
2985
2996
  className: playerCssClassname(overrideInternalClassName),
2986
2997
  children: [
2987
2998
  VideoComponent ? /* @__PURE__ */ jsx12(ErrorBoundary, {
@@ -3011,7 +3022,10 @@ var PlayerUI = ({
3011
3022
  ]
3012
3023
  }),
3013
3024
  /* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {}),
3014
- canvasOverlay
3025
+ /* @__PURE__ */ jsx12(CanvasContentContext.Provider, {
3026
+ value: canvasContent,
3027
+ children: canvasOverlay
3028
+ })
3015
3029
  ]
3016
3030
  }),
3017
3031
  shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx12("div", {
@@ -3056,14 +3070,14 @@ var PlayerUI = ({
3056
3070
  return /* @__PURE__ */ jsx12("div", {
3057
3071
  ref: container,
3058
3072
  style: outerStyle,
3059
- className: className2,
3073
+ className,
3060
3074
  children: content
3061
3075
  });
3062
3076
  }
3063
3077
  return /* @__PURE__ */ jsx12("div", {
3064
3078
  ref: container,
3065
3079
  style: outerStyle,
3066
- className: className2,
3080
+ className,
3067
3081
  children: /* @__PURE__ */ jsx12(Suspense, {
3068
3082
  fallback: loadingMarkup,
3069
3083
  children: content
@@ -3220,21 +3234,23 @@ var SharedPlayerContexts = ({
3220
3234
  value: timelineContext,
3221
3235
  children: /* @__PURE__ */ jsx13(Internals13.CompositionManager.Provider, {
3222
3236
  value: compositionManagerContext,
3223
- children: /* @__PURE__ */ jsx13(Internals13.PrefetchProvider, {
3224
- children: /* @__PURE__ */ jsx13(Internals13.DurationsContextProvider, {
3225
- children: /* @__PURE__ */ jsx13(Internals13.MediaVolumeContext.Provider, {
3226
- value: mediaVolumeContextValue,
3227
- children: /* @__PURE__ */ jsx13(Internals13.SetMediaVolumeContext.Provider, {
3228
- value: setMediaVolumeContextValue,
3229
- children: /* @__PURE__ */ jsx13(Internals13.BufferingProvider, {
3230
- children: /* @__PURE__ */ jsx13(Internals13.SharedAudioContextProvider, {
3231
- audioLatencyHint,
3232
- audioEnabled: shouldCreateAudioContext,
3233
- previewSampleRate: sampleRate,
3234
- _experimentalKeepAudioContextAlive,
3235
- children: /* @__PURE__ */ jsx13(Internals13.SharedAudioTagsContextProvider, {
3236
- numberOfAudioTags: numberOfSharedAudioTags,
3237
- children
3237
+ children: /* @__PURE__ */ jsx13(Internals13.VideoProvider, {
3238
+ children: /* @__PURE__ */ jsx13(Internals13.PrefetchProvider, {
3239
+ children: /* @__PURE__ */ jsx13(Internals13.DurationsContextProvider, {
3240
+ children: /* @__PURE__ */ jsx13(Internals13.MediaVolumeContext.Provider, {
3241
+ value: mediaVolumeContextValue,
3242
+ children: /* @__PURE__ */ jsx13(Internals13.SetMediaVolumeContext.Provider, {
3243
+ value: setMediaVolumeContextValue,
3244
+ children: /* @__PURE__ */ jsx13(Internals13.BufferingProvider, {
3245
+ children: /* @__PURE__ */ jsx13(Internals13.SharedAudioContextProvider, {
3246
+ audioLatencyHint,
3247
+ audioEnabled: shouldCreateAudioContext,
3248
+ previewSampleRate: sampleRate,
3249
+ _experimentalKeepAudioContextAlive,
3250
+ children: /* @__PURE__ */ jsx13(Internals13.SharedAudioTagsContextProvider, {
3251
+ numberOfAudioTags: numberOfSharedAudioTags,
3252
+ children
3253
+ })
3238
3254
  })
3239
3255
  })
3240
3256
  })
@@ -3371,10 +3387,16 @@ var componentOrNullIfLazy = (props) => {
3371
3387
  return null;
3372
3388
  };
3373
3389
  var TimelineSequenceObserverComponent = ({ onTimelineSequenceChange }) => {
3374
- const sequences = Internals15.useSequenceManagerSequences();
3375
- useEffect13(() => {
3376
- onTimelineSequenceChange(sequences);
3377
- }, [onTimelineSequenceChange, sequences]);
3390
+ const registry = React13.useContext(Internals15.SequenceRegistryContext);
3391
+ useLayoutEffect3(() => {
3392
+ if (registry === null) {
3393
+ throw new Error("Timeline sequence observer requires a sequence registry");
3394
+ }
3395
+ const publish = () => onTimelineSequenceChange(registry.getSnapshot());
3396
+ const unsubscribe = registry.subscribe(publish);
3397
+ publish();
3398
+ return unsubscribe;
3399
+ }, [onTimelineSequenceChange, registry]);
3378
3400
  return null;
3379
3401
  };
3380
3402
  var PlayerFn = ({
@@ -3383,7 +3405,7 @@ var PlayerFn = ({
3383
3405
  compositionWidth,
3384
3406
  fps,
3385
3407
  inputProps,
3386
- style: style2,
3408
+ style,
3387
3409
  controls = false,
3388
3410
  loop = false,
3389
3411
  autoPlay = false,
@@ -3397,7 +3419,7 @@ var PlayerFn = ({
3397
3419
  errorFallback = () => "⚠️",
3398
3420
  playbackRate = 1,
3399
3421
  renderLoading,
3400
- className: className2,
3422
+ className,
3401
3423
  showPosterWhenUnplayed,
3402
3424
  showPosterWhenEnded,
3403
3425
  showPosterWhenPaused,
@@ -3417,6 +3439,7 @@ var PlayerFn = ({
3417
3439
  showPlaybackRateControl = false,
3418
3440
  posterFillMode = "player-size",
3419
3441
  bufferStateDelayInMilliseconds,
3442
+ defaultPremountInSeconds = NoReactInternals2.DEFAULT_PREMOUNT_IN_SECONDS,
3420
3443
  hideControlsWhenPointerDoesntMove = true,
3421
3444
  overflowVisible = false,
3422
3445
  renderMuteButton,
@@ -3432,6 +3455,7 @@ var PlayerFn = ({
3432
3455
  _experimentalKeepAudioContextAlive = false,
3433
3456
  ...componentProps
3434
3457
  }, ref) => {
3458
+ NoReactInternals2.validateDefaultPremountInSeconds(defaultPremountInSeconds);
3435
3459
  if (typeof window !== "undefined") {
3436
3460
  window.remotion_isPlayer = true;
3437
3461
  }
@@ -3622,7 +3646,7 @@ var PlayerFn = ({
3622
3646
  loop: Boolean(loop),
3623
3647
  controls: Boolean(controls),
3624
3648
  errorFallback,
3625
- style: style2,
3649
+ style,
3626
3650
  inputProps: actualInputProps,
3627
3651
  allowFullscreen: Boolean(allowFullscreen),
3628
3652
  moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded),
@@ -3631,7 +3655,7 @@ var PlayerFn = ({
3631
3655
  doubleClickToFullscreen: Boolean(doubleClickToFullscreen),
3632
3656
  spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause),
3633
3657
  playbackRate: currentPlaybackRate,
3634
- className: className2 ?? undefined,
3658
+ className: className ?? undefined,
3635
3659
  showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed),
3636
3660
  showPosterWhenEnded: Boolean(showPosterWhenEnded),
3637
3661
  showPosterWhenPaused: Boolean(showPosterWhenPaused),
@@ -3659,19 +3683,19 @@ var PlayerFn = ({
3659
3683
  })
3660
3684
  })
3661
3685
  });
3662
- if (!onTimelineSequenceChange) {
3663
- return player;
3664
- }
3665
- return /* @__PURE__ */ jsx14(Internals15.SequenceRegistrationContext.Provider, {
3666
- value: true,
3667
- children: /* @__PURE__ */ jsxs10(Internals15.SequenceManagerProvider, {
3668
- children: [
3669
- /* @__PURE__ */ jsx14(TimelineSequenceObserverComponent, {
3670
- onTimelineSequenceChange
3671
- }),
3672
- player
3673
- ]
3674
- })
3686
+ return /* @__PURE__ */ jsx14(Internals15.DefaultPremountContext.Provider, {
3687
+ value: defaultPremountInSeconds,
3688
+ children: onTimelineSequenceChange ? /* @__PURE__ */ jsx14(Internals15.SequenceRegistrationContext.Provider, {
3689
+ value: true,
3690
+ children: /* @__PURE__ */ jsxs10(Internals15.SequenceManagerProvider, {
3691
+ children: [
3692
+ /* @__PURE__ */ jsx14(TimelineSequenceObserverComponent, {
3693
+ onTimelineSequenceChange
3694
+ }),
3695
+ player
3696
+ ]
3697
+ })
3698
+ }) : player
3675
3699
  });
3676
3700
  };
3677
3701
  var forward = forwardRef2;
@@ -3721,11 +3745,11 @@ if (reactVersion2 === "0") {
3721
3745
  }
3722
3746
  var doesReactVersionSupportSuspense2 = parseInt(reactVersion2, 10) >= 18;
3723
3747
  var ThumbnailUI = ({
3724
- style: style2,
3748
+ style,
3725
3749
  inputProps,
3726
3750
  errorFallback,
3727
3751
  renderLoading,
3728
- className: className2,
3752
+ className,
3729
3753
  overflowVisible,
3730
3754
  noSuspense,
3731
3755
  overrideInternalClassName
@@ -3762,16 +3786,16 @@ var ThumbnailUI = ({
3762
3786
  const outerStyle = useMemo16(() => {
3763
3787
  return calculateOuterStyle({
3764
3788
  config,
3765
- style: style2,
3789
+ style,
3766
3790
  canvasSize,
3767
3791
  overflowVisible,
3768
3792
  layout
3769
3793
  });
3770
- }, [canvasSize, config, layout, overflowVisible, style2]);
3794
+ }, [canvasSize, config, layout, overflowVisible, style]);
3771
3795
  const outer = useMemo16(() => {
3772
3796
  return calculateOuter({ config, layout, scale, overflowVisible });
3773
3797
  }, [config, layout, overflowVisible, scale]);
3774
- const containerStyle3 = useMemo16(() => {
3798
+ const containerStyle = useMemo16(() => {
3775
3799
  return calculateContainerStyle({
3776
3800
  config,
3777
3801
  layout,
@@ -3801,7 +3825,7 @@ var ThumbnailUI = ({
3801
3825
  const content = /* @__PURE__ */ jsx15("div", {
3802
3826
  style: outer,
3803
3827
  children: /* @__PURE__ */ jsx15("div", {
3804
- style: containerStyle3,
3828
+ style: containerStyle,
3805
3829
  className: playerCssClassname(overrideInternalClassName),
3806
3830
  children: VideoComponent ? /* @__PURE__ */ jsx15(ErrorBoundary, {
3807
3831
  onError,
@@ -3820,14 +3844,14 @@ var ThumbnailUI = ({
3820
3844
  return /* @__PURE__ */ jsx15("div", {
3821
3845
  ref: container,
3822
3846
  style: outerStyle,
3823
- className: className2,
3847
+ className,
3824
3848
  children: content
3825
3849
  });
3826
3850
  }
3827
3851
  return /* @__PURE__ */ jsx15("div", {
3828
3852
  ref: container,
3829
3853
  style: outerStyle,
3830
- className: className2,
3854
+ className,
3831
3855
  children: /* @__PURE__ */ jsx15(Suspense2, {
3832
3856
  fallback: loadingMarkup,
3833
3857
  children: content
@@ -3840,13 +3864,13 @@ var ThumbnailUI_default = forwardRef3(ThumbnailUI);
3840
3864
  import { jsx as jsx16 } from "react/jsx-runtime";
3841
3865
  var ThumbnailFn = ({
3842
3866
  frameToDisplay,
3843
- style: style2,
3867
+ style,
3844
3868
  inputProps,
3845
3869
  compositionHeight,
3846
3870
  compositionWidth,
3847
3871
  durationInFrames,
3848
3872
  fps,
3849
- className: className2,
3873
+ className,
3850
3874
  errorFallback = () => "⚠️",
3851
3875
  renderLoading,
3852
3876
  overflowVisible = false,
@@ -3941,11 +3965,11 @@ var ThumbnailFn = ({
3941
3965
  value: emitter,
3942
3966
  children: /* @__PURE__ */ jsx16(ThumbnailUI_default, {
3943
3967
  ref: rootRef,
3944
- className: className2,
3968
+ className,
3945
3969
  errorFallback,
3946
3970
  inputProps: passedInputProps,
3947
3971
  renderLoading,
3948
- style: style2,
3972
+ style,
3949
3973
  overflowVisible,
3950
3974
  overrideInternalClassName,
3951
3975
  noSuspense: Boolean(noSuspense)
@@ -3971,10 +3995,11 @@ var PlayerInternals = {
3971
3995
  PlayerEmitterProvider,
3972
3996
  BufferingIndicator,
3973
3997
  TimelineSequenceObserverContext,
3974
- CanvasOverlayContext
3998
+ CanvasOverlayContext,
3999
+ CanvasContentContext
3975
4000
  };
3976
4001
  export {
3977
- Thumbnail,
4002
+ Player,
3978
4003
  PlayerInternals,
3979
- Player
4004
+ Thumbnail
3980
4005
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/player"
4
4
  },
5
5
  "name": "@remotion/player",
6
- "version": "4.0.534",
6
+ "version": "4.0.536",
7
7
  "description": "React component for embedding a Remotion preview into your app",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "license": "SEE LICENSE IN LICENSE.md",
37
37
  "dependencies": {
38
- "remotion": "4.0.534"
38
+ "remotion": "4.0.536"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=16.8.0",
@@ -49,7 +49,7 @@
49
49
  "react-dom": "19.2.3",
50
50
  "webpack": "5.105.0",
51
51
  "zod": "4.5.4",
52
- "@remotion/eslint-config-internal": "4.0.534",
52
+ "@remotion/eslint-config-internal": "4.0.536",
53
53
  "eslint": "9.19.0",
54
54
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
55
55
  },
@@ -1,11 +0,0 @@
1
- import type { Context } from 'react';
2
- import React from 'react';
3
- import type { TimelineImperativeContextValue } from 'remotion';
4
- export declare const getTimelineImperativeContext: () => Context<TimelineImperativeContextValue | null>;
5
- export declare const CoreTimelineImperativeContextProvider: React.FC<{
6
- readonly children: React.ReactNode;
7
- readonly value: TimelineImperativeContextValue;
8
- }>;
9
- export declare const TimelineImperativeCompatibilityProvider: React.FC<{
10
- readonly children: React.ReactNode;
11
- }>;
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.TimelineImperativeCompatibilityProvider = exports.CoreTimelineImperativeContextProvider = exports.getTimelineImperativeContext = void 0;
37
- const jsx_runtime_1 = require("react/jsx-runtime");
38
- const react_1 = __importStar(require("react"));
39
- const remotion_1 = require("remotion");
40
- const PlayerTimelineImperativeContext = react_1.default.createContext(null);
41
- const getCoreTimelineImperativeContext = () => {
42
- return remotion_1.Internals.TimelineImperativeContext;
43
- };
44
- const getTimelineImperativeContext = () => {
45
- var _a;
46
- return (_a = getCoreTimelineImperativeContext()) !== null && _a !== void 0 ? _a : PlayerTimelineImperativeContext;
47
- };
48
- exports.getTimelineImperativeContext = getTimelineImperativeContext;
49
- const CoreTimelineImperativeContextProvider = ({ children, value }) => {
50
- const TimelineImperativeContext = getCoreTimelineImperativeContext();
51
- if (!TimelineImperativeContext) {
52
- return children;
53
- }
54
- return (jsx_runtime_1.jsx(TimelineImperativeContext.Provider, { value: value, children: children }));
55
- };
56
- exports.CoreTimelineImperativeContextProvider = CoreTimelineImperativeContextProvider;
57
- const LegacyTimelineImperativeContextProvider = ({ children }) => {
58
- const timelineContext = remotion_1.Internals.Timeline.useTimelineContext();
59
- const frameRef = (0, react_1.useRef)(timelineContext.frame);
60
- frameRef.current = timelineContext.frame;
61
- const value = (0, react_1.useMemo)(() => {
62
- return {
63
- frameRef,
64
- imperativePlaying: timelineContext.imperativePlaying,
65
- audioAndVideoTags: timelineContext.audioAndVideoTags,
66
- };
67
- }, [timelineContext.audioAndVideoTags, timelineContext.imperativePlaying]);
68
- return (jsx_runtime_1.jsx(PlayerTimelineImperativeContext.Provider, { value: value, children: children }));
69
- };
70
- const TimelineImperativeCompatibilityProvider = ({ children }) => {
71
- if (getCoreTimelineImperativeContext()) {
72
- return children;
73
- }
74
- return (jsx_runtime_1.jsx(LegacyTimelineImperativeContextProvider, { children: children }));
75
- };
76
- exports.TimelineImperativeCompatibilityProvider = TimelineImperativeCompatibilityProvider;
@@ -1,21 +0,0 @@
1
- import type { SyntheticEvent } from 'react';
2
- import type { PlayerEmitter } from './event-emitter.js';
3
- type UsePlayerMethods = {
4
- frameBack: (frames: number) => void;
5
- frameForward: (frames: number) => void;
6
- isLastFrame: boolean;
7
- isFirstFrame: boolean;
8
- emitter: PlayerEmitter;
9
- playing: boolean;
10
- play: (e?: SyntheticEvent | PointerEvent) => void;
11
- pause: () => void;
12
- pauseAndReturnToPlayStart: () => void;
13
- seek: (newFrame: number) => void;
14
- getCurrentFrame: () => number;
15
- isPlaying: () => boolean;
16
- hasPlayed: boolean;
17
- isBuffering: () => boolean;
18
- toggle: (e?: SyntheticEvent | PointerEvent) => void;
19
- };
20
- export declare const usePlayer: () => UsePlayerMethods;
21
- export {};
@@ -1,195 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usePlayer = void 0;
4
- const react_1 = require("react");
5
- const remotion_1 = require("remotion");
6
- const emitter_context_js_1 = require("./emitter-context.js");
7
- const usePlayer = () => {
8
- var _a;
9
- const [playing, setPlaying, imperativePlaying] = remotion_1.Internals.Timeline.usePlayingState();
10
- const [hasPlayed, setHasPlayed] = (0, react_1.useState)(false);
11
- const frame = remotion_1.Internals.Timeline.useTimelinePosition();
12
- const playStart = (0, react_1.useRef)(frame);
13
- const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
14
- const setTimelinePosition = remotion_1.Internals.Timeline.useTimelineSetFrame();
15
- const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
16
- const audioTagsContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioTagsContext);
17
- const { audioAndVideoTags } = remotion_1.Internals.useTimelineContext();
18
- const frameRef = (0, react_1.useRef)(frame);
19
- frameRef.current = frame;
20
- const video = remotion_1.Internals.useVideo();
21
- const config = remotion_1.Internals.useUnsafeVideoConfig();
22
- const emitter = (0, react_1.useContext)(emitter_context_js_1.PlayerEventEmitterContext);
23
- const lastFrame = ((_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
24
- const isLastFrame = frame === lastFrame;
25
- const isFirstFrame = frame === 0;
26
- if (!emitter) {
27
- throw new TypeError('Expected Player event emitter context');
28
- }
29
- const bufferingContext = (0, react_1.useContext)(remotion_1.Internals.BufferingContextReact);
30
- if (!bufferingContext) {
31
- throw new Error('Missing the buffering context. Most likely you have a Remotion version mismatch.');
32
- }
33
- const { buffering } = bufferingContext;
34
- const seek = (0, react_1.useCallback)((newFrame) => {
35
- const frameToSeekTo = config
36
- ? remotion_1.Internals.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames)
37
- : Math.max(0, newFrame);
38
- if (video === null || video === void 0 ? void 0 : video.id) {
39
- setTimelinePosition((c) => c[video.id] === frameToSeekTo ? c : { ...c, [video.id]: frameToSeekTo });
40
- }
41
- frameRef.current = frameToSeekTo;
42
- emitter.dispatchSeek(frameToSeekTo);
43
- }, [config, emitter, setTimelinePosition, video === null || video === void 0 ? void 0 : video.id]);
44
- const play = (0, react_1.useCallback)((e) => {
45
- if (imperativePlaying.current) {
46
- return;
47
- }
48
- setHasPlayed(true);
49
- if (isLastFrame) {
50
- seek(0);
51
- }
52
- audioContext === null || audioContext === void 0 ? void 0 : audioContext.resume();
53
- /**
54
- * Play silent audio tags to warm them up for autoplay
55
- */
56
- if (audioTagsContext && audioTagsContext.numberOfAudioTags > 0 && e) {
57
- audioTagsContext.playAllAudios();
58
- }
59
- /**
60
- * Play audios and videos directly here so they can benefit from
61
- * being triggered by a click
62
- */
63
- audioAndVideoTags.current.forEach((a) => a.play('player play() was called and playing audio from a click'));
64
- imperativePlaying.current = true;
65
- setPlaying(true);
66
- playStart.current = frameRef.current;
67
- emitter.dispatchPlay();
68
- }, [
69
- imperativePlaying,
70
- isLastFrame,
71
- audioContext,
72
- audioTagsContext,
73
- setPlaying,
74
- emitter,
75
- seek,
76
- audioAndVideoTags,
77
- ]);
78
- const pause = (0, react_1.useCallback)(() => {
79
- if (imperativePlaying.current) {
80
- imperativePlaying.current = false;
81
- setPlaying(false);
82
- emitter.dispatchPause();
83
- audioContext === null || audioContext === void 0 ? void 0 : audioContext.suspend();
84
- }
85
- }, [emitter, imperativePlaying, setPlaying, audioContext]);
86
- const pauseAndReturnToPlayStart = (0, react_1.useCallback)(() => {
87
- if (imperativePlaying.current) {
88
- imperativePlaying.current = false;
89
- frameRef.current = playStart.current;
90
- if (config) {
91
- setTimelinePosition((c) => ({
92
- ...c,
93
- [config.id]: playStart.current,
94
- }));
95
- setPlaying(false);
96
- emitter.dispatchPause();
97
- }
98
- }
99
- }, [config, emitter, imperativePlaying, setPlaying, setTimelinePosition]);
100
- const videoId = video === null || video === void 0 ? void 0 : video.id;
101
- const frameBack = (0, react_1.useCallback)((frames) => {
102
- if (!videoId) {
103
- return null;
104
- }
105
- if (imperativePlaying.current) {
106
- return;
107
- }
108
- setFrame((c) => {
109
- var _a, _b;
110
- const prevFrame = (_b = (_a = c[videoId]) !== null && _a !== void 0 ? _a : window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0;
111
- const newFrame = Math.max(0, prevFrame - frames);
112
- if (prevFrame === newFrame) {
113
- return c;
114
- }
115
- return {
116
- ...c,
117
- [videoId]: newFrame,
118
- };
119
- });
120
- }, [imperativePlaying, setFrame, videoId]);
121
- const frameForward = (0, react_1.useCallback)((frames) => {
122
- if (!videoId) {
123
- return null;
124
- }
125
- if (imperativePlaying.current) {
126
- return;
127
- }
128
- setFrame((c) => {
129
- var _a, _b;
130
- const prevFrame = (_b = (_a = c[videoId]) !== null && _a !== void 0 ? _a : window.remotion_initialFrame) !== null && _b !== void 0 ? _b : 0;
131
- const newFrame = Math.min(lastFrame, prevFrame + frames);
132
- if (prevFrame === newFrame) {
133
- return c;
134
- }
135
- return {
136
- ...c,
137
- [videoId]: newFrame,
138
- };
139
- });
140
- }, [videoId, imperativePlaying, lastFrame, setFrame]);
141
- const toggle = (0, react_1.useCallback)((e) => {
142
- if (imperativePlaying.current) {
143
- pause();
144
- }
145
- else {
146
- play(e);
147
- }
148
- }, [imperativePlaying, pause, play]);
149
- const isPlaying = (0, react_1.useCallback)(() => {
150
- return imperativePlaying.current;
151
- }, [imperativePlaying]);
152
- const getCurrentFrame = (0, react_1.useCallback)(() => {
153
- return frameRef.current;
154
- }, [frameRef]);
155
- const isBuffering = (0, react_1.useCallback)(() => {
156
- return buffering.current;
157
- }, [buffering]);
158
- const returnValue = (0, react_1.useMemo)(() => {
159
- return {
160
- frameBack,
161
- frameForward,
162
- isLastFrame,
163
- emitter,
164
- playing,
165
- play,
166
- pause,
167
- seek,
168
- isFirstFrame,
169
- getCurrentFrame,
170
- isPlaying,
171
- isBuffering,
172
- pauseAndReturnToPlayStart,
173
- hasPlayed,
174
- toggle,
175
- };
176
- }, [
177
- emitter,
178
- frameBack,
179
- frameForward,
180
- hasPlayed,
181
- isFirstFrame,
182
- isLastFrame,
183
- getCurrentFrame,
184
- pause,
185
- pauseAndReturnToPlayStart,
186
- play,
187
- playing,
188
- seek,
189
- toggle,
190
- isPlaying,
191
- isBuffering,
192
- ]);
193
- return returnValue;
194
- };
195
- exports.usePlayer = usePlayer;