@remotion/player 4.0.526 → 4.0.527

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
  }
@@ -1366,6 +1366,7 @@ import React13, {
1366
1366
  useState as useState12
1367
1367
  } from "react";
1368
1368
  import { Composition, Internals as Internals15 } from "remotion";
1369
+ import { NoReactInternals as NoReactInternals2 } from "remotion/no-react";
1369
1370
 
1370
1371
  // src/player-css-classname.ts
1371
1372
  var playerCssClassname = (override) => {
@@ -3391,7 +3392,7 @@ var PlayerFn = ({
3391
3392
  doubleClickToFullscreen = false,
3392
3393
  spaceKeyToPlayOrPause = true,
3393
3394
  moveToBeginningWhenEnded = true,
3394
- numberOfSharedAudioTags = 5,
3395
+ numberOfSharedAudioTags = NoReactInternals2.ENABLE_V5_BREAKING_CHANGES ? 0 : 5,
3395
3396
  errorFallback = () => "⚠️",
3396
3397
  playbackRate = 1,
3397
3398
  renderLoading,
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.527",
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.527"
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.527",
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;