@remotion/player 4.0.527 → 4.0.529
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.js +4 -1
- package/dist/cjs/PlayerUI.js +4 -3
- package/dist/cjs/Thumbnail.js +2 -1
- package/dist/cjs/canvas-overlay-context.d.ts +2 -0
- package/dist/cjs/canvas-overlay-context.js +7 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/use-playback.js +3 -3
- package/dist/cjs/use-player-methods.js +18 -26
- package/dist/esm/index.mjs +36 -30
- package/package.json +3 -3
package/dist/cjs/Player.js
CHANGED
|
@@ -94,6 +94,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
94
94
|
const [frame, setFrame] = (0, react_1.useState)(() => ({
|
|
95
95
|
[SharedPlayerContext_js_1.PLAYER_COMP_ID]: initialFrame !== null && initialFrame !== void 0 ? initialFrame : 0,
|
|
96
96
|
}));
|
|
97
|
+
const seek = remotion_1.Internals.useTimelineSeek(setFrame);
|
|
97
98
|
const frameRef = (0, react_1.useRef)(frame);
|
|
98
99
|
frameRef.current = frame;
|
|
99
100
|
const rootRef = (0, react_1.useRef)(null);
|
|
@@ -204,7 +205,8 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
204
205
|
}, [currentPlaybackRate]);
|
|
205
206
|
const setTimelineContextValue = (0, react_1.useMemo)(() => {
|
|
206
207
|
return {
|
|
207
|
-
setFrame,
|
|
208
|
+
setFrameWithoutSeek: setFrame,
|
|
209
|
+
seek,
|
|
208
210
|
setPlaying: (updater) => {
|
|
209
211
|
const current = playingStore.store.getSnapshot().playing;
|
|
210
212
|
const next = typeof updater === 'function' ? updater(current) : updater;
|
|
@@ -226,6 +228,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
226
228
|
};
|
|
227
229
|
}, [
|
|
228
230
|
bufferingStore,
|
|
231
|
+
seek,
|
|
229
232
|
setFrame,
|
|
230
233
|
frameRef,
|
|
231
234
|
playingStore,
|
package/dist/cjs/PlayerUI.js
CHANGED
|
@@ -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)) {
|
package/dist/cjs/Thumbnail.js
CHANGED
|
@@ -44,7 +44,8 @@ const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, com
|
|
|
44
44
|
frameRef.current = timelineState.frame;
|
|
45
45
|
const setTimelineContext = (0, react_1.useMemo)(() => {
|
|
46
46
|
return {
|
|
47
|
-
|
|
47
|
+
setFrameWithoutSeek: () => undefined,
|
|
48
|
+
seek: null,
|
|
48
49
|
setPlaying: () => undefined,
|
|
49
50
|
setBuffering: (buffering) => {
|
|
50
51
|
if (bufferingStore.store.getSnapshot().buffering !== buffering) {
|
|
@@ -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);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -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
|
};
|
package/dist/cjs/use-playback.js
CHANGED
|
@@ -27,7 +27,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
27
27
|
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
28
28
|
const playing = remotion_1.Internals.usePlaying();
|
|
29
29
|
const { pause, emitter, isPlaying } = (0, use_player_methods_js_1.usePlayerMethods)();
|
|
30
|
-
const
|
|
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
33
|
const { isBuffering, subscribeBuffering } = (0, react_2.useContext)(remotion_1.Internals.SetTimelineContext);
|
|
@@ -191,7 +191,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
191
191
|
if (nextFrame !== getCurrentFrame() &&
|
|
192
192
|
(!hasEnded || moveToBeginningWhenEnded) &&
|
|
193
193
|
!isBuffering()) {
|
|
194
|
-
|
|
194
|
+
setFrameFromPlayback((c) => ({ ...c, [config.id]: nextFrame }));
|
|
195
195
|
}
|
|
196
196
|
if (hasEnded) {
|
|
197
197
|
stop();
|
|
@@ -276,7 +276,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
276
276
|
loop,
|
|
277
277
|
pause,
|
|
278
278
|
playing,
|
|
279
|
-
|
|
279
|
+
setFrameFromPlayback,
|
|
280
280
|
emitter,
|
|
281
281
|
playbackRate,
|
|
282
282
|
inFrame,
|
|
@@ -6,8 +6,7 @@ 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
|
|
10
|
-
const setTimelinePosition = remotion_1.Internals.Timeline.useTimelineSetFrame();
|
|
9
|
+
const seekFrame = remotion_1.Internals.Timeline.useTimelineSeekFrame();
|
|
11
10
|
const { setPlaying, frameRef, audioAndVideoTags, isPlaying: readIsPlaying, isBuffering, } = (0, react_1.useContext)(remotion_1.Internals.SetTimelineContext);
|
|
12
11
|
const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
|
|
13
12
|
const audioTagsContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioTagsContext);
|
|
@@ -39,18 +38,18 @@ const usePlayerMethods = () => {
|
|
|
39
38
|
: Math.max(0, newFrame);
|
|
40
39
|
fallbackFrame.current = frameToSeekTo;
|
|
41
40
|
if (video === null || video === void 0 ? void 0 : video.id) {
|
|
41
|
+
seekFrame((currentFrames) => currentFrames[video.id] === frameToSeekTo
|
|
42
|
+
? currentFrames
|
|
43
|
+
: { ...currentFrames, [video.id]: frameToSeekTo });
|
|
42
44
|
if (frameRef.current[video.id] !== frameToSeekTo) {
|
|
43
45
|
frameRef.current = {
|
|
44
46
|
...frameRef.current,
|
|
45
47
|
[video.id]: frameToSeekTo,
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
|
-
setTimelinePosition((currentFrames) => currentFrames[video.id] === frameToSeekTo
|
|
49
|
-
? currentFrames
|
|
50
|
-
: { ...currentFrames, [video.id]: frameToSeekTo });
|
|
51
50
|
}
|
|
52
51
|
emitter.dispatchSeek(frameToSeekTo);
|
|
53
|
-
}, [config, emitter, frameRef,
|
|
52
|
+
}, [config, emitter, frameRef, seekFrame, video === null || video === void 0 ? void 0 : video.id]);
|
|
54
53
|
const play = (0, react_1.useCallback)((e) => {
|
|
55
54
|
var _a;
|
|
56
55
|
const isAutoPlayAttempt = nextPlayIsAutoPlayAttempt.current;
|
|
@@ -109,25 +108,18 @@ const usePlayerMethods = () => {
|
|
|
109
108
|
setPlaying(false);
|
|
110
109
|
fallbackFrame.current = playStart.current;
|
|
111
110
|
if (config) {
|
|
111
|
+
seekFrame((currentFrames) => ({
|
|
112
|
+
...currentFrames,
|
|
113
|
+
[config.id]: playStart.current,
|
|
114
|
+
}));
|
|
112
115
|
frameRef.current = {
|
|
113
116
|
...frameRef.current,
|
|
114
117
|
[config.id]: playStart.current,
|
|
115
118
|
};
|
|
116
|
-
setTimelinePosition((currentFrames) => ({
|
|
117
|
-
...currentFrames,
|
|
118
|
-
[config.id]: playStart.current,
|
|
119
|
-
}));
|
|
120
119
|
emitter.dispatchPause();
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
|
-
}, [
|
|
124
|
-
config,
|
|
125
|
-
emitter,
|
|
126
|
-
frameRef,
|
|
127
|
-
readIsPlaying,
|
|
128
|
-
setPlaying,
|
|
129
|
-
setTimelinePosition,
|
|
130
|
-
]);
|
|
122
|
+
}, [config, emitter, frameRef, readIsPlaying, setPlaying, seekFrame]);
|
|
131
123
|
const videoId = video === null || video === void 0 ? void 0 : video.id;
|
|
132
124
|
const lastFrame = ((_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
|
|
133
125
|
const frameBack = (0, react_1.useCallback)((frames) => {
|
|
@@ -143,14 +135,14 @@ const usePlayerMethods = () => {
|
|
|
143
135
|
if (previousFrame === newFrame) {
|
|
144
136
|
return;
|
|
145
137
|
}
|
|
138
|
+
seekFrame((currentFrames) => currentFrames[videoId] === newFrame
|
|
139
|
+
? currentFrames
|
|
140
|
+
: { ...currentFrames, [videoId]: newFrame });
|
|
146
141
|
frameRef.current = {
|
|
147
142
|
...frameRef.current,
|
|
148
143
|
[videoId]: newFrame,
|
|
149
144
|
};
|
|
150
|
-
|
|
151
|
-
? currentFrames
|
|
152
|
-
: { ...currentFrames, [videoId]: newFrame });
|
|
153
|
-
}, [frameRef, readIsPlaying, setFrame, videoId]);
|
|
145
|
+
}, [frameRef, readIsPlaying, seekFrame, videoId]);
|
|
154
146
|
const frameForward = (0, react_1.useCallback)((frames) => {
|
|
155
147
|
var _a, _b;
|
|
156
148
|
if (!videoId) {
|
|
@@ -164,14 +156,14 @@ const usePlayerMethods = () => {
|
|
|
164
156
|
if (previousFrame === newFrame) {
|
|
165
157
|
return;
|
|
166
158
|
}
|
|
159
|
+
seekFrame((currentFrames) => currentFrames[videoId] === newFrame
|
|
160
|
+
? currentFrames
|
|
161
|
+
: { ...currentFrames, [videoId]: newFrame });
|
|
167
162
|
frameRef.current = {
|
|
168
163
|
...frameRef.current,
|
|
169
164
|
[videoId]: newFrame,
|
|
170
165
|
};
|
|
171
|
-
|
|
172
|
-
? currentFrames
|
|
173
|
-
: { ...currentFrames, [videoId]: newFrame });
|
|
174
|
-
}, [frameRef, lastFrame, readIsPlaying, setFrame, videoId]);
|
|
166
|
+
}, [frameRef, lastFrame, readIsPlaying, seekFrame, videoId]);
|
|
175
167
|
const toggle = (0, react_1.useCallback)((e) => {
|
|
176
168
|
if (readIsPlaying()) {
|
|
177
169
|
pause();
|
package/dist/esm/index.mjs
CHANGED
|
@@ -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,7 @@ 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
|
|
564
|
-
const setTimelinePosition = Internals3.Timeline.useTimelineSetFrame();
|
|
567
|
+
const seekFrame = Internals3.Timeline.useTimelineSeekFrame();
|
|
565
568
|
const {
|
|
566
569
|
setPlaying,
|
|
567
570
|
frameRef,
|
|
@@ -592,16 +595,16 @@ var usePlayerMethods = () => {
|
|
|
592
595
|
const frameToSeekTo = config ? Internals3.TimelinePosition.clampFrameToCompositionRange(newFrame, config.durationInFrames) : Math.max(0, newFrame);
|
|
593
596
|
fallbackFrame.current = frameToSeekTo;
|
|
594
597
|
if (video?.id) {
|
|
598
|
+
seekFrame((currentFrames) => currentFrames[video.id] === frameToSeekTo ? currentFrames : { ...currentFrames, [video.id]: frameToSeekTo });
|
|
595
599
|
if (frameRef.current[video.id] !== frameToSeekTo) {
|
|
596
600
|
frameRef.current = {
|
|
597
601
|
...frameRef.current,
|
|
598
602
|
[video.id]: frameToSeekTo
|
|
599
603
|
};
|
|
600
604
|
}
|
|
601
|
-
setTimelinePosition((currentFrames) => currentFrames[video.id] === frameToSeekTo ? currentFrames : { ...currentFrames, [video.id]: frameToSeekTo });
|
|
602
605
|
}
|
|
603
606
|
emitter.dispatchSeek(frameToSeekTo);
|
|
604
|
-
}, [config, emitter, frameRef,
|
|
607
|
+
}, [config, emitter, frameRef, seekFrame, video?.id]);
|
|
605
608
|
const play = useCallback((e) => {
|
|
606
609
|
const isAutoPlayAttempt = nextPlayIsAutoPlayAttempt.current;
|
|
607
610
|
nextPlayIsAutoPlayAttempt.current = false;
|
|
@@ -651,25 +654,18 @@ var usePlayerMethods = () => {
|
|
|
651
654
|
setPlaying(false);
|
|
652
655
|
fallbackFrame.current = playStart.current;
|
|
653
656
|
if (config) {
|
|
657
|
+
seekFrame((currentFrames) => ({
|
|
658
|
+
...currentFrames,
|
|
659
|
+
[config.id]: playStart.current
|
|
660
|
+
}));
|
|
654
661
|
frameRef.current = {
|
|
655
662
|
...frameRef.current,
|
|
656
663
|
[config.id]: playStart.current
|
|
657
664
|
};
|
|
658
|
-
setTimelinePosition((currentFrames) => ({
|
|
659
|
-
...currentFrames,
|
|
660
|
-
[config.id]: playStart.current
|
|
661
|
-
}));
|
|
662
665
|
emitter.dispatchPause();
|
|
663
666
|
}
|
|
664
667
|
}
|
|
665
|
-
}, [
|
|
666
|
-
config,
|
|
667
|
-
emitter,
|
|
668
|
-
frameRef,
|
|
669
|
-
readIsPlaying,
|
|
670
|
-
setPlaying,
|
|
671
|
-
setTimelinePosition
|
|
672
|
-
]);
|
|
668
|
+
}, [config, emitter, frameRef, readIsPlaying, setPlaying, seekFrame]);
|
|
673
669
|
const videoId = video?.id;
|
|
674
670
|
const lastFrame = (config?.durationInFrames ?? 1) - 1;
|
|
675
671
|
const frameBack = useCallback((frames) => {
|
|
@@ -684,12 +680,12 @@ var usePlayerMethods = () => {
|
|
|
684
680
|
if (previousFrame === newFrame) {
|
|
685
681
|
return;
|
|
686
682
|
}
|
|
683
|
+
seekFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
|
|
687
684
|
frameRef.current = {
|
|
688
685
|
...frameRef.current,
|
|
689
686
|
[videoId]: newFrame
|
|
690
687
|
};
|
|
691
|
-
|
|
692
|
-
}, [frameRef, readIsPlaying, setFrame, videoId]);
|
|
688
|
+
}, [frameRef, readIsPlaying, seekFrame, videoId]);
|
|
693
689
|
const frameForward = useCallback((frames) => {
|
|
694
690
|
if (!videoId) {
|
|
695
691
|
return null;
|
|
@@ -702,12 +698,12 @@ var usePlayerMethods = () => {
|
|
|
702
698
|
if (previousFrame === newFrame) {
|
|
703
699
|
return;
|
|
704
700
|
}
|
|
701
|
+
seekFrame((currentFrames) => currentFrames[videoId] === newFrame ? currentFrames : { ...currentFrames, [videoId]: newFrame });
|
|
705
702
|
frameRef.current = {
|
|
706
703
|
...frameRef.current,
|
|
707
704
|
[videoId]: newFrame
|
|
708
705
|
};
|
|
709
|
-
|
|
710
|
-
}, [frameRef, lastFrame, readIsPlaying, setFrame, videoId]);
|
|
706
|
+
}, [frameRef, lastFrame, readIsPlaying, seekFrame, videoId]);
|
|
711
707
|
const toggle = useCallback((e) => {
|
|
712
708
|
if (readIsPlaying()) {
|
|
713
709
|
pause();
|
|
@@ -963,7 +959,7 @@ var usePlayback = ({
|
|
|
963
959
|
const frame = Internals6.Timeline.useTimelinePosition();
|
|
964
960
|
const playing = Internals6.usePlaying();
|
|
965
961
|
const { pause, emitter, isPlaying } = usePlayerMethods();
|
|
966
|
-
const
|
|
962
|
+
const setFrameFromPlayback = Internals6.Timeline.useTimelineSetFrameWithoutSeek();
|
|
967
963
|
const sharedAudioContext = useContext3(Internals6.SharedAudioContext);
|
|
968
964
|
const { setPlayerMuted } = useContext3(Internals6.SetMediaVolumeContext);
|
|
969
965
|
const { isBuffering, subscribeBuffering } = useContext3(Internals6.SetTimelineContext);
|
|
@@ -1105,7 +1101,7 @@ var usePlayback = ({
|
|
|
1105
1101
|
});
|
|
1106
1102
|
framesAdvanced += framesToAdvance;
|
|
1107
1103
|
if (nextFrame !== getCurrentFrame() && (!hasEnded || moveToBeginningWhenEnded) && !isBuffering()) {
|
|
1108
|
-
|
|
1104
|
+
setFrameFromPlayback((c) => ({ ...c, [config.id]: nextFrame }));
|
|
1109
1105
|
}
|
|
1110
1106
|
if (hasEnded) {
|
|
1111
1107
|
stop();
|
|
@@ -1181,7 +1177,7 @@ var usePlayback = ({
|
|
|
1181
1177
|
loop,
|
|
1182
1178
|
pause,
|
|
1183
1179
|
playing,
|
|
1184
|
-
|
|
1180
|
+
setFrameFromPlayback,
|
|
1185
1181
|
emitter,
|
|
1186
1182
|
playbackRate,
|
|
1187
1183
|
inFrame,
|
|
@@ -2646,6 +2642,7 @@ var PlayerUI = ({
|
|
|
2646
2642
|
player.play(e);
|
|
2647
2643
|
}, [player]);
|
|
2648
2644
|
const { playerMuted, mediaVolume } = useContext4(Internals11.MediaVolumeContext);
|
|
2645
|
+
const canvasOverlay = useContext4(CanvasOverlayContext);
|
|
2649
2646
|
useEffect12(() => {
|
|
2650
2647
|
player.emitter.dispatchVolumeChange(mediaVolume);
|
|
2651
2648
|
}, [player.emitter, mediaVolume]);
|
|
@@ -2992,9 +2989,12 @@ var PlayerUI = ({
|
|
|
2992
2989
|
errorFallback,
|
|
2993
2990
|
children: /* @__PURE__ */ jsx12(Internals11.CurrentScaleContext.Provider, {
|
|
2994
2991
|
value: currentScale,
|
|
2995
|
-
children: /* @__PURE__ */ jsx12(
|
|
2996
|
-
|
|
2997
|
-
|
|
2992
|
+
children: /* @__PURE__ */ jsx12(CanvasOverlayContext.Provider, {
|
|
2993
|
+
value: null,
|
|
2994
|
+
children: /* @__PURE__ */ jsx12(VideoComponent, {
|
|
2995
|
+
...video?.props ?? {},
|
|
2996
|
+
...inputProps ?? {}
|
|
2997
|
+
})
|
|
2998
2998
|
})
|
|
2999
2999
|
})
|
|
3000
3000
|
}) : null,
|
|
@@ -3010,7 +3010,8 @@ var PlayerUI = ({
|
|
|
3010
3010
|
}) : null
|
|
3011
3011
|
]
|
|
3012
3012
|
}),
|
|
3013
|
-
/* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {})
|
|
3013
|
+
/* @__PURE__ */ jsx12(RenderWarningIfBlacklist, {}),
|
|
3014
|
+
canvasOverlay
|
|
3014
3015
|
]
|
|
3015
3016
|
}),
|
|
3016
3017
|
shouldShowPoster && posterFillMode === "player-size" ? /* @__PURE__ */ jsx12("div", {
|
|
@@ -3455,6 +3456,7 @@ var PlayerFn = ({
|
|
|
3455
3456
|
const [frame, setFrame] = useState12(() => ({
|
|
3456
3457
|
[PLAYER_COMP_ID]: initialFrame ?? 0
|
|
3457
3458
|
}));
|
|
3459
|
+
const seek = Internals15.useTimelineSeek(setFrame);
|
|
3458
3460
|
const frameRef = useRef12(frame);
|
|
3459
3461
|
frameRef.current = frame;
|
|
3460
3462
|
const rootRef = useRef12(null);
|
|
@@ -3548,7 +3550,8 @@ var PlayerFn = ({
|
|
|
3548
3550
|
}, [currentPlaybackRate]);
|
|
3549
3551
|
const setTimelineContextValue = useMemo14(() => {
|
|
3550
3552
|
return {
|
|
3551
|
-
setFrame,
|
|
3553
|
+
setFrameWithoutSeek: setFrame,
|
|
3554
|
+
seek,
|
|
3552
3555
|
setPlaying: (updater) => {
|
|
3553
3556
|
const current = playingStore.store.getSnapshot().playing;
|
|
3554
3557
|
const next = typeof updater === "function" ? updater(current) : updater;
|
|
@@ -3570,6 +3573,7 @@ var PlayerFn = ({
|
|
|
3570
3573
|
};
|
|
3571
3574
|
}, [
|
|
3572
3575
|
bufferingStore,
|
|
3576
|
+
seek,
|
|
3573
3577
|
setFrame,
|
|
3574
3578
|
frameRef,
|
|
3575
3579
|
playingStore,
|
|
@@ -3882,9 +3886,10 @@ var ThumbnailFn = ({
|
|
|
3882
3886
|
frameRef.current = timelineState.frame;
|
|
3883
3887
|
const setTimelineContext = useMemo17(() => {
|
|
3884
3888
|
return {
|
|
3885
|
-
|
|
3889
|
+
setFrameWithoutSeek: () => {
|
|
3886
3890
|
return;
|
|
3887
3891
|
},
|
|
3892
|
+
seek: null,
|
|
3888
3893
|
setPlaying: () => {
|
|
3889
3894
|
return;
|
|
3890
3895
|
},
|
|
@@ -3965,7 +3970,8 @@ var PlayerInternals = {
|
|
|
3965
3970
|
updateAllElementsSizes,
|
|
3966
3971
|
PlayerEmitterProvider,
|
|
3967
3972
|
BufferingIndicator,
|
|
3968
|
-
TimelineSequenceObserverContext
|
|
3973
|
+
TimelineSequenceObserverContext,
|
|
3974
|
+
CanvasOverlayContext
|
|
3969
3975
|
};
|
|
3970
3976
|
export {
|
|
3971
3977
|
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.
|
|
6
|
+
"version": "4.0.529",
|
|
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.
|
|
38
|
+
"remotion": "4.0.529"
|
|
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.
|
|
52
|
+
"@remotion/eslint-config-internal": "4.0.529",
|
|
53
53
|
"eslint": "9.19.0",
|
|
54
54
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
55
55
|
},
|