@remotion/player 4.0.0-alpha.217 → 4.0.0-alpha10
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.
- package/dist/cjs/Player.d.ts +3 -3
- package/dist/cjs/Player.js +4 -2
- package/dist/cjs/PlayerUI.d.ts +1 -1
- package/dist/cjs/PlayerUI.js +23 -5
- package/dist/cjs/SharedPlayerContext.d.ts +1 -1
- package/dist/cjs/SharedPlayerContext.js +3 -1
- package/dist/cjs/Thumbnail.d.ts +4 -4
- package/dist/cjs/Thumbnail.js +1 -1
- package/dist/cjs/ThumbnailUI.d.ts +1 -1
- package/dist/cjs/ThumbnailUI.js +2 -2
- package/dist/cjs/event-emitter.d.ts +17 -2
- package/dist/cjs/event-emitter.js +18 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/is-backgrounded.d.ts +2 -0
- package/dist/cjs/is-backgrounded.js +24 -0
- package/dist/cjs/player-methods.d.ts +1 -1
- package/dist/cjs/use-playback.js +42 -5
- package/dist/cjs/utils/props-if-has-props.d.ts +2 -2
- package/dist/esm/Player.d.ts +3 -3
- package/dist/esm/PlayerUI.d.ts +1 -1
- package/dist/esm/SharedPlayerContext.d.ts +1 -1
- package/dist/esm/Thumbnail.d.ts +4 -4
- package/dist/esm/ThumbnailUI.d.ts +1 -1
- package/dist/esm/error-boundary.d.ts +1 -1
- package/dist/esm/event-emitter.d.ts +17 -2
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.mjs +113 -18
- package/dist/esm/is-backgrounded.d.ts +2 -0
- package/dist/esm/player-methods.d.ts +1 -1
- package/dist/esm/utils/props-if-has-props.d.ts +2 -2
- package/dist/tsconfig-esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +80 -79
|
@@ -13,19 +13,31 @@ declare type FrameUpdateEventPayload = {
|
|
|
13
13
|
declare type RateChangeEventPayload = {
|
|
14
14
|
playbackRate: number;
|
|
15
15
|
};
|
|
16
|
+
declare type ScaleChangeEventPayload = {
|
|
17
|
+
scale: number;
|
|
18
|
+
};
|
|
19
|
+
declare type VolumeChangeEventPayload = {
|
|
20
|
+
volume: number;
|
|
21
|
+
};
|
|
16
22
|
declare type FullscreenChangeEventPayload = {
|
|
17
23
|
isFullscreen: boolean;
|
|
18
24
|
};
|
|
25
|
+
declare type MuteChangeEventPayload = {
|
|
26
|
+
isMuted: boolean;
|
|
27
|
+
};
|
|
19
28
|
declare type PlayerStateEventMap = {
|
|
20
29
|
seeked: SeekPayload;
|
|
21
30
|
pause: undefined;
|
|
22
31
|
play: undefined;
|
|
23
32
|
ratechange: RateChangeEventPayload;
|
|
33
|
+
scalechange: ScaleChangeEventPayload;
|
|
34
|
+
volumechange: VolumeChangeEventPayload;
|
|
24
35
|
ended: undefined;
|
|
25
36
|
error: ErrorPayload;
|
|
26
37
|
timeupdate: TimeUpdateEventPayload;
|
|
27
38
|
frameupdate: FrameUpdateEventPayload;
|
|
28
39
|
fullscreenchange: FullscreenChangeEventPayload;
|
|
40
|
+
mutechange: MuteChangeEventPayload;
|
|
29
41
|
};
|
|
30
42
|
declare type ThumbnailStateEventMap = {
|
|
31
43
|
error: ErrorPayload;
|
|
@@ -47,14 +59,17 @@ export declare class PlayerEmitter {
|
|
|
47
59
|
removeEventListener<Q extends PlayerEventTypes>(name: Q, callback: CallbackListener<Q>): void;
|
|
48
60
|
private dispatchEvent;
|
|
49
61
|
dispatchSeek(frame: number): void;
|
|
62
|
+
dispatchVolumeChange(volume: number): void;
|
|
50
63
|
dispatchPause(): void;
|
|
51
64
|
dispatchPlay(): void;
|
|
52
65
|
dispatchEnded(): void;
|
|
53
|
-
|
|
66
|
+
dispatchRateChange(playbackRate: number): void;
|
|
67
|
+
dispatchScaleChange(scale: number): void;
|
|
54
68
|
dispatchError(error: Error): void;
|
|
55
69
|
dispatchTimeUpdate(event: TimeUpdateEventPayload): void;
|
|
56
70
|
dispatchFrameUpdate(event: FrameUpdateEventPayload): void;
|
|
57
|
-
|
|
71
|
+
dispatchFullscreenChange(event: FullscreenChangeEventPayload): void;
|
|
72
|
+
dispatchMuteChange(event: MuteChangeEventPayload): void;
|
|
58
73
|
}
|
|
59
74
|
export declare class ThumbnailEmitter {
|
|
60
75
|
listeners: ThumbnailListeners;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { CallbackListener, PlayerEventTypes } from './event-emitter.js';
|
|
2
3
|
import { PlayerEmitter } from './event-emitter.js';
|
|
3
|
-
export { Player, PlayerProps } from './Player.js';
|
|
4
4
|
export { PlayerMethods, PlayerRef, ThumbnailMethods, ThumbnailRef, } from './player-methods.js';
|
|
5
|
+
export { Player, PlayerProps } from './Player.js';
|
|
5
6
|
export type { RenderFullscreenButton, RenderPlayPauseButton, } from './PlayerControls.js';
|
|
6
7
|
export type { ErrorFallback, RenderLoading, RenderPoster } from './PlayerUI.js';
|
|
7
8
|
export { Thumbnail } from './Thumbnail.js';
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import React, { useState, useEffect, useRef, useContext, useCallback, useMemo, forwardRef, useImperativeHandle, Suspense, useLayoutEffect } from 'react';
|
|
2
3
|
import { Internals, random, interpolate, Composition } from 'remotion';
|
|
3
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -115,10 +116,13 @@ class PlayerEmitter {
|
|
|
115
116
|
pause: [],
|
|
116
117
|
play: [],
|
|
117
118
|
ratechange: [],
|
|
119
|
+
scalechange: [],
|
|
118
120
|
seeked: [],
|
|
119
121
|
timeupdate: [],
|
|
120
122
|
frameupdate: [],
|
|
121
123
|
fullscreenchange: [],
|
|
124
|
+
volumechange: [],
|
|
125
|
+
mutechange: [],
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
128
|
addEventListener(name, callback) {
|
|
@@ -137,6 +141,11 @@ class PlayerEmitter {
|
|
|
137
141
|
frame,
|
|
138
142
|
});
|
|
139
143
|
}
|
|
144
|
+
dispatchVolumeChange(volume) {
|
|
145
|
+
this.dispatchEvent('volumechange', {
|
|
146
|
+
volume,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
140
149
|
dispatchPause() {
|
|
141
150
|
this.dispatchEvent('pause', undefined);
|
|
142
151
|
}
|
|
@@ -146,11 +155,16 @@ class PlayerEmitter {
|
|
|
146
155
|
dispatchEnded() {
|
|
147
156
|
this.dispatchEvent('ended', undefined);
|
|
148
157
|
}
|
|
149
|
-
|
|
158
|
+
dispatchRateChange(playbackRate) {
|
|
150
159
|
this.dispatchEvent('ratechange', {
|
|
151
160
|
playbackRate,
|
|
152
161
|
});
|
|
153
162
|
}
|
|
163
|
+
dispatchScaleChange(scale) {
|
|
164
|
+
this.dispatchEvent('scalechange', {
|
|
165
|
+
scale,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
154
168
|
dispatchError(error) {
|
|
155
169
|
this.dispatchEvent('error', {
|
|
156
170
|
error,
|
|
@@ -162,9 +176,12 @@ class PlayerEmitter {
|
|
|
162
176
|
dispatchFrameUpdate(event) {
|
|
163
177
|
this.dispatchEvent('frameupdate', event);
|
|
164
178
|
}
|
|
165
|
-
|
|
179
|
+
dispatchFullscreenChange(event) {
|
|
166
180
|
this.dispatchEvent('fullscreenchange', event);
|
|
167
181
|
}
|
|
182
|
+
dispatchMuteChange(event) {
|
|
183
|
+
this.dispatchEvent('mutechange', event);
|
|
184
|
+
}
|
|
168
185
|
}
|
|
169
186
|
class ThumbnailEmitter {
|
|
170
187
|
constructor() {
|
|
@@ -238,6 +255,26 @@ const calculateNextFrame = ({ time, currentFrame: startFrame, playbackSpeed, fps
|
|
|
238
255
|
return { nextFrame, framesToAdvance, hasEnded };
|
|
239
256
|
};
|
|
240
257
|
|
|
258
|
+
const getIsBackgrounded = () => {
|
|
259
|
+
if (typeof document === 'undefined') {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
return document.visibilityState === 'hidden';
|
|
263
|
+
};
|
|
264
|
+
const useIsBackgrounded = () => {
|
|
265
|
+
const isBackgrounded = useRef(getIsBackgrounded());
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
const onVisibilityChange = () => {
|
|
268
|
+
isBackgrounded.current = getIsBackgrounded();
|
|
269
|
+
};
|
|
270
|
+
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
271
|
+
return () => {
|
|
272
|
+
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
273
|
+
};
|
|
274
|
+
}, []);
|
|
275
|
+
return isBackgrounded;
|
|
276
|
+
};
|
|
277
|
+
|
|
241
278
|
const usePlayer = () => {
|
|
242
279
|
var _a;
|
|
243
280
|
const [playing, setPlaying, imperativePlaying] = Internals.Timeline.usePlayingState();
|
|
@@ -369,6 +406,10 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
369
406
|
const config = Internals.useUnsafeVideoConfig();
|
|
370
407
|
const { playing, pause, emitter } = usePlayer();
|
|
371
408
|
const setFrame = Internals.Timeline.useTimelineSetFrame();
|
|
409
|
+
// requestAnimationFrame() does not work if the tab is not active.
|
|
410
|
+
// This means that audio will keep playing even if it has ended.
|
|
411
|
+
// In that case, we use setTimeout() instead.
|
|
412
|
+
const isBackgroundedRef = useIsBackgrounded();
|
|
372
413
|
const frameRef = useRef(frame);
|
|
373
414
|
frameRef.current = frame;
|
|
374
415
|
const lastTimeUpdateEvent = useRef(null);
|
|
@@ -383,12 +424,20 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
383
424
|
let reqAnimFrameCall = null;
|
|
384
425
|
const startedTime = performance.now();
|
|
385
426
|
let framesAdvanced = 0;
|
|
386
|
-
const
|
|
387
|
-
hasBeenStopped = true;
|
|
427
|
+
const cancelQueuedFrame = () => {
|
|
388
428
|
if (reqAnimFrameCall !== null) {
|
|
389
|
-
|
|
429
|
+
if (reqAnimFrameCall.type === 'raf') {
|
|
430
|
+
cancelAnimationFrame(reqAnimFrameCall.id);
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
clearTimeout(reqAnimFrameCall.id);
|
|
434
|
+
}
|
|
390
435
|
}
|
|
391
436
|
};
|
|
437
|
+
const stop = () => {
|
|
438
|
+
hasBeenStopped = true;
|
|
439
|
+
cancelQueuedFrame();
|
|
440
|
+
};
|
|
392
441
|
const callback = () => {
|
|
393
442
|
const time = performance.now() - startedTime;
|
|
394
443
|
const actualLastFrame = outFrame !== null && outFrame !== void 0 ? outFrame : config.durationInFrames - 1;
|
|
@@ -415,11 +464,34 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
415
464
|
return;
|
|
416
465
|
}
|
|
417
466
|
if (!hasBeenStopped) {
|
|
418
|
-
|
|
467
|
+
queueNextFrame();
|
|
419
468
|
}
|
|
420
469
|
};
|
|
421
|
-
|
|
470
|
+
const queueNextFrame = () => {
|
|
471
|
+
if (isBackgroundedRef.current) {
|
|
472
|
+
reqAnimFrameCall = {
|
|
473
|
+
type: 'timeout',
|
|
474
|
+
// Note: Most likely, this will not be 1000 / fps, but the browser will throttle it to ~1/sec.
|
|
475
|
+
id: setTimeout(callback, 1000 / config.fps),
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
reqAnimFrameCall = { type: 'raf', id: requestAnimationFrame(callback) };
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
queueNextFrame();
|
|
483
|
+
const onVisibilityChange = () => {
|
|
484
|
+
if (document.visibilityState === 'visible') {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
// If tab goes into the background, cancel requestAnimationFrame() and update immediately.
|
|
488
|
+
// , so the transition to setTimeout() can be fulfilled.
|
|
489
|
+
cancelQueuedFrame();
|
|
490
|
+
callback();
|
|
491
|
+
};
|
|
492
|
+
window.addEventListener('visibilitychange', onVisibilityChange);
|
|
422
493
|
return () => {
|
|
494
|
+
window.removeEventListener('visibilitychange', onVisibilityChange);
|
|
423
495
|
stop();
|
|
424
496
|
};
|
|
425
497
|
}, [
|
|
@@ -433,6 +505,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
433
505
|
inFrame,
|
|
434
506
|
outFrame,
|
|
435
507
|
moveToBeginningWhenEnded,
|
|
508
|
+
isBackgroundedRef,
|
|
436
509
|
]);
|
|
437
510
|
useEffect(() => {
|
|
438
511
|
const interval = setInterval(() => {
|
|
@@ -1148,7 +1221,7 @@ if (reactVersion$1 === '0') {
|
|
|
1148
1221
|
}
|
|
1149
1222
|
const doesReactVersionSupportSuspense$1 = parseInt(reactVersion$1, 10) >= 18;
|
|
1150
1223
|
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, doubleClickToFullscreen, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, inFrame, outFrame, initiallyShowControls, renderFullscreen: renderFullscreenButton, renderPlayPauseButton, alwaysShowControls, }, ref) => {
|
|
1151
|
-
var _a, _b, _c, _d
|
|
1224
|
+
var _a, _b, _c, _d;
|
|
1152
1225
|
const config = Internals.useUnsafeVideoConfig();
|
|
1153
1226
|
const video = Internals.useVideo();
|
|
1154
1227
|
const container = useRef(null);
|
|
@@ -1234,12 +1307,12 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
1234
1307
|
var _a;
|
|
1235
1308
|
const element = (_a = document.webkitFullscreenElement) !== null && _a !== void 0 ? _a : document.fullscreenElement;
|
|
1236
1309
|
if (element && element === container.current) {
|
|
1237
|
-
player.emitter.
|
|
1310
|
+
player.emitter.dispatchFullscreenChange({
|
|
1238
1311
|
isFullscreen: true,
|
|
1239
1312
|
});
|
|
1240
1313
|
}
|
|
1241
1314
|
else {
|
|
1242
|
-
player.emitter.
|
|
1315
|
+
player.emitter.dispatchFullscreenChange({
|
|
1243
1316
|
isFullscreen: false,
|
|
1244
1317
|
});
|
|
1245
1318
|
}
|
|
@@ -1264,8 +1337,25 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
1264
1337
|
});
|
|
1265
1338
|
}, [canvasSize, config]);
|
|
1266
1339
|
const scale = (_b = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _b !== void 0 ? _b : 1;
|
|
1340
|
+
const initialScaleIgnored = useRef(false);
|
|
1341
|
+
useEffect(() => {
|
|
1342
|
+
if (!initialScaleIgnored.current) {
|
|
1343
|
+
initialScaleIgnored.current = true;
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
player.emitter.dispatchScaleChange(scale);
|
|
1347
|
+
}, [player.emitter, scale]);
|
|
1267
1348
|
const { setMediaVolume, setMediaMuted } = useContext(Internals.SetMediaVolumeContext);
|
|
1268
1349
|
const { mediaMuted, mediaVolume } = useContext(Internals.MediaVolumeContext);
|
|
1350
|
+
useEffect(() => {
|
|
1351
|
+
player.emitter.dispatchVolumeChange(mediaVolume);
|
|
1352
|
+
}, [player.emitter, mediaVolume]);
|
|
1353
|
+
const isMuted = mediaMuted || mediaVolume === 0;
|
|
1354
|
+
useEffect(() => {
|
|
1355
|
+
player.emitter.dispatchMuteChange({
|
|
1356
|
+
isMuted,
|
|
1357
|
+
});
|
|
1358
|
+
}, [player.emitter, isMuted]);
|
|
1269
1359
|
useImperativeHandle(ref, () => {
|
|
1270
1360
|
const methods = {
|
|
1271
1361
|
play: player.play,
|
|
@@ -1308,7 +1398,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
1308
1398
|
}
|
|
1309
1399
|
setMediaVolume(vol);
|
|
1310
1400
|
},
|
|
1311
|
-
isMuted: () =>
|
|
1401
|
+
isMuted: () => isMuted,
|
|
1312
1402
|
mute: () => {
|
|
1313
1403
|
setMediaMuted(true);
|
|
1314
1404
|
},
|
|
@@ -1324,6 +1414,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
1324
1414
|
isFullscreen,
|
|
1325
1415
|
loop,
|
|
1326
1416
|
mediaMuted,
|
|
1417
|
+
isMuted,
|
|
1327
1418
|
mediaVolume,
|
|
1328
1419
|
player,
|
|
1329
1420
|
requestFullscreen,
|
|
@@ -1405,7 +1496,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
1405
1496
|
showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
|
|
1406
1497
|
showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
|
|
1407
1498
|
].some(Boolean);
|
|
1408
|
-
const content = (jsxs(Fragment, { children: [jsx("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: jsx("div", { style: containerStyle, className: PLAYER_CSS_CLASSNAME, children: VideoComponent ? (jsx(ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: jsx(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...(
|
|
1499
|
+
const content = (jsxs(Fragment, { children: [jsx("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: jsx("div", { style: containerStyle, className: PLAYER_CSS_CLASSNAME, children: VideoComponent ? (jsx(ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: jsx(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) })) : null }) }), shouldShowPoster ? (jsx("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? (jsx(Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, inFrame: inFrame, outFrame: outFrame, initiallyShowControls: initiallyShowControls, playerWidth: (_d = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _d !== void 0 ? _d : 0, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton, alwaysShowControls: alwaysShowControls })) : null] }));
|
|
1409
1500
|
if (IS_NODE && !doesReactVersionSupportSuspense$1) {
|
|
1410
1501
|
return (jsx("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
1411
1502
|
}
|
|
@@ -1446,6 +1537,7 @@ const SharedPlayerContexts = ({ children, timelineContext, inputProps, fps, comp
|
|
|
1446
1537
|
defaultProps: undefined,
|
|
1447
1538
|
parentFolderName: null,
|
|
1448
1539
|
schema: null,
|
|
1540
|
+
calculateMetadata: null,
|
|
1449
1541
|
},
|
|
1450
1542
|
],
|
|
1451
1543
|
folders: [],
|
|
@@ -1464,6 +1556,7 @@ const SharedPlayerContexts = ({ children, timelineContext, inputProps, fps, comp
|
|
|
1464
1556
|
setCurrentCompositionMetadata: () => undefined,
|
|
1465
1557
|
assets: [],
|
|
1466
1558
|
setClipRegion: () => undefined,
|
|
1559
|
+
resolved: null,
|
|
1467
1560
|
};
|
|
1468
1561
|
}, [
|
|
1469
1562
|
component,
|
|
@@ -1491,7 +1584,7 @@ const SharedPlayerContexts = ({ children, timelineContext, inputProps, fps, comp
|
|
|
1491
1584
|
setMediaVolume: setMediaVolumeAndPersist,
|
|
1492
1585
|
};
|
|
1493
1586
|
}, [setMediaVolumeAndPersist]);
|
|
1494
|
-
return (jsx(Internals.CanUseRemotionHooksProvider, { children: jsx(Internals.Timeline.TimelineContext.Provider, { value: timelineContext, children: jsx(Internals.CompositionManager.Provider, { value: compositionManagerContext, children: jsx(Internals.PrefetchProvider, { children: jsx(Internals.DurationsContextProvider, { children: jsx(Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: jsx(Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: jsx(Internals.SharedAudioContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, component: component, children: children }) }) }) }) }) }) }) }));
|
|
1587
|
+
return (jsx(Internals.CanUseRemotionHooksProvider, { children: jsx(Internals.Timeline.TimelineContext.Provider, { value: timelineContext, children: jsx(Internals.CompositionManager.Provider, { value: compositionManagerContext, children: jsx(Internals.ResolveCompositionConfig, { children: jsx(Internals.PrefetchProvider, { children: jsx(Internals.DurationsContextProvider, { children: jsx(Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: jsx(Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: jsx(Internals.SharedAudioContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, component: component, children: children }) }) }) }) }) }) }) }) }));
|
|
1495
1588
|
};
|
|
1496
1589
|
|
|
1497
1590
|
const validateSingleFrame = (frame, variableName) => {
|
|
@@ -1631,6 +1724,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
1631
1724
|
allowFloats: false,
|
|
1632
1725
|
});
|
|
1633
1726
|
Internals.validateFps(fps, 'as a prop of the <Player/> component', false);
|
|
1727
|
+
Internals.validateDefaultAndInputProps(inputProps, 'inputProps', null);
|
|
1634
1728
|
validateInOutFrames({
|
|
1635
1729
|
durationInFrames,
|
|
1636
1730
|
inFrame,
|
|
@@ -1673,7 +1767,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
1673
1767
|
}
|
|
1674
1768
|
validatePlaybackRate(playbackRate);
|
|
1675
1769
|
useEffect(() => {
|
|
1676
|
-
emitter.
|
|
1770
|
+
emitter.dispatchRateChange(playbackRate);
|
|
1677
1771
|
}, [emitter, playbackRate]);
|
|
1678
1772
|
useImperativeHandle(ref, () => rootRef.current, []);
|
|
1679
1773
|
const timelineContextValue = useMemo(() => {
|
|
@@ -1706,7 +1800,8 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
1706
1800
|
Internals.CSSUtils.injectCSS(Internals.CSSUtils.makeDefaultCSS(`.${PLAYER_CSS_CLASSNAME}`, '#fff'));
|
|
1707
1801
|
}, []);
|
|
1708
1802
|
}
|
|
1709
|
-
|
|
1803
|
+
const actualInputProps = useMemo(() => inputProps !== null && inputProps !== void 0 ? inputProps : {}, [inputProps]);
|
|
1804
|
+
return (jsx(Internals.IsPlayerContextProvider, { children: jsx(SharedPlayerContexts, { timelineContext: timelineContextValue, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: actualInputProps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, children: jsx(Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx(PlayerEventEmitterContext.Provider, { value: emitter, children: jsx(PlayerUI$1, { ref: rootRef, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: passedInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
|
|
1710
1805
|
? clickToPlay
|
|
1711
1806
|
: Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), 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, alwaysShowControls: alwaysShowControls }) }) }) }) }));
|
|
1712
1807
|
};
|
|
@@ -1736,7 +1831,7 @@ if (reactVersion === '0') {
|
|
|
1736
1831
|
}
|
|
1737
1832
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
1738
1833
|
const ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className }, ref) => {
|
|
1739
|
-
var _a, _b
|
|
1834
|
+
var _a, _b;
|
|
1740
1835
|
const config = Internals.useUnsafeVideoConfig();
|
|
1741
1836
|
const video = Internals.useVideo();
|
|
1742
1837
|
const container = useRef(null);
|
|
@@ -1796,7 +1891,7 @@ const ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, classNam
|
|
|
1796
1891
|
if (!config) {
|
|
1797
1892
|
return null;
|
|
1798
1893
|
}
|
|
1799
|
-
const content = (jsx("div", { style: outer, children: jsx("div", { style: containerStyle, className: PLAYER_CSS_CLASSNAME, children: VideoComponent ? (jsx(ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: jsx(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...(
|
|
1894
|
+
const content = (jsx("div", { style: outer, children: jsx("div", { style: containerStyle, className: PLAYER_CSS_CLASSNAME, children: VideoComponent ? (jsx(ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: jsx(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...(inputProps !== null && inputProps !== void 0 ? inputProps : {}) }) })) : null }) }));
|
|
1800
1895
|
if (IS_NODE && !doesReactVersionSupportSuspense) {
|
|
1801
1896
|
return (jsx("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
1802
1897
|
}
|
|
@@ -1828,7 +1923,7 @@ const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, com
|
|
|
1828
1923
|
const passedInputProps = useMemo(() => {
|
|
1829
1924
|
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
1830
1925
|
}, [inputProps]);
|
|
1831
|
-
return (jsx(Internals.IsPlayerContextProvider, { children: jsx(SharedPlayerContexts, { timelineContext: timelineState, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps:
|
|
1926
|
+
return (jsx(Internals.IsPlayerContextProvider, { children: jsx(SharedPlayerContexts, { timelineContext: timelineState, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: passedInputProps, numberOfSharedAudioTags: 0, initiallyMuted: true, children: jsx(ThumbnailEmitterContext.Provider, { value: emitter, children: jsx(ThumbnailUI$1, { className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style }) }) }) }));
|
|
1832
1927
|
};
|
|
1833
1928
|
const forward = forwardRef;
|
|
1834
1929
|
/**
|
|
@@ -12,7 +12,7 @@ export declare type PlayerMethods = ThumbnailMethods & {
|
|
|
12
12
|
getCurrentFrame: () => number;
|
|
13
13
|
requestFullscreen: () => void;
|
|
14
14
|
exitFullscreen: () => void;
|
|
15
|
-
isFullscreen: () =>
|
|
15
|
+
isFullscreen: () => boolean;
|
|
16
16
|
setVolume: (num: number) => void;
|
|
17
17
|
getVolume: () => number;
|
|
18
18
|
isMuted: () => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
export declare type PropsIfHasProps<Schema extends
|
|
1
|
+
import type { AnyZodObject, z } from 'zod';
|
|
2
|
+
export declare type PropsIfHasProps<Schema extends AnyZodObject, Props> = AnyZodObject extends Schema ? {} extends Props ? {
|
|
3
3
|
inputProps?: z.infer<Schema> & Props;
|
|
4
4
|
} : {
|
|
5
5
|
inputProps: Props;
|