@remotion/player 4.0.526 → 4.0.528

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.
@@ -40,6 +40,7 @@ exports.Player = exports.componentOrNullIfLazy = void 0;
40
40
  const jsx_runtime_1 = require("react/jsx-runtime");
41
41
  const react_1 = __importStar(require("react"));
42
42
  const remotion_1 = require("remotion");
43
+ const no_react_1 = require("remotion/no-react");
43
44
  const EmitterProvider_js_1 = require("./EmitterProvider.js");
44
45
  const player_css_classname_js_1 = require("./player-css-classname.js");
45
46
  const PlayerUI_js_1 = __importDefault(require("./PlayerUI.js"));
@@ -64,7 +65,9 @@ const TimelineSequenceObserverComponent = ({ onTimelineSequenceChange }) => {
64
65
  }, [onTimelineSequenceChange, sequences]);
65
66
  return null;
66
67
  };
67
- 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 = 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) => {
68
+ 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
+ ? 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) => {
68
71
  if (typeof window !== 'undefined') {
69
72
  window.remotion_isPlayer = true;
70
73
  }
@@ -91,6 +94,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
91
94
  const [frame, setFrame] = (0, react_1.useState)(() => ({
92
95
  [SharedPlayerContext_js_1.PLAYER_COMP_ID]: initialFrame !== null && initialFrame !== void 0 ? initialFrame : 0,
93
96
  }));
97
+ const seek = remotion_1.Internals.useTimelineSeek(setFrame);
94
98
  const frameRef = (0, react_1.useRef)(frame);
95
99
  frameRef.current = frame;
96
100
  const rootRef = (0, react_1.useRef)(null);
@@ -202,6 +206,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
202
206
  const setTimelineContextValue = (0, react_1.useMemo)(() => {
203
207
  return {
204
208
  setFrame,
209
+ seek,
205
210
  setPlaying: (updater) => {
206
211
  const current = playingStore.store.getSnapshot().playing;
207
212
  const next = typeof updater === 'function' ? updater(current) : updater;
@@ -223,6 +228,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
223
228
  };
224
229
  }, [
225
230
  bufferingStore,
231
+ seek,
226
232
  setFrame,
227
233
  frameRef,
228
234
  playingStore,
@@ -37,6 +37,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
37
37
  const react_1 = __importStar(require("react"));
38
38
  const remotion_1 = require("remotion");
39
39
  const calculate_scale_js_1 = require("./calculate-scale.js");
40
+ const canvas_overlay_context_js_1 = require("./canvas-overlay-context.js");
40
41
  const error_boundary_js_1 = require("./error-boundary.js");
41
42
  const license_blacklist_js_1 = require("./license-blacklist.js");
42
43
  const player_css_classname_js_1 = require("./player-css-classname.js");
@@ -84,6 +85,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
84
85
  player.play(e);
85
86
  }, [player]);
86
87
  const { playerMuted, mediaVolume } = (0, react_1.useContext)(remotion_1.Internals.MediaVolumeContext);
88
+ const canvasOverlay = (0, react_1.useContext)(canvas_overlay_context_js_1.CanvasOverlayContext);
87
89
  (0, react_1.useEffect)(() => {
88
90
  player.emitter.dispatchVolumeChange(mediaVolume);
89
91
  }, [player.emitter, mediaVolume]);
@@ -447,12 +449,11 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
447
449
  const { left, top, width, height, ...outerWithoutScale } = outer;
448
450
  const content = (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
449
451
  jsx_runtime_1.jsxs("div", { style: outer, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: [
450
- 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(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: {
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: {
451
453
  ...outerWithoutScale,
452
454
  width: config.width,
453
455
  height: config.height,
454
- }, onPointerDown: clickToPlay ? handlePointerDown : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null] }), jsx_runtime_1.jsx(license_blacklist_js_1.RenderWarningIfBlacklist, {})
455
- ] }), 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
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
456
457
  ? handlePointerDown
457
458
  : undefined, renderMuteButton: renderMuteButton, renderVolumeSlider: renderVolumeSlider, renderCustomControls: renderCustomControls })) : null] }));
