@remotion/player 4.0.539 → 4.0.540
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/PlaybackrateControl.d.ts +1 -1
- package/dist/cjs/Player.d.ts +2 -0
- package/dist/cjs/Player.js +2 -2
- package/dist/cjs/PlayerUI.js +2 -2
- package/dist/cjs/SharedPlayerContext.d.ts +2 -0
- package/dist/cjs/SharedPlayerContext.js +2 -2
- package/dist/cjs/Thumbnail.d.ts +2 -0
- package/dist/cjs/Thumbnail.js +2 -2
- package/dist/cjs/error-boundary.d.ts +1 -1
- package/dist/cjs/use-playback.js +6 -3
- package/dist/cjs/use-player-methods.js +16 -11
- package/dist/esm/index.mjs +26 -10
- package/package.json +6 -6
- package/dist/cjs/timeline-imperative-context.d.ts +0 -11
- package/dist/cjs/timeline-imperative-context.js +0 -76
- package/dist/cjs/use-player.d.ts +0 -21
- package/dist/cjs/use-player.js +0 -195
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Size } from './utils/use-element-size.js';
|
|
3
|
-
export declare const Checkmark: () =>
|
|
3
|
+
export declare const Checkmark: () => React.JSX.Element;
|
|
4
4
|
export declare const playerButtonStyle: React.CSSProperties;
|
|
5
5
|
export declare const PlaybackrateControl: React.FC<{
|
|
6
6
|
readonly playbackRates: number[];
|
package/dist/cjs/Player.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { PreferredEffectBackend } from 'remotion';
|
|
3
4
|
import type { AnyZodObject, CompProps, LogLevel } from 'remotion';
|
|
4
5
|
import type { BrowserMediaControlsBehavior } from './browser-mediasession.js';
|
|
5
6
|
import type { RenderMuteButton } from './MediaVolumeSlider.js';
|
|
@@ -65,6 +66,7 @@ export type PlayerProps<Schema extends AnyZodObject, Props extends Record<string
|
|
|
65
66
|
readonly logLevel?: LogLevel;
|
|
66
67
|
readonly noSuspense?: boolean;
|
|
67
68
|
readonly acknowledgeRemotionLicense?: boolean;
|
|
69
|
+
readonly preferredEffectBackend?: PreferredEffectBackend;
|
|
68
70
|
readonly audioLatencyHint?: AudioContextLatencyCategory;
|
|
69
71
|
readonly sampleRate?: number;
|
|
70
72
|
readonly volumePersistenceKey?: string;
|
package/dist/cjs/Player.js
CHANGED
|
@@ -73,7 +73,7 @@ const TimelineSequenceObserverComponent = ({ onTimelineSequenceChange }) => {
|
|
|
73
73
|
};
|
|
74
74
|
const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = no_react_1.NoReactInternals.ENABLE_V5_BREAKING_CHANGES
|
|
75
75
|
? 0
|
|
76
|
-
: 5, errorFallback = () => '⚠️', playbackRate = 1, preservePitch = false, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, renderVolumeSlider, renderCustomControls, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, defaultPremountInSeconds = no_react_1.NoReactInternals.DEFAULT_PREMOUNT_IN_SECONDS, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'playback', sampleRate = 48000, volumePersistenceKey, initialVolume, _experimentalKeepAudioContextAlive = false, ...componentProps }, ref) => {
|
|
76
|
+
: 5, errorFallback = () => '⚠️', playbackRate = 1, preservePitch = false, renderLoading, className, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, showPosterWhenBuffering, showPosterWhenBufferingAndPaused, initialFrame, renderPoster, inFrame, outFrame, initiallyShowControls, renderFullscreenButton, renderPlayPauseButton, renderVolumeSlider, renderCustomControls, alwaysShowControls = false, initiallyMuted = false, showPlaybackRateControl = false, posterFillMode = 'player-size', bufferStateDelayInMilliseconds, defaultPremountInSeconds = no_react_1.NoReactInternals.DEFAULT_PREMOUNT_IN_SECONDS, hideControlsWhenPointerDoesntMove = true, overflowVisible = false, renderMuteButton, browserMediaControlsBehavior: passedBrowserMediaControlsBehavior, overrideInternalClassName, logLevel = 'info', noSuspense, acknowledgeRemotionLicense, audioLatencyHint = 'playback', preferredEffectBackend = 'auto', sampleRate = 48000, volumePersistenceKey, initialVolume, _experimentalKeepAudioContextAlive = false, ...componentProps }, ref) => {
|
|
77
77
|
no_react_1.NoReactInternals.validateDefaultPremountInSeconds(defaultPremountInSeconds);
|
|
78
78
|
if (typeof window !== 'undefined') {
|
|
79
79
|
window.remotion_isPlayer = true;
|
|
@@ -258,7 +258,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
|
|
|
258
258
|
mode: 'prevent-media-session',
|
|
259
259
|
});
|
|
260
260
|
}, [passedBrowserMediaControlsBehavior]);
|
|
261
|
-
const player = ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, playbackRateContext: playbackRateContextValue, preservePitch: preservePitch, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, sampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, volumePersistenceKey: volumePersistenceKey, initialVolume: initialVolume, inputProps: actualInputProps, audioEnabled: true, children: (0, jsx_runtime_1.jsx)(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: (0, jsx_runtime_1.jsx)(PlayerUI_js_1.default, { ref: rootRef, posterFillMode: posterFillMode, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: actualInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
|
|
261
|
+
const player = ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineContextValue, playbackRateContext: playbackRateContextValue, preservePitch: preservePitch, component: component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: numberOfSharedAudioTags, initiallyMuted: initiallyMuted, logLevel: logLevel, audioLatencyHint: audioLatencyHint, preferredEffectBackend: preferredEffectBackend, sampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, volumePersistenceKey: volumePersistenceKey, initialVolume: initialVolume, inputProps: actualInputProps, audioEnabled: true, children: (0, jsx_runtime_1.jsx)(EmitterProvider_js_1.PlayerEmitterProvider, { currentPlaybackRate: currentPlaybackRate, children: (0, jsx_runtime_1.jsx)(PlayerUI_js_1.default, { ref: rootRef, posterFillMode: posterFillMode, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: actualInputProps, allowFullscreen: Boolean(allowFullscreen), moveToBeginningWhenEnded: Boolean(moveToBeginningWhenEnded), clickToPlay: typeof clickToPlay === 'boolean'
|
|
262
262
|
? clickToPlay
|
|
263
263
|
: Boolean(controls), showVolumeControls: Boolean(showVolumeControls), doubleClickToFullscreen: Boolean(doubleClickToFullscreen), spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: currentPlaybackRate, className: className !== null && className !== void 0 ? className : undefined, showPosterWhenUnplayed: Boolean(showPosterWhenUnplayed), showPosterWhenEnded: Boolean(showPosterWhenEnded), showPosterWhenPaused: Boolean(showPosterWhenPaused), showPosterWhenBuffering: Boolean(showPosterWhenBuffering), showPosterWhenBufferingAndPaused: Boolean(showPosterWhenBufferingAndPaused), renderPoster: renderPoster, inFrame: inFrame !== null && inFrame !== void 0 ? inFrame : null, outFrame: outFrame !== null && outFrame !== void 0 ? outFrame : null, initiallyShowControls: initiallyShowControls !== null && initiallyShowControls !== void 0 ? initiallyShowControls : true, renderFullscreen: renderFullscreenButton !== null && renderFullscreenButton !== void 0 ? renderFullscreenButton : null, renderPlayPauseButton: renderPlayPauseButton !== null && renderPlayPauseButton !== void 0 ? renderPlayPauseButton : null, renderMuteButton: renderMuteButton !== null && renderMuteButton !== void 0 ? renderMuteButton : null, renderVolumeSlider: renderVolumeSlider !== null && renderVolumeSlider !== void 0 ? renderVolumeSlider : null, renderCustomControls: renderCustomControls !== null && renderCustomControls !== void 0 ? renderCustomControls : null, alwaysShowControls: alwaysShowControls, showPlaybackRateControl: showPlaybackRateControl, bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds !== null && bufferStateDelayInMilliseconds !== void 0 ? bufferStateDelayInMilliseconds : 300, hideControlsWhenPointerDoesntMove: hideControlsWhenPointerDoesntMove, overflowVisible: overflowVisible, browserMediaControlsBehavior: browserMediaControlsBehavior, overrideInternalClassName: overrideInternalClassName !== null && overrideInternalClassName !== void 0 ? overrideInternalClassName : undefined, noSuspense: Boolean(noSuspense) }) }) }) }) }));
|
|
264
264
|
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.DefaultPremountContext.Provider, { value: defaultPremountInSeconds, children: onTimelineSequenceChange ? ((0, jsx_runtime_1.jsx)(remotion_1.Internals.SequenceRegistrationContext.Provider, { value: true, children: (0, jsx_runtime_1.jsxs)(remotion_1.Internals.SequenceManagerProvider, { children: [(0, jsx_runtime_1.jsx)(TimelineSequenceObserverComponent, { onTimelineSequenceChange: onTimelineSequenceChange }), player] }) })) : (player) }));
|
package/dist/cjs/PlayerUI.js
CHANGED
|
@@ -84,7 +84,8 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
84
84
|
setHasPlayed(true);
|
|
85
85
|
player.play(e);
|
|
86
86
|
}, [player]);
|
|
87
|
-
const
|
|
87
|
+
const [playerMuted, setPlayerMuted] = remotion_1.Internals.usePlayerMutedState();
|
|
88
|
+
const [mediaVolume, setMediaVolume] = remotion_1.Internals.useMediaVolumeState();
|
|
88
89
|
const canvasOverlay = (0, react_1.useContext)(canvas_overlay_context_js_1.CanvasOverlayContext);
|
|
89
90
|
const canvasContentRef = (0, react_1.useRef)(null);
|
|
90
91
|
(0, react_1.useEffect)(() => {
|
|
@@ -219,7 +220,6 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
219
220
|
}
|
|
220
221
|
player.emitter.dispatchScaleChange(scale);
|
|
221
222
|
}, [player.emitter, scale]);
|
|
222
|
-
const { setMediaVolume, setPlayerMuted } = (0, react_1.useContext)(remotion_1.Internals.SetMediaVolumeContext);
|
|
223
223
|
const [showBufferIndicator, setShowBufferState] = (0, react_1.useState)(false);
|
|
224
224
|
(0, react_1.useEffect)(() => {
|
|
225
225
|
let timeout = null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComponentType, LazyExoticComponent } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { PreferredEffectBackend } from 'remotion';
|
|
3
4
|
import type { LogLevel, PlaybackRateContextValue, TimelineContextValue } from 'remotion';
|
|
4
5
|
export declare const PLAYER_COMP_ID = "player-comp";
|
|
5
6
|
export declare const SharedPlayerContexts: React.FC<{
|
|
@@ -15,6 +16,7 @@ export declare const SharedPlayerContexts: React.FC<{
|
|
|
15
16
|
readonly numberOfSharedAudioTags: number;
|
|
16
17
|
readonly initiallyMuted: boolean;
|
|
17
18
|
readonly logLevel: LogLevel;
|
|
19
|
+
readonly preferredEffectBackend: PreferredEffectBackend;
|
|
18
20
|
readonly audioLatencyHint: AudioContextLatencyCategory;
|
|
19
21
|
readonly sampleRate: number;
|
|
20
22
|
readonly volumePersistenceKey?: string;
|
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
7
7
|
const volume_persistence_js_1 = require("./volume-persistence.js");
|
|
8
8
|
exports.PLAYER_COMP_ID = 'player-comp';
|
|
9
|
-
const SharedPlayerContexts = ({ children, timelineContext, playbackRateContext, preservePitch, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, initiallyMuted, logLevel, audioLatencyHint, sampleRate, volumePersistenceKey, initialVolume, inputProps, audioEnabled, _experimentalKeepAudioContextAlive, }) => {
|
|
9
|
+
const SharedPlayerContexts = ({ children, timelineContext, playbackRateContext, preservePitch, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, initiallyMuted, logLevel, audioLatencyHint, preferredEffectBackend, sampleRate, volumePersistenceKey, initialVolume, inputProps, audioEnabled, _experimentalKeepAudioContextAlive, }) => {
|
|
10
10
|
const persistVolumeToStorage = initialVolume === undefined;
|
|
11
11
|
const compositionManagerContext = (0, react_1.useMemo)(() => {
|
|
12
12
|
const context = {
|
|
@@ -93,6 +93,6 @@ const SharedPlayerContexts = ({ children, timelineContext, playbackRateContext,
|
|
|
93
93
|
isReadOnlyStudio: false,
|
|
94
94
|
};
|
|
95
95
|
}, []);
|
|
96
|
-
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.RemotionEnvironmentContext.Provider, { value: env, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.LogLevelContext.Provider, { value: logLevelContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.AbsoluteTimeContext.Provider, { value: timelineContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PlaybackRateContext.Provider, { value: playbackRateContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PlaybackPitchContext.Provider, { value: preservePitch, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.TimelineContext.Provider, { value: timelineContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.VideoProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.BufferingProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: shouldCreateAudioContext, previewSampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
96
|
+
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.RemotionEnvironmentContext.Provider, { value: env, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.LogLevelContext.Provider, { value: logLevelContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.AbsoluteTimeContext.Provider, { value: timelineContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PlaybackRateContext.Provider, { value: playbackRateContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PlaybackPitchContext.Provider, { value: preservePitch, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.TimelineContext.Provider, { value: timelineContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.VideoProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.BufferingProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SharedAudioContextProvider, { audioLatencyHint: audioLatencyHint, audioEnabled: shouldCreateAudioContext, previewSampleRate: sampleRate, _experimentalKeepAudioContextAlive: _experimentalKeepAudioContextAlive, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SharedAudioTagsContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PreferredEffectBackendContext.Provider, { value: remotion_1.Internals.validatePreferredEffectBackend(preferredEffectBackend), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
97
97
|
};
|
|
98
98
|
exports.SharedPlayerContexts = SharedPlayerContexts;
|
package/dist/cjs/Thumbnail.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { PreferredEffectBackend } from 'remotion';
|
|
2
3
|
import type { AnyZodObject, CompProps, LogLevel } from 'remotion';
|
|
3
4
|
import type { ThumbnailMethods } from './player-methods.js';
|
|
4
5
|
import type { ErrorFallback, RenderLoading } from './PlayerUI.js';
|
|
@@ -15,6 +16,7 @@ export type ThumbnailProps<Schema extends AnyZodObject, Props extends Record<str
|
|
|
15
16
|
readonly renderLoading?: RenderLoading;
|
|
16
17
|
readonly className?: string;
|
|
17
18
|
readonly overrideInternalClassName?: string;
|
|
19
|
+
readonly preferredEffectBackend?: PreferredEffectBackend;
|
|
18
20
|
readonly logLevel?: LogLevel;
|
|
19
21
|
readonly noSuspense?: boolean;
|
|
20
22
|
};
|
package/dist/cjs/Thumbnail.js
CHANGED
|
@@ -11,7 +11,7 @@ const emitter_context_js_1 = require("./emitter-context.js");
|
|
|
11
11
|
const event_emitter_js_1 = require("./event-emitter.js");
|
|
12
12
|
const SharedPlayerContext_js_1 = require("./SharedPlayerContext.js");
|
|
13
13
|
const ThumbnailUI_js_1 = __importDefault(require("./ThumbnailUI.js"));
|
|
14
|
-
const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback = () => '⚠️', renderLoading, overflowVisible = false, overrideInternalClassName, logLevel = 'info', noSuspense, ...componentProps }, ref) => {
|
|
14
|
+
const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback = () => '⚠️', renderLoading, overflowVisible = false, overrideInternalClassName, logLevel = 'info', preferredEffectBackend = 'auto', noSuspense, ...componentProps }, ref) => {
|
|
15
15
|
if (typeof window !== 'undefined') {
|
|
16
16
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
17
17
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -70,7 +70,7 @@ const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, com
|
|
|
70
70
|
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
71
71
|
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
72
72
|
}, [inputProps]);
|
|
73
|
-
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContext, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineState, playbackRateContext: playbackRateContext, preservePitch: false, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: 0, initiallyMuted: true, logLevel: logLevel, audioLatencyHint: "playback", sampleRate: 48000, inputProps: passedInputProps, audioEnabled: false, _experimentalKeepAudioContextAlive: false, children: (0, jsx_runtime_1.jsx)(emitter_context_js_1.ThumbnailEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(ThumbnailUI_js_1.default, { ref: rootRef, className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style, overflowVisible: overflowVisible, overrideInternalClassName: overrideInternalClassName, noSuspense: Boolean(noSuspense) }) }) }) }) }));
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetTimelineContext.Provider, { value: setTimelineContext, children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineState, playbackRateContext: playbackRateContext, preservePitch: false, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, numberOfSharedAudioTags: 0, initiallyMuted: true, logLevel: logLevel, audioLatencyHint: "playback", preferredEffectBackend: preferredEffectBackend, sampleRate: 48000, inputProps: passedInputProps, audioEnabled: false, _experimentalKeepAudioContextAlive: false, children: (0, jsx_runtime_1.jsx)(emitter_context_js_1.ThumbnailEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(ThumbnailUI_js_1.default, { ref: rootRef, className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style, overflowVisible: overflowVisible, overrideInternalClassName: overrideInternalClassName, noSuspense: Boolean(noSuspense) }) }) }) }) }));
|
|
74
74
|
};
|
|
75
75
|
const forward = react_1.forwardRef;
|
|
76
76
|
/*
|
|
@@ -15,5 +15,5 @@ export declare class ErrorBoundary extends React.Component<{
|
|
|
15
15
|
hasError: Error;
|
|
16
16
|
};
|
|
17
17
|
componentDidCatch(error: Error): void;
|
|
18
|
-
render(): string | number | bigint | boolean |
|
|
18
|
+
render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
|
|
19
19
|
}
|
package/dist/cjs/use-playback.js
CHANGED
|
@@ -111,8 +111,8 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
111
111
|
};
|
|
112
112
|
}, [fps, getCurrentFrame, logLevel, muted, playbackRate, sharedAudioContext]);
|
|
113
113
|
(0, react_2.useEffect)(() => {
|
|
114
|
-
var _a;
|
|
115
|
-
var
|
|
114
|
+
var _a, _b;
|
|
115
|
+
var _c;
|
|
116
116
|
const wasMuted = previousMutedRef.current;
|
|
117
117
|
previousMutedRef.current = muted;
|
|
118
118
|
if (fps === null || durationInFrames === null || compositionId === null) {
|
|
@@ -124,6 +124,9 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
124
124
|
(_a = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _a === void 0 ? void 0 : _a.call(sharedAudioContext);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
|
+
if (muted) {
|
|
128
|
+
(_b = sharedAudioContext === null || sharedAudioContext === void 0 ? void 0 : sharedAudioContext.suspend) === null || _b === void 0 ? void 0 : _b.call(sharedAudioContext);
|
|
129
|
+
}
|
|
127
130
|
// Duration and range changes update the endpoint without losing elapsed
|
|
128
131
|
// sub-frame time. A different composition or timebase needs a fresh clock.
|
|
129
132
|
const previousClock = playbackClockRef.current;
|
|
@@ -170,7 +173,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
170
173
|
let audioContextFailed = false;
|
|
171
174
|
let reqAnimFrameCall = null;
|
|
172
175
|
let playbackFrame = getCurrentFrame();
|
|
173
|
-
let lastSeekRevision = (
|
|
176
|
+
let lastSeekRevision = (_c = seek === null || seek === void 0 ? void 0 : seek.revision.current) !== null && _c !== void 0 ? _c : null;
|
|
174
177
|
const cancelQueuedFrame = () => {
|
|
175
178
|
if (reqAnimFrameCall !== null) {
|
|
176
179
|
if (reqAnimFrameCall.type === 'raf') {
|
|
@@ -10,6 +10,8 @@ const usePlayerMethods = () => {
|
|
|
10
10
|
const { setPlaying, frameRef, audioAndVideoTags, isPlaying: readIsPlaying, isBuffering, } = (0, react_1.useContext)(remotion_1.Internals.SetTimelineContext);
|
|
11
11
|
const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
|
|
12
12
|
const audioTagsContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioTagsContext);
|
|
13
|
+
const { playerMuted, mediaVolume } = (0, react_1.useContext)(remotion_1.Internals.MediaVolumeContext);
|
|
14
|
+
const muted = playerMuted || mediaVolume === 0;
|
|
13
15
|
const environment = (0, remotion_1.useRemotionEnvironment)();
|
|
14
16
|
const video = remotion_1.Internals.useVideo();
|
|
15
17
|
const videoId = (_a = video === null || video === void 0 ? void 0 : video.id) !== null && _a !== void 0 ? _a : null;
|
|
@@ -63,17 +65,19 @@ const usePlayerMethods = () => {
|
|
|
63
65
|
if (getCurrentFrame() === lastFrameForPlayback) {
|
|
64
66
|
seek(0);
|
|
65
67
|
}
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
audioTagsContext.
|
|
68
|
+
if (!muted) {
|
|
69
|
+
if (isAutoPlayAttempt) {
|
|
70
|
+
audioContext === null || audioContext === void 0 ? void 0 : audioContext.resumeAsAutoPlay();
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
audioContext === null || audioContext === void 0 ? void 0 : audioContext.resume();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Play silent audio tags to warm them up for autoplay
|
|
77
|
+
*/
|
|
78
|
+
if (audioTagsContext && audioTagsContext.numberOfAudioTags > 0 && e) {
|
|
79
|
+
audioTagsContext.playAllAudios();
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
/**
|
|
79
83
|
* Play audios and videos directly here so they can benefit from
|
|
@@ -90,6 +94,7 @@ const usePlayerMethods = () => {
|
|
|
90
94
|
config === null || config === void 0 ? void 0 : config.durationInFrames,
|
|
91
95
|
emitter,
|
|
92
96
|
getCurrentFrame,
|
|
97
|
+
muted,
|
|
93
98
|
readIsPlaying,
|
|
94
99
|
seek,
|
|
95
100
|
setPlaying,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -575,6 +575,8 @@ var usePlayerMethods = () => {
|
|
|
575
575
|
} = useContext2(Internals3.SetTimelineContext);
|
|
576
576
|
const audioContext = useContext2(Internals3.SharedAudioContext);
|
|
577
577
|
const audioTagsContext = useContext2(Internals3.SharedAudioTagsContext);
|
|
578
|
+
const { playerMuted, mediaVolume } = useContext2(Internals3.MediaVolumeContext);
|
|
579
|
+
const muted = playerMuted || mediaVolume === 0;
|
|
578
580
|
const environment = useRemotionEnvironment();
|
|
579
581
|
const video = Internals3.useVideo();
|
|
580
582
|
const videoId = video?.id ?? null;
|
|
@@ -618,13 +620,15 @@ var usePlayerMethods = () => {
|
|
|
618
620
|
if (getCurrentFrame() === lastFrameForPlayback) {
|
|
619
621
|
seek(0);
|
|
620
622
|
}
|
|
621
|
-
if (
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
audioTagsContext.
|
|
623
|
+
if (!muted) {
|
|
624
|
+
if (isAutoPlayAttempt) {
|
|
625
|
+
audioContext?.resumeAsAutoPlay();
|
|
626
|
+
} else {
|
|
627
|
+
audioContext?.resume();
|
|
628
|
+
}
|
|
629
|
+
if (audioTagsContext && audioTagsContext.numberOfAudioTags > 0 && e) {
|
|
630
|
+
audioTagsContext.playAllAudios();
|
|
631
|
+
}
|
|
628
632
|
}
|
|
629
633
|
audioAndVideoTags.current.forEach((tag) => tag.play("player play() was called and playing audio from a click"));
|
|
630
634
|
setPlaying(true);
|
|
@@ -637,6 +641,7 @@ var usePlayerMethods = () => {
|
|
|
637
641
|
config?.durationInFrames,
|
|
638
642
|
emitter,
|
|
639
643
|
getCurrentFrame,
|
|
644
|
+
muted,
|
|
640
645
|
readIsPlaying,
|
|
641
646
|
seek,
|
|
642
647
|
setPlaying
|
|
@@ -1045,6 +1050,9 @@ var usePlayback = ({
|
|
|
1045
1050
|
sharedAudioContext?.suspend?.();
|
|
1046
1051
|
return;
|
|
1047
1052
|
}
|
|
1053
|
+
if (muted) {
|
|
1054
|
+
sharedAudioContext?.suspend?.();
|
|
1055
|
+
}
|
|
1048
1056
|
const previousClock = playbackClockRef.current;
|
|
1049
1057
|
const shouldRestartClock = previousClock === null || previousClock.compositionId !== compositionId || previousClock.fps !== fps || previousClock.playbackRate !== playbackRate;
|
|
1050
1058
|
const clock = shouldRestartClock ? {
|
|
@@ -2677,7 +2685,8 @@ var PlayerUI = ({
|
|
|
2677
2685
|
setHasPlayed(true);
|
|
2678
2686
|
player.play(e);
|
|
2679
2687
|
}, [player]);
|
|
2680
|
-
const
|
|
2688
|
+
const [playerMuted, setPlayerMuted] = Internals11.usePlayerMutedState();
|
|
2689
|
+
const [mediaVolume, setMediaVolume] = Internals11.useMediaVolumeState();
|
|
2681
2690
|
const canvasOverlay = useContext4(CanvasOverlayContext);
|
|
2682
2691
|
const canvasContentRef = useRef10(null);
|
|
2683
2692
|
useEffect12(() => {
|
|
@@ -2797,7 +2806,6 @@ var PlayerUI = ({
|
|
|
2797
2806
|
}
|
|
2798
2807
|
player.emitter.dispatchScaleChange(scale);
|
|
2799
2808
|
}, [player.emitter, scale]);
|
|
2800
|
-
const { setMediaVolume, setPlayerMuted } = useContext4(Internals11.SetMediaVolumeContext);
|
|
2801
2809
|
const [showBufferIndicator, setShowBufferState] = useState10(false);
|
|
2802
2810
|
useEffect12(() => {
|
|
2803
2811
|
let timeout = null;
|
|
@@ -3160,6 +3168,7 @@ var SharedPlayerContexts = ({
|
|
|
3160
3168
|
initiallyMuted,
|
|
3161
3169
|
logLevel,
|
|
3162
3170
|
audioLatencyHint,
|
|
3171
|
+
preferredEffectBackend,
|
|
3163
3172
|
sampleRate,
|
|
3164
3173
|
volumePersistenceKey,
|
|
3165
3174
|
initialVolume,
|
|
@@ -3280,7 +3289,10 @@ var SharedPlayerContexts = ({
|
|
|
3280
3289
|
_experimentalKeepAudioContextAlive,
|
|
3281
3290
|
children: /* @__PURE__ */ jsx13(Internals13.SharedAudioTagsContextProvider, {
|
|
3282
3291
|
numberOfAudioTags: numberOfSharedAudioTags,
|
|
3283
|
-
children
|
|
3292
|
+
children: /* @__PURE__ */ jsx13(Internals13.PreferredEffectBackendContext.Provider, {
|
|
3293
|
+
value: Internals13.validatePreferredEffectBackend(preferredEffectBackend),
|
|
3294
|
+
children
|
|
3295
|
+
})
|
|
3284
3296
|
})
|
|
3285
3297
|
})
|
|
3286
3298
|
})
|
|
@@ -3482,6 +3494,7 @@ var PlayerFn = ({
|
|
|
3482
3494
|
noSuspense,
|
|
3483
3495
|
acknowledgeRemotionLicense,
|
|
3484
3496
|
audioLatencyHint = "playback",
|
|
3497
|
+
preferredEffectBackend = "auto",
|
|
3485
3498
|
sampleRate = 48000,
|
|
3486
3499
|
volumePersistenceKey,
|
|
3487
3500
|
initialVolume,
|
|
@@ -3667,6 +3680,7 @@ var PlayerFn = ({
|
|
|
3667
3680
|
initiallyMuted,
|
|
3668
3681
|
logLevel,
|
|
3669
3682
|
audioLatencyHint,
|
|
3683
|
+
preferredEffectBackend,
|
|
3670
3684
|
sampleRate,
|
|
3671
3685
|
_experimentalKeepAudioContextAlive,
|
|
3672
3686
|
volumePersistenceKey,
|
|
@@ -3913,6 +3927,7 @@ var ThumbnailFn = ({
|
|
|
3913
3927
|
overflowVisible = false,
|
|
3914
3928
|
overrideInternalClassName,
|
|
3915
3929
|
logLevel = "info",
|
|
3930
|
+
preferredEffectBackend = "auto",
|
|
3916
3931
|
noSuspense,
|
|
3917
3932
|
...componentProps
|
|
3918
3933
|
}, ref) => {
|
|
@@ -3995,6 +4010,7 @@ var ThumbnailFn = ({
|
|
|
3995
4010
|
initiallyMuted: true,
|
|
3996
4011
|
logLevel,
|
|
3997
4012
|
audioLatencyHint: "playback",
|
|
4013
|
+
preferredEffectBackend,
|
|
3998
4014
|
sampleRate: 48000,
|
|
3999
4015
|
inputProps: passedInputProps,
|
|
4000
4016
|
audioEnabled: false,
|
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.540",
|
|
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.540"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.8.0",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@testing-library/react": "16.1.0",
|
|
46
46
|
"@happy-dom/global-registrator": "14.5.1",
|
|
47
47
|
"csstype": "3.2.3",
|
|
48
|
-
"react": "19.
|
|
49
|
-
"react-dom": "19.
|
|
48
|
+
"react": "19.3.1",
|
|
49
|
+
"react-dom": "19.3.1",
|
|
50
50
|
"webpack": "5.105.0",
|
|
51
|
-
"zod": "4.
|
|
52
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
51
|
+
"zod": "4.6.7",
|
|
52
|
+
"@remotion/eslint-config-internal": "4.0.540",
|
|
53
53
|
"eslint": "9.19.0",
|
|
54
54
|
"typescript": "7.1.0-beta"
|
|
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;
|
package/dist/cjs/use-player.d.ts
DELETED
|
@@ -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 {};
|
package/dist/cjs/use-player.js
DELETED
|
@@ -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;
|