458
459
  if (noSuspense || (is_node_js_1.IS_NODE && !doesReactVersionSupportSuspense)) {
@@ -45,6 +45,7 @@ const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, com
45
45
  const setTimelineContext = (0, react_1.useMemo)(() => {
46
46
  return {
47
47
  setFrame: () => undefined,
48
+ seek: null,
48
49
  setPlaying: () => undefined,
49
50
  setBuffering: (buffering) => {
50
51
  if (bufferingStore.store.getSnapshot().buffering !== buffering) {
@@ -0,0 +1,2 @@
1
+ import type { ReactNode } from 'react';
2
+ export declare const CanvasOverlayContext: import("react").Context<ReactNode>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CanvasOverlayContext = void 0;
4
+ const react_1 = require("react");
5
+ // Canvas supplies its authoring UI here so it shares the Player's timeline,
6
+ // clipping and fullscreen container without wrapping the user's composition.
7
+ exports.CanvasOverlayContext = (0, react_1.createContext)(null);
@@ -53,4 +53,5 @@ export declare const PlayerInternals: {
53
53
  readonly color?: string | undefined;
54
54
  }>;
55
55
  TimelineSequenceObserverContext: import("react").Context<import("./timeline-sequence-observer-context.js").TimelineSequenceObserver | null>;
56
+ CanvasOverlayContext: import("react").Context<import("react").ReactNode>;
56
57
  };
package/dist/cjs/index.js CHANGED
@@ -4,6 +4,7 @@ exports.PlayerInternals = exports.Thumbnail = exports.Player = void 0;
4
4
  require("./_check-rsc.js");
5
5
  const BufferingIndicator_js_1 = require("./BufferingIndicator.js");
6
6
  const calculate_scale_js_1 = require("./calculate-scale.js");
7
+ const canvas_overlay_context_js_1 = require("./canvas-overlay-context.js");
7
8
  const emitter_context_js_1 = require("./emitter-context.js");
8
9
  const EmitterProvider_js_1 = require("./EmitterProvider.js");
9
10
  const event_emitter_js_1 = require("./event-emitter.js");
@@ -28,4 +29,5 @@ exports.PlayerInternals = {
28
29
  PlayerEmitterProvider: EmitterProvider_js_1.PlayerEmitterProvider,
29
30
  BufferingIndicator: BufferingIndicator_js_1.BufferingIndicator,
30
31
  TimelineSequenceObserverContext: timeline_sequence_observer_context_js_1.TimelineSequenceObserverContext,
32
+ CanvasOverlayContext: canvas_overlay_context_js_1.CanvasOverlayContext,
31
33
  };
@@ -6,8 +6,8 @@ const remotion_1 = require("remotion");
6
6
  const emitter_context_js_1 = require("./emitter-context.js");
7
7
  const usePlayerMethods = () => {
8
8
  var _a;
9
- const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
10
- const setTimelinePosition = remotion_1.Internals.Timeline.useTimelineSetFrame();
9
+ const setFrame = remotion_1.Internals.Timeline.useTimelineSeekFrame();
10
+ const setTimelinePosition = setFrame;
11
11
  const { setPlaying, frameRef, audioAndVideoTags, isPlaying: readIsPlaying, isBuffering, } = (0, react_1.useContext)(remotion_1.Internals.SetTimelineContext);
12
12
  const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
13
13
  const audioTagsContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioTagsContext);
@@ -39,15 +39,15 @@ const usePlayerMethods = () => {
39
39
  : Math.max(0, newFrame);
40
40
  fallbackFrame.current = frameToSeekTo;
41
41
  if (video === null || video === void 0 ? void 0 : video.id) {
42
+ setTimelinePosition((currentFrames) => currentFrames[video.id] === frameToSeekTo
43
+ ? currentFrames
44
+ : { ...currentFrames, [video.id]: frameToSeekTo });
42
45
  if (frameRef.current[video.id] !== frameToSeekTo) {
43
46
  frameRef.current = {
44
47
  ...frameRef.current,
45
48
  [video.id]: frameToSeekTo,
46
49
  };
47
50
  }
48
- setTimelinePosition((currentFrames) => currentFrames[video.id] === frameToSeekTo
49
- ? currentFrames
50
- : { ...currentFrames, [video.id]: frameToSeekTo });
51
51
  }
52
52
  emitter.dispatchSeek(frameToSeekTo);
53
53
  }, [config, emitter, frameRef, setTimelinePosition, video === null || video === void 0 ? void 0 : video.id]);
@@ -109,14 +109,14 @@ const usePlayerMethods = () => {
109
109
  setPlaying(false);
110
110
  fallbackFrame.current = playStart.current;
111
111
  if (config) {
112
- frameRef.current = {
113
- ...frameRef.current,
114
- [config.id]: playStart.current,
115
- };
116
112
  setTimelinePosition((currentFrames) => ({
117
113
  ...currentFrames,
118
114
  [config.id]: playStart.current,
119
115
  }));
116
+ frameRef.current = {
117
+ ...frameRef.current,
118
+ [config.id]: playStart.current,
119
+ };
120
120
  emitter.dispatchPause();
121
121
  }
122
122
  }
@@ -143,13 +143,13 @@ const usePlayerMethods = () => {
143
143
  if (previousFrame === newFrame) {
144
144
  return;
145
145
  }
146
+ setFrame((currentFrames) => currentFrames[videoId] === newFrame
147
+ ? currentFrames
148
+ : { ...currentFrames, [videoId]: newFrame });
146
149
  frameRef.current = {
147
150
  ...frameRef.current,
148
151
  [videoId]: newFrame,
149
152
  };
150
- setFrame((currentFrames) => currentFrames[videoId] === newFrame
151
- ? currentFrames
152
- : { ...currentFrames, [videoId]: newFrame });
153
153
  }, [frameRef, readIsPlaying, setFrame, videoId]);
154
154
  const frameForward = (0, react_1.useCallback)((frames) => {
155
155
  var _a, _b;
@@ -164,13 +164,13 @@ const usePlayerMethods = () => {
164
164
  if (previousFrame === newFrame) {
165
165
  return;
166
166
  }
167
+ setFrame((currentFrames) => currentFrames[videoId] === newFrame
168
+ ? currentFrames
169
+ : { ...currentFrames, [videoId]: newFrame });
167
170
  frameRef.current = {
168
171
  ...frameRef.current,
169
172
  [videoId]: newFrame,
170
173
  };
171
- setFrame((currentFrames) => currentFrames[videoId] === newFrame
172
- ? currentFrames
173
- : { ...currentFrames, [videoId]: newFrame });
174
174
  }, [frameRef, lastFrame, readIsPlaying, setFrame, videoId]);
175
175
  const toggle = (0, react_1.useCallback)((e) => {
176
176
  if (readIsPlaying()) {
@@ -347,6 +347,10 @@ var calculateOuter = ({
347
347
  };
348
348
  };
349
349
 
350
+ // src/canvas-overlay-context.ts
351
+ import { createContext as createContext2 } from "react";
352
+ var CanvasOverlayContext = createContext2(null);
353
+
350
354
  // src/emitter-context.ts
351
355
  import React from "react";
352
356
  var PlayerEventEmitterContext = React.createContext(undefined);
@@ -560,8 +564,8 @@ import { Internals as Internals4 } from "remotion";
560
564
  import { useCallback, useContext as useContext2, useMemo, useRef } from "react";
561
565
  import { Internals as Internals3, useRemotionEnvironment } from "remotion";
562
566
  var usePlayerMethods = () => {
563
- const setFrame = Internals3.Timeline.useTimelineSetFrame();
564
- const setTimelinePosition = Internals3.Timeline.useTimelineSetFrame();
567
+ const setFrame = Internals3.Timeline.useTimelineSeekFrame();
568
+ const setTimelinePosition = setFrame;
565
569
  const {
566
570
  setPlaying,
567
571
  frameRef,
@@ -592,13 +596,13 @@ var usePlayerMethods = () => {
592
596
  const frameToSeekTo = config ? Internals3.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames) : Math.max(0, newFrame);
593
597
  fallbackFrame.current = frameToSeekTo;
594
598
  if (video?.id) {
599
+ setTimelinePosition((currentFrames) => currentFrames[video.id] === frameToSeekTo ? currentFrames : { ...currentFrames, [video.id]: frameToSeekTo });
595
600
  if (frameRef.current[video.id] !== frameToSeekTo) {
596
601
  frameRef.current = {
597
602
  ...frameRef.current,
598
603
  [video.id]: frameToSeekTo
599
604
  };
600
605
  }
601
- setTimelinePosition((currentFrames) => currentFrames[video.id] === frameToSeekTo ? currentFrames : { ...currentFrames, [video.id]: frameToSeekTo });
602
606
  }
603
607
  emitter.dispatchSeek(frameToSeekTo);
604
608
  }, [config, emitter, frameRef, setTimelinePosition, video?.id]);
@@ -651,14 +655,14 @@ var usePlayerMethods = () => {
651
655
  setPlaying(false);
652
656
  fallbackFrame.current = playStart.current;
653
657
  if (config) {
654
- frameRef.current = {
655
- ...frameRef.current,
656
- [config.id]: playStart.current
657
- };
658
658
  setTimelinePosition((currentFrames) => ({
659
659
  ...currentFrames,
660
660
  [config.id]: playStart.current
661
661
  }));
662
+ frameRef.current = {
663
+ ...frameRef.current,
664
+ [config.id]: playStart.current
665
+ };
662
666
  emitter.dispatchPause();
663
667
  }
664
668
  }
@@ -684,11 +688,11 @@ var usePlayerMethods = () => {
684
688
  if (previousFrame === newFrame) {
685
689
  return;
686
690
  }
691
+ setFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
687
692
  frameRef.current = {
688
693
  ...frameRef.current,
689
694
  [videoId]: newFrame
690
695
  };
691
- setFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
692
696
  }, [frameRef, readIsPlaying, setFrame, videoId]);
693
697
  const frameForward = useCallback((frames) => {
694
698
  if (!videoId) {
@@ -702,11 +706,11 @@ var usePlayerMethods = () => {
702
706
  if (previousFrame === newFrame) {
703
707
  return;
704
708
  }
709
+ setFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
705
710
  frameRef.current = {
706
711
  ...frameRef.current,
707
712
  [videoId]: newFrame
708
713
  };
709
- setFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
710
714
  }, [frameRef, lastFrame, readIsPlaying, setFrame, videoId]);
711
715
  const toggle = useCallback((e) => {
712
716
  if (readIsPlaying()) {
@@ -1366,6 +1370,7 @@ import React13, {
1366
1370
  useState as useState12
1367
1371
  } from "react";
1368
1372
  import { Composition, Internals as Internals15 } from "remotion";
1373
+ import { NoReactInternals as NoReactInternals2 } from "remotion/no-react";
1369
1374
 
1370
1375
  // src/player-css-classname.ts
1371
1376
  var playerCssClassname = (override) => {
@@ -2645,6 +2650,7 @@ var PlayerUI = ({
2645
2650
  player.play(e);
2646
2651
  }, [player]);
2647
2652
  const { playerMuted, mediaVolume } = useContext4(Internals11.MediaVolumeContext);
2653
+ const canvasOverlay = useContext4(CanvasOverlayContext);
2648
2654
  useEffect12(() => {
2649
2655
  player.emitter.dispatchVolumeChange(mediaVolume);
2650
2656
  }, [player.emitter, mediaVolume]);
@@ -2991,9 +2997,12 @@ var PlayerUI = ({
2991
2997
  errorFallback,
2992
2998
  children: /* @__PURE__ */ jsx12(Internals11.CurrentScaleContext.Provider, {
2993
2999
  value: currentScale,
2994
- children: /* @__PURE__ */ jsx12(VideoComponent, {
2995
- ...video?.props ?? {},
2996
- ...inputProps ?? {}
3000
+ children: /* @__PURE__ */ jsx12(CanvasOverlayContext.Provider, {
3001
+ value: null,
3002
+ children: /* @__PURE__ */ jsx12(VideoComponent, {
3003
+ ...video?.props ?? {},
3004
+ ...inputProps ?? {}
3005
+ })
2997
3006
  })
2998
3007
  })
2999
3008
  }) : null,
@@ -3009,7 +3018,8 @@ var PlayerUI = ({
3009
3018
  }) : null
3010
3019
  ]
3011
3020
  }),
3012
- /* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {})
3021
+ /* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {}),
3022
+ canvasOverlay
3013
3023
  ]
3014
3024
  }),
3015
3025
  shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx12("div", {
@@ -3391,7 +3401,7 @@ var PlayerFn = ({
3391
3401
  doubleClickToFullscreen = false,
3392
3402
  spaceKeyToPlayOrPause = true,
3393
3403
  moveToBeginningWhenEnded = true,
3394
- numberOfSharedAudioTags = 5,
3404
+ numberOfSharedAudioTags = NoReactInternals2.ENABLE_V5_BREAKING_CHANGES ? 0 : 5,
3395
3405
  errorFallback = () => "⚠️",
3396
3406
  playbackRate = 1,
3397
3407
  renderLoading,
@@ -3454,6 +3464,7 @@ var PlayerFn = ({
3454
3464
  const [frame, setFrame] = useState12(() => ({
3455
3465
  [PLAYER_COMP_ID]: initialFrame ?? 0
3456
3466
  }));
3467
+ const seek = Internals15.useTimelineSeek(setFrame);
3457
3468
  const frameRef = useRef12(frame);
3458
3469
  frameRef.current = frame;
3459
3470
  const rootRef = useRef12(null);
@@ -3548,6 +3559,7 @@ var PlayerFn = ({
3548
3559
  const setTimelineContextValue = useMemo14(() => {
3549
3560
  return {
3550
3561
  setFrame,
3562
+ seek,
3551
3563
  setPlaying: (updater) => {
3552
3564
  const current = playingStore.store.getSnapshot().playing;
3553
3565
  const next = typeof updater === "function" ? updater(current) : updater;
@@ -3569,6 +3581,7 @@ var PlayerFn = ({
3569
3581
  };
3570
3582
  }, [
3571
3583
  bufferingStore,
3584
+ seek,
3572
3585
  setFrame,
3573
3586
  frameRef,
3574
3587
  playingStore,
@@ -3884,6 +3897,7 @@ var ThumbnailFn = ({
3884
3897
  setFrame: () => {
3885
3898
  return;
3886
3899
  },
3900
+ seek: null,
3887
3901
  setPlaying: () => {
3888
3902
  return;
3889
3903
  },
@@ -3964,7 +3978,8 @@ var PlayerInternals = {
3964
3978
  updateAllElementsSizes,
3965
3979
  PlayerEmitterProvider,
3966
3980
  BufferingIndicator,
3967
- TimelineSequenceObserverContext
3981
+ TimelineSequenceObserverContext,
3982
+ CanvasOverlayContext
3968
3983
  };
3969
3984
  export {
3970
3985
  Thumbnail,
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.526",
6
+ "version": "4.0.528",
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.526"
38
+ "remotion": "4.0.528"
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.526",
52
+ "@remotion/eslint-config-internal": "4.0.528",
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;