@remotion/player 4.0.0-preload.17 → 4.0.0-reorg.27

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.
@@ -88,6 +88,6 @@ const MediaVolumeSlider = () => {
88
88
  }
89
89
  setMediaMuted((mute) => !mute);
90
90
  }, [mediaVolume, setMediaMuted, setMediaVolume]);
91
- return ((0, jsx_runtime_1.jsxs)("div", { ref: parentDivRef, style: parentDivStyle, children: [(0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(icons_1.VolumeOffIcon, {}, void 0) : (0, jsx_runtime_1.jsx)(icons_1.VolumeOnIcon, {}, void 0) }, void 0), (focused || hover) && !mediaMuted ? ((0, jsx_runtime_1.jsx)("input", { ref: inputRef, "aria-label": "Change volume", className: player_css_classname_1.VOLUME_SLIDER_INPUT_CSS_CLASSNAME, max: 1, min: 0, onBlur: () => setFocused(false), onChange: onVolumeChange, step: 0.01, type: "range", value: mediaVolume }, void 0)) : null] }, void 0));
91
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: parentDivRef, style: parentDivStyle, children: [(0, jsx_runtime_1.jsx)("button", { "aria-label": isMutedOrZero ? 'Unmute sound' : 'Mute sound', title: isMutedOrZero ? 'Unmute sound' : 'Mute sound', onClick: onClick, onBlur: onBlur, onFocus: () => setFocused(true), style: volumeContainer, type: "button", children: isMutedOrZero ? (0, jsx_runtime_1.jsx)(icons_1.VolumeOffIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.VolumeOnIcon, {}) }), (focused || hover) && !mediaMuted ? ((0, jsx_runtime_1.jsx)("input", { ref: inputRef, "aria-label": "Change volume", className: player_css_classname_1.VOLUME_SLIDER_INPUT_CSS_CLASSNAME, max: 1, min: 0, onBlur: () => setFocused(false), onChange: onVolumeChange, step: 0.01, type: "range", value: mediaVolume })) : null] }));
92
92
  };
93
93
  exports.MediaVolumeSlider = MediaVolumeSlider;
package/dist/Player.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import React, { ComponentType, MutableRefObject } from 'react';
2
- import { CompProps } from 'remotion';
3
- import { PlayerRef } from './player-methods';
4
- import { RenderLoading } from './PlayerUI';
1
+ import type { ComponentType, MutableRefObject } from 'react';
2
+ import React from 'react';
3
+ import type { CompProps } from 'remotion';
4
+ import type { PlayerRef } from './player-methods';
5
+ import type { RenderLoading } from './PlayerUI';
5
6
  declare type PropsIfHasProps<Props> = {} extends Props ? {
6
7
  inputProps?: Props;
7
8
  } : {
@@ -28,9 +29,11 @@ export declare type PlayerProps<T> = {
28
29
  numberOfSharedAudioTags?: number;
29
30
  playbackRate?: number;
30
31
  renderLoading?: RenderLoading;
32
+ moveToBeginningWhenEnded?: boolean;
33
+ className?: string;
31
34
  } & PropsIfHasProps<T> & CompProps<T>;
32
- export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => React.ComponentType<T> | null;
33
- export declare const PlayerFn: <T>({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls, loop, autoPlay, showVolumeControls, allowFullscreen, clickToPlay, doubleClickToFullscreen, spaceKeyToPlayOrPause, numberOfSharedAudioTags, errorFallback, playbackRate, renderLoading, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
35
+ export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
36
+ export declare const PlayerFn: <T>({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls, loop, autoPlay, showVolumeControls, allowFullscreen, clickToPlay, doubleClickToFullscreen, spaceKeyToPlayOrPause, moveToBeginningWhenEnded, numberOfSharedAudioTags, errorFallback, playbackRate, renderLoading, className, ...componentProps }: PlayerProps<T>, ref: MutableRefObject<PlayerRef>) => JSX.Element;
34
37
  declare module 'react' {
35
38
  function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
36
39
  }
package/dist/Player.js CHANGED
@@ -21,7 +21,7 @@ const componentOrNullIfLazy = (props) => {
21
21
  return null;
22
22
  };
23
23
  exports.componentOrNullIfLazy = componentOrNullIfLazy;
24
- const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, ...componentProps }, ref) => {
24
+ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps, inputProps, style, controls = false, loop = false, autoPlay = false, showVolumeControls = true, allowFullscreen = true, clickToPlay, doubleClickToFullscreen = false, spaceKeyToPlayOrPause = true, moveToBeginningWhenEnded = true, numberOfSharedAudioTags = 5, errorFallback = () => '⚠️', playbackRate = 1, renderLoading, className, ...componentProps }, ref) => {
25
25
  if (typeof window !== 'undefined') {
26
26
  // eslint-disable-next-line react-hooks/rules-of-hooks
27
27
  (0, react_1.useLayoutEffect)(() => {
@@ -59,7 +59,7 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
59
59
  remotion_1.Internals.validateDimension(compositionHeight, 'compositionHeight', 'of the <Player /> component');
60
60
  remotion_1.Internals.validateDimension(compositionWidth, 'compositionWidth', 'of the <Player /> component');
61
61
  remotion_1.Internals.validateDurationInFrames(durationInFrames, 'of the <Player/> component');
62
- remotion_1.Internals.validateFps(fps, 'as a prop of the <Player/> component');
62
+ remotion_1.Internals.validateFps(fps, 'as a prop of the <Player/> component', false);
63
63
  if (typeof controls !== 'boolean' && typeof controls !== 'undefined') {
64
64
  throw new TypeError(`'controls' must be a boolean or undefined but got '${typeof controls}' instead`);
65
65
  }
@@ -179,9 +179,9 @@ const PlayerFn = ({ durationInFrames, compositionHeight, compositionWidth, fps,
179
179
  const passedInputProps = (0, react_1.useMemo)(() => {
180
180
  return inputProps !== null && inputProps !== void 0 ? inputProps : {};
181
181
  }, [inputProps]);
182
- return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, 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.SharedAudioContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(emitter_context_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_1.default, { ref: rootRef, renderLoading: renderLoading, autoPlay: Boolean(autoPlay), loop: Boolean(loop), controls: Boolean(controls), errorFallback: errorFallback, style: style, inputProps: passedInputProps, allowFullscreen: Boolean(allowFullscreen), clickToPlay: typeof clickToPlay === 'boolean'
183
- ? clickToPlay
184
- : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), setMediaVolume: setMediaVolumeAndPersist, mediaVolume: mediaVolume, mediaMuted: mediaMuted, doubleClickToFullscreen: Boolean(doubleClickToFullscreen), setMediaMuted: setMediaMuted, spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
182
+ return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, 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.SharedAudioContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: (0, jsx_runtime_1.jsx)(emitter_context_1.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(PlayerUI_1.default, { 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'
183
+ ? clickToPlay
184
+ : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), setMediaVolume: setMediaVolumeAndPersist, mediaVolume: mediaVolume, mediaMuted: mediaMuted, doubleClickToFullscreen: Boolean(doubleClickToFullscreen), setMediaMuted: setMediaMuted, spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate, className: className !== null && className !== void 0 ? className : undefined }) }) }) }) }) }) }) }) }));
185
185
  };
186
186
  exports.PlayerFn = PlayerFn;
187
187
  exports.Player = (0, react_1.forwardRef)(exports.PlayerFn);
@@ -1,5 +1,16 @@
1
- import React, { MouseEventHandler } from 'react';
2
- import { usePlayer } from './use-player';
1
+ import type { MouseEventHandler } from 'react';
2
+ import React from 'react';
3
+ import type { usePlayer } from './use-player';
4
+ declare global {
5
+ interface Document {
6
+ webkitFullscreenEnabled?: boolean;
7
+ webkitFullscreenElement?: Element;
8
+ webkitExitFullscreen?: Document['exitFullscreen'];
9
+ }
10
+ interface HTMLDivElement {
11
+ webkitRequestFullScreen: HTMLDivElement['requestFullscreen'];
12
+ }
13
+ }
3
14
  export declare const Controls: React.FC<{
4
15
  fps: number;
5
16
  durationInFrames: number;
@@ -8,7 +8,6 @@ const format_time_1 = require("./format-time");
8
8
  const icons_1 = require("./icons");
9
9
  const MediaVolumeSlider_1 = require("./MediaVolumeSlider");
10
10
  const PlayerSeekBar_1 = require("./PlayerSeekBar");
11
- const browser_supports_fullscreen_1 = require("./utils/browser-supports-fullscreen");
12
11
  const containerStyle = {
13
12
  boxSizing: 'border-box',
14
13
  position: 'absolute',
@@ -66,6 +65,7 @@ const timeLabel = {
66
65
  const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVolumeControls, onFullscreenButtonClick, allowFullscreen, onExitFullscreenButtonClick, spaceKeyToPlayOrPause, }) => {
67
66
  const playButtonRef = (0, react_1.useRef)(null);
68
67
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
68
+ const [supportsFullscreen, setSupportsFullscreen] = (0, react_1.useState)(false);
69
69
  const containerCss = (0, react_1.useMemo)(() => {
70
70
  // Hide if playing and mouse outside
71
71
  const shouldShow = hovered || !player.playing;
@@ -77,11 +77,19 @@ const Controls = ({ durationInFrames, hovered, isFullscreen, fps, player, showVo
77
77
  (0, react_1.useEffect)(() => {
78
78
  if (playButtonRef.current && spaceKeyToPlayOrPause) {
79
79
  // This switches focus to play button when player.playing flag changes
80
- playButtonRef.current.focus();
80
+ playButtonRef.current.focus({
81
+ preventScroll: true,
82
+ });
81
83
  }
82
84
  }, [player.playing, spaceKeyToPlayOrPause]);
83
- return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: buttonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: player.playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}, void 0) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {}, void 0) }, void 0), showVolumeControls ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: xSpacer }, void 0), (0, jsx_runtime_1.jsx)(MediaVolumeSlider_1.MediaVolumeSlider, {}, void 0)] }, void 0)) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }, void 0), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_1.formatTime)(frame / fps), " / ", (0, format_time_1.formatTime)(durationInFrames / fps)] }, void 0), (0, jsx_runtime_1.jsx)("div", { style: xSpacer }, void 0)] }, void 0), (0, jsx_runtime_1.jsx)("div", { style: flex1 }, void 0), browser_supports_fullscreen_1.browserSupportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: (0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: buttonStyle, onClick: isFullscreen
85
+ (0, react_1.useEffect)(() => {
86
+ var _a;
87
+ // Must be handled client-side to avoid SSR hydration mismatch
88
+ setSupportsFullscreen((_a = (typeof document !== 'undefined' &&
89
+ (document.fullscreenEnabled || document.webkitFullscreenEnabled))) !== null && _a !== void 0 ? _a : false);
90
+ }, []);
91
+ return ((0, jsx_runtime_1.jsxs)("div", { style: containerCss, children: [(0, jsx_runtime_1.jsxs)("div", { style: controlsRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: leftPartStyle, children: [(0, jsx_runtime_1.jsx)("button", { ref: playButtonRef, type: "button", style: buttonStyle, onClick: player.playing ? player.pause : player.play, "aria-label": player.playing ? 'Pause video' : 'Play video', title: player.playing ? 'Pause video' : 'Play video', children: player.playing ? (0, jsx_runtime_1.jsx)(icons_1.PauseIcon, {}) : (0, jsx_runtime_1.jsx)(icons_1.PlayIcon, {}) }), showVolumeControls ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsx)(MediaVolumeSlider_1.MediaVolumeSlider, {})] })) : null, (0, jsx_runtime_1.jsx)("div", { style: xSpacer }), (0, jsx_runtime_1.jsxs)("div", { style: timeLabel, children: [(0, format_time_1.formatTime)(frame / fps), " / ", (0, format_time_1.formatTime)(durationInFrames / fps)] }), (0, jsx_runtime_1.jsx)("div", { style: xSpacer })] }), (0, jsx_runtime_1.jsx)("div", { style: flex1 }), (0, jsx_runtime_1.jsx)("div", { style: fullscreen, children: supportsFullscreen && allowFullscreen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-label": isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', title: isFullscreen ? 'Exit fullscreen' : 'Enter Fullscreen', style: buttonStyle, onClick: isFullscreen
84
92
  ? onExitFullscreenButtonClick
85
- : onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { minimized: !isFullscreen }, void 0) }, void 0) }, void 0)) : null] }, void 0), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }, void 0), (0, jsx_runtime_1.jsx)(PlayerSeekBar_1.PlayerSeekBar, { durationInFrames: durationInFrames }, void 0)] }, void 0));
93
+ : onFullscreenButtonClick, children: (0, jsx_runtime_1.jsx)(icons_1.FullscreenIcon, { minimized: !isFullscreen }) })) : null })] }), (0, jsx_runtime_1.jsx)("div", { style: ySpacer }), (0, jsx_runtime_1.jsx)(PlayerSeekBar_1.PlayerSeekBar, { durationInFrames: durationInFrames })] }));
86
94
  };
87
95
  exports.Controls = Controls;
@@ -117,6 +117,6 @@ const PlayerSeekBar = ({ durationInFrames }) => {
117
117
  borderRadius: BAR_HEIGHT / 2,
118
118
  };
119
119
  }, [durationInFrames, frame]);
120
- return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, onPointerDown: onPointerDown, style: containerStyle, children: [(0, jsx_runtime_1.jsx)("div", { style: barBackground, children: (0, jsx_runtime_1.jsx)("div", { style: fillStyle }, void 0) }, void 0), (0, jsx_runtime_1.jsx)("div", { style: knobStyle }, void 0)] }, void 0));
120
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, onPointerDown: onPointerDown, style: containerStyle, children: [(0, jsx_runtime_1.jsx)("div", { style: barBackground, children: (0, jsx_runtime_1.jsx)("div", { style: fillStyle }) }), (0, jsx_runtime_1.jsx)("div", { style: knobStyle })] }));
121
121
  };
122
122
  exports.PlayerSeekBar = PlayerSeekBar;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { PlayerRef } from './player-methods';
2
+ import type { PlayerRef } from './player-methods';
3
3
  export declare type ErrorFallback = (info: {
4
4
  error: Error;
5
5
  }) => React.ReactNode;
@@ -25,5 +25,7 @@ declare const _default: (props: {
25
25
  errorFallback: ErrorFallback;
26
26
  playbackRate: number;
27
27
  renderLoading?: RenderLoading | undefined;
28
+ className: string | undefined;
29
+ moveToBeginningWhenEnded: boolean;
28
30
  } & React.RefAttributes<PlayerRef | null>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
29
31
  export default _default;
package/dist/PlayerUI.js CHANGED
@@ -1,7 +1,30 @@
1
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 (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
27
+ const react_1 = __importStar(require("react"));
5
28
  const remotion_1 = require("remotion");
6
29
  const calculate_scale_1 = require("./calculate-scale");
7
30
  const error_boundary_1 = require("./error-boundary");
@@ -10,12 +33,16 @@ const PlayerControls_1 = require("./PlayerControls");
10
33
  const use_hover_state_1 = require("./use-hover-state");
11
34
  const use_playback_1 = require("./use-playback");
12
35
  const use_player_1 = require("./use-player");
13
- const browser_supports_fullscreen_1 = require("./utils/browser-supports-fullscreen");
14
36
  const calculate_player_size_1 = require("./utils/calculate-player-size");
15
37
  const is_node_1 = require("./utils/is-node");
16
38
  const use_click_prevention_on_double_click_1 = require("./utils/use-click-prevention-on-double-click");
17
39
  const use_element_size_1 = require("./utils/use-element-size");
18
- const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, mediaVolume, mediaMuted, doubleClickToFullscreen, setMediaMuted, setMediaVolume, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, }, ref) => {
40
+ const reactVersion = react_1.default.version.split('.')[0];
41
+ if (reactVersion === '0') {
42
+ throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
43
+ }
44
+ const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
45
+ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, mediaVolume, mediaMuted, doubleClickToFullscreen, setMediaMuted, setMediaVolume, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, className, moveToBeginningWhenEnded, }, ref) => {
19
46
  var _a, _b, _c;
20
47
  const config = remotion_1.Internals.useUnsafeVideoConfig();
21
48
  const video = remotion_1.Internals.useVideo();
@@ -28,7 +55,13 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
28
55
  const [hasPausedToResume, setHasPausedToResume] = (0, react_1.useState)(false);
29
56
  const [shouldAutoplay, setShouldAutoPlay] = (0, react_1.useState)(autoPlay);
30
57
  const [isFullscreen, setIsFullscreen] = (0, react_1.useState)(() => false);
31
- (0, use_playback_1.usePlayback)({ loop, playbackRate });
58
+ (0, use_playback_1.usePlayback)({
59
+ loop,
60
+ playbackRate,
61
+ moveToBeginningWhenEnded,
62
+ inFrame: null,
63
+ outFrame: null,
64
+ });
32
65
  const player = (0, use_player_1.usePlayer)();
33
66
  (0, react_1.useEffect)(() => {
34
67
  if (hasPausedToResume && !player.playing) {
@@ -64,7 +97,8 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
64
97
  if (!allowFullscreen) {
65
98
  throw new Error('allowFullscreen is false');
66
99
  }
67
- if (!browser_supports_fullscreen_1.browserSupportsFullscreen) {
100
+ const supportsFullScreen = document.fullscreenEnabled || document.webkitFullscreenEnabled;
101
+ if (!supportsFullScreen) {
68
102
  throw new Error('Browser doesnt support fullscreen');
69
103
  }
70
104
  if (!container.current) {
@@ -250,10 +284,9 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
250
284
  if (!config) {
251
285
  return null;
252
286
  }
253
- const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...((_c = inputProps) !== null && _c !== void 0 ? _c : {}) }, void 0) }, void 0)) : null }, void 0) }, void 0), controls ? ((0, jsx_runtime_1.jsx)(PlayerControls_1.Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause }, void 0)) : null] }, void 0));
254
- // Don't render suspense on Node.js
255
- if (is_node_1.IS_NODE) {
256
- return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, children: content }, void 0));
287
+ const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...((_c = inputProps) !== null && _c !== void 0 ? _c : {}) }) })) : null }) }), controls ? ((0, jsx_runtime_1.jsx)(PlayerControls_1.Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause })) : null] }));
288
+ if (is_node_1.IS_NODE && !doesReactVersionSupportSuspense) {
289
+ return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
257
290
  }
258
291
  const loadingMarkup = renderLoading
259
292
  ? renderLoading({
@@ -261,6 +294,6 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
261
294
  width: outerStyle.width,
262
295
  })
263
296
  : null;
264
- return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }, void 0) }, void 0));
297
+ return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }) }));
265
298
  };
266
299
  exports.default = (0, react_1.forwardRef)(PlayerUI);
@@ -1,5 +1,5 @@
1
- import { PreviewSize } from './utils/preview-size';
2
- import { Size } from './utils/use-element-size';
1
+ import type { PreviewSize } from './utils/preview-size';
2
+ import type { Size } from './utils/use-element-size';
3
3
  export declare const calculateScale: ({ previewSize, compositionWidth, compositionHeight, canvasSize, }: {
4
4
  previewSize: PreviewSize;
5
5
  compositionWidth: number;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- import { PlayerEmitter } from './event-emitter';
2
+ import type { PlayerEmitter } from './event-emitter';
3
3
  export declare const PlayerEventEmitterContext: React.Context<PlayerEmitter | undefined>;
@@ -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 | boolean | JSX.Element | React.ReactFragment | null | undefined;
18
+ render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
19
19
  }
@@ -31,7 +31,7 @@ class ErrorBoundary extends react_1.default.Component {
31
31
  // You can render any custom fallback UI
32
32
  return ((0, jsx_runtime_1.jsx)("div", { style: errorStyle, children: this.props.errorFallback({
33
33
  error: this.state.hasError,
34
- }) }, void 0));
34
+ }) }));
35
35
  }
36
36
  return this.props.children;
37
37
  }
package/dist/icons.js CHANGED
@@ -8,11 +8,11 @@ const rotate = {
8
8
  transform: `rotate(90deg)`,
9
9
  };
10
10
  const PlayIcon = () => {
11
- return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "-100 -100 400 400", style: rotate, children: (0, jsx_runtime_1.jsx)("path", { fill: "#fff", stroke: "#fff", strokeWidth: "100", strokeLinejoin: "round", d: "M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z" }, void 0) }, void 0));
11
+ return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "-100 -100 400 400", style: rotate, children: (0, jsx_runtime_1.jsx)("path", { fill: "#fff", stroke: "#fff", strokeWidth: "100", strokeLinejoin: "round", d: "M 2 172 a 196 100 0 0 0 195 5 A 196 240 0 0 0 100 2.259 A 196 240 0 0 0 2 172 z" }) }));
12
12
  };
13
13
  exports.PlayIcon = PlayIcon;
14
14
  const PauseIcon = () => {
15
- return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 100 100", width: exports.ICON_SIZE, height: exports.ICON_SIZE, children: [(0, jsx_runtime_1.jsx)("rect", { x: "25", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" }, void 0), (0, jsx_runtime_1.jsx)("rect", { x: "55", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" }, void 0)] }, void 0));
15
+ return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 100 100", width: exports.ICON_SIZE, height: exports.ICON_SIZE, children: [(0, jsx_runtime_1.jsx)("rect", { x: "25", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" }), (0, jsx_runtime_1.jsx)("rect", { x: "55", y: "20", width: "20", height: "60", fill: "#fff", ry: "5", rx: "5" })] }));
16
16
  };
17
17
  exports.PauseIcon = PauseIcon;
18
18
  const FullscreenIcon = ({ minimized }) => {
@@ -25,26 +25,26 @@ const FullscreenIcon = ({ minimized }) => {
25
25
  M ${out} ${inset}
26
26
  L ${middleInset} ${middleInset}
27
27
  L ${inset} ${out}
28
- `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: `
28
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }), (0, jsx_runtime_1.jsx)("path", { d: `
29
29
  M ${viewSize - out} ${inset}
30
30
  L ${viewSize - middleInset} ${middleInset}
31
31
  L ${viewSize - inset} ${out}
32
- `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: `
32
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }), (0, jsx_runtime_1.jsx)("path", { d: `
33
33
  M ${out} ${viewSize - inset}
34
34
  L ${middleInset} ${viewSize - middleInset}
35
35
  L ${inset} ${viewSize - out}
36
- `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: `
36
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }), (0, jsx_runtime_1.jsx)("path", { d: `
37
37
  M ${viewSize - out} ${viewSize - inset}
38
38
  L ${viewSize - middleInset} ${viewSize - middleInset}
39
39
  L ${viewSize - inset} ${viewSize - out}
40
- `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" }, void 0)] }, void 0));
40
+ `, stroke: "#fff", strokeWidth: strokeWidth, fill: "none" })] }));
41
41
  };
42
42
  exports.FullscreenIcon = FullscreenIcon;
43
43
  const VolumeOffIcon = () => {
44
- return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M3.63 3.63a.996.996 0 000 1.41L7.29 8.7 7 9H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71v-4.17l4.18 4.18c-.49.37-1.02.68-1.6.91-.36.15-.58.53-.58.92 0 .72.73 1.18 1.39.91.8-.33 1.55-.77 2.22-1.31l1.34 1.34a.996.996 0 101.41-1.41L5.05 3.63c-.39-.39-1.02-.39-1.42 0zM19 12c0 .82-.15 1.61-.41 2.34l1.53 1.53c.56-1.17.88-2.48.88-3.87 0-3.83-2.4-7.11-5.78-8.4-.59-.23-1.22.23-1.22.86v.19c0 .38.25.71.61.85C17.18 6.54 19 9.06 19 12zm-8.71-6.29l-.17.17L12 7.76V6.41c0-.89-1.08-1.33-1.71-.7zM16.5 12A4.5 4.5 0 0014 7.97v1.79l2.48 2.48c.01-.08.02-.16.02-.24z", fill: "#fff" }, void 0) }, void 0));
44
+ return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M3.63 3.63a.996.996 0 000 1.41L7.29 8.7 7 9H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71v-4.17l4.18 4.18c-.49.37-1.02.68-1.6.91-.36.15-.58.53-.58.92 0 .72.73 1.18 1.39.91.8-.33 1.55-.77 2.22-1.31l1.34 1.34a.996.996 0 101.41-1.41L5.05 3.63c-.39-.39-1.02-.39-1.42 0zM19 12c0 .82-.15 1.61-.41 2.34l1.53 1.53c.56-1.17.88-2.48.88-3.87 0-3.83-2.4-7.11-5.78-8.4-.59-.23-1.22.23-1.22.86v.19c0 .38.25.71.61.85C17.18 6.54 19 9.06 19 12zm-8.71-6.29l-.17.17L12 7.76V6.41c0-.89-1.08-1.33-1.71-.7zM16.5 12A4.5 4.5 0 0014 7.97v1.79l2.48 2.48c.01-.08.02-.16.02-.24z", fill: "#fff" }) }));
45
45
  };
46
46
  exports.VolumeOffIcon = VolumeOffIcon;
47
47
  const VolumeOnIcon = () => {
48
- return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M3 10v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71V6.41c0-.89-1.08-1.34-1.71-.71L7 9H4c-.55 0-1 .45-1 1zm13.5 2A4.5 4.5 0 0014 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 4.45v.2c0 .38.25.71.6.85C17.18 6.53 19 9.06 19 12s-1.82 5.47-4.4 6.5c-.36.14-.6.47-.6.85v.2c0 .63.63 1.07 1.21.85C18.6 19.11 21 15.84 21 12s-2.4-7.11-5.79-8.4c-.58-.23-1.21.22-1.21.85z", fill: "#fff" }, void 0) }, void 0));
48
+ return ((0, jsx_runtime_1.jsx)("svg", { width: exports.ICON_SIZE, height: exports.ICON_SIZE, viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "M3 10v4c0 .55.45 1 1 1h3l3.29 3.29c.63.63 1.71.18 1.71-.71V6.41c0-.89-1.08-1.34-1.71-.71L7 9H4c-.55 0-1 .45-1 1zm13.5 2A4.5 4.5 0 0014 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 4.45v.2c0 .38.25.71.6.85C17.18 6.53 19 9.06 19 12s-1.82 5.47-4.4 6.5c-.36.14-.6.47-.6.85v.2c0 .63.63 1.07 1.21.85C18.6 19.11 21 15.84 21 12s-2.4-7.11-5.79-8.4c-.58-.23-1.21.22-1.21.85z", fill: "#fff" }) }));
49
49
  };
50
50
  exports.VolumeOnIcon = VolumeOnIcon;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { CallbackListener, EventTypes, PlayerEmitter } from './event-emitter';
2
+ import type { CallbackListener, EventTypes } from './event-emitter';
3
+ import { PlayerEmitter } from './event-emitter';
3
4
  export { ErrorFallback, Player } from './Player';
4
5
  export { PlayerMethods, PlayerRef } from './player-methods';
5
6
  export type { RenderLoading } from './PlayerUI';
@@ -17,13 +18,17 @@ export declare const PlayerInternals: {
17
18
  playing: boolean;
18
19
  play: (e?: import("react").SyntheticEvent<Element, Event> | undefined) => void;
19
20
  pause: () => void;
21
+ pauseAndReturnToPlayStart: () => void;
20
22
  seek: (newFrame: number) => void;
21
23
  getCurrentFrame: () => number;
22
24
  isPlaying: () => boolean;
23
25
  };
24
- usePlayback: ({ loop, playbackRate, }: {
26
+ usePlayback: ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }: {
25
27
  loop: boolean;
26
28
  playbackRate: number;
29
+ moveToBeginningWhenEnded: boolean;
30
+ inFrame: number | null;
31
+ outFrame: number | null;
27
32
  }) => void;
28
33
  useElementSize: (ref: import("react").RefObject<HTMLElement>, options: {
29
34
  triggerOnWindowResize: boolean;
@@ -1,5 +1,5 @@
1
- import { SyntheticEvent } from 'react';
2
- import { PlayerEmitter } from './event-emitter';
1
+ import type { SyntheticEvent } from 'react';
2
+ import type { PlayerEmitter } from './event-emitter';
3
3
  export declare type PlayerMethods = {
4
4
  play: (e?: SyntheticEvent) => void;
5
5
  pause: () => void;
@@ -1,6 +1,6 @@
1
- import { queries, RenderOptions } from '@testing-library/react';
2
- import { FC, ReactElement } from 'react';
1
+ import type { queries, RenderOptions } from '@testing-library/react';
2
+ import type { FC, ReactElement } from 'react';
3
3
  declare const HelloWorld: FC;
4
- declare const customRender: (ui: ReactElement, options?: Omit<RenderOptions<typeof queries, HTMLElement, HTMLElement>, "queries"> | undefined) => import("@testing-library/react").RenderResult<typeof queries, HTMLElement, HTMLElement>;
4
+ declare const customRender: (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>) => import("@testing-library/react").RenderResult<typeof queries, HTMLElement, HTMLElement>;
5
5
  export * from '@testing-library/react';
6
6
  export { customRender as render, HelloWorld };
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,14 +18,14 @@ exports.HelloWorld = exports.render = void 0;
14
18
  const jsx_runtime_1 = require("react/jsx-runtime");
15
19
  const react_1 = require("@testing-library/react");
16
20
  const HelloWorld = () => {
17
- return (0, jsx_runtime_1.jsx)("div", { children: "Hello World" }, void 0);
21
+ return (0, jsx_runtime_1.jsx)("div", { children: "Hello World" });
18
22
  };
19
23
  exports.HelloWorld = HelloWorld;
20
24
  const AllTheProviders = ({ children }) => {
21
25
  // overwriting console.error console does not gets poluted with all the errors
22
26
  // eslint-disable-next-line @typescript-eslint/no-empty-function
23
27
  window.console.error = () => { };
24
- return (0, jsx_runtime_1.jsx)("div", { children: children }, void 0);
28
+ return (0, jsx_runtime_1.jsx)("div", { children: children });
25
29
  };
26
30
  const customRender = (ui, options) => (0, react_1.render)(ui, { wrapper: AllTheProviders, ...options });
27
31
  exports.render = customRender;
@@ -10,7 +10,7 @@ test('no compositionWidth should give errors', () => {
10
10
  // @ts-expect-error
11
11
  , {
12
12
  // @ts-expect-error
13
- compositionWidth: null, errorFallback: () => 'something went wrong', compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }, void 0));
13
+ compositionWidth: null, errorFallback: () => 'something went wrong', compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
14
14
  }
15
15
  catch (e) {
16
16
  expect(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
@@ -20,7 +20,7 @@ test('no compositionHeight should give errors', () => {
20
20
  try {
21
21
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 400, errorFallback: () => 'something went wrong',
22
22
  // @ts-expect-error
23
- compositionHeight: undefined, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }, void 0));
23
+ compositionHeight: undefined, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
24
24
  }
25
25
  catch (e) {
26
26
  expect(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
@@ -30,7 +30,7 @@ test('No fps should give errors', () => {
30
30
  try {
31
31
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
32
32
  // @ts-expect-error
33
- fps: null, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }, void 0));
33
+ fps: null, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
34
34
  }
35
35
  catch (e) {
36
36
  expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
@@ -38,7 +38,7 @@ test('No fps should give errors', () => {
38
38
  try {
39
39
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
40
40
  // @ts-expect-error
41
- fps: undefined, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }, void 0));
41
+ fps: undefined, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
42
42
  }
43
43
  catch (e) {
44
44
  expect(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
@@ -48,7 +48,7 @@ test('No durationInFrames should give errors', () => {
48
48
  try {
49
49
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30,
50
50
  // @ts-expect-error
51
- durationInFrames: undefined, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }, void 0));
51
+ durationInFrames: undefined, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
52
52
  }
53
53
  catch (e) {
54
54
  expect(e.message).toMatch(/The "durationInFrames" prop of the <Player\/> component must be a number, but you passed a value of type undefined/);
@@ -56,7 +56,7 @@ test('No durationInFrames should give errors', () => {
56
56
  });
57
57
  test('Invalid playbackRate should give error', () => {
58
58
  try {
59
- (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: -5 }, void 0));
59
+ (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: -5 }));
60
60
  }
61
61
  catch (e) {
62
62
  expect(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
@@ -64,7 +64,7 @@ test('Invalid playbackRate should give error', () => {
64
64
  });
65
65
  test('playbackRate of 0 should not be possible', () => {
66
66
  try {
67
- (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: 0 }, void 0));
67
+ (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: 0 }));
68
68
  }
69
69
  catch (e) {
70
70
  expect(e.message).toMatch(/A playback rate of 0 is not supported./);
@@ -74,14 +74,14 @@ test('playbackRate of wrong type should not be possible', () => {
74
74
  try {
75
75
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true,
76
76
  // @ts-expect-error
77
- playbackRate: 'hi' }, void 0));
77
+ playbackRate: 'hi' }));
78
78
  }
79
79
  catch (e) {
80
80
  expect(e.message).toMatch(/A playback rate of 0 is not supported./);
81
81
  }
82
82
  });
83
83
  test('playbackRate of undefined should be okay', () => {
84
- (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }, void 0));
84
+ (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_1.HelloWorld, controls: true, showVolumeControls: true }));
85
85
  expect(true).toBe(true);
86
86
  });
87
87
  test('passing in <Composition /> instance should not be possible', () => {
@@ -93,21 +93,21 @@ test('passing in <Composition /> instance should not be possible', () => {
93
93
  fps: 30,
94
94
  durationInFrames: 500,
95
95
  component: test_utils_1.HelloWorld,
96
- } }, void 0));
96
+ } }));
97
97
  }).toThrow(/'component' must not be the 'Composition' component\. Pass your own React/);
98
98
  });
99
99
  test('passing in <Composition /> instance should not be possible', () => {
100
100
  expect(() => {
101
101
  (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500,
102
102
  // @ts-expect-error
103
- component: (0, jsx_runtime_1.jsx)(remotion_1.Composition, { durationInFrames: 30, fps: 30, height: 10, width: 10, id: "hello", component: test_utils_1.HelloWorld }, void 0), controls: true, showVolumeControls: true, inputProps: {
103
+ component: (0, jsx_runtime_1.jsx)(remotion_1.Composition, { durationInFrames: 30, fps: 30, height: 10, width: 10, id: "hello", component: test_utils_1.HelloWorld }), controls: true, showVolumeControls: true, inputProps: {
104
104
  id: 'HelloWorld',
105
105
  width: 500,
106
106
  height: 400,
107
107
  fps: 30,
108
108
  durationInFrames: 500,
109
109
  component: test_utils_1.HelloWorld,
110
- } }, void 0));
110
+ } }));
111
111
  }).toThrow(/'component' should not be an instance of <Composition\/>\. Pass the React component dir/);
112
112
  });
113
113
  test.each([
@@ -122,7 +122,7 @@ test.each([
122
122
  const props = {};
123
123
  props[a] = 'hey';
124
124
  try {
125
- (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30, durationInFrames: 100, component: test_utils_1.HelloWorld, ...props }, void 0));
125
+ (0, test_utils_1.render)((0, jsx_runtime_1.jsx)(index_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30, durationInFrames: 100, component: test_utils_1.HelloWorld, ...props }));
126
126
  }
127
127
  catch (e) {
128
128
  expect(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
@@ -1,4 +1,7 @@
1
- export declare const usePlayback: ({ loop, playbackRate, }: {
1
+ export declare const usePlayback: ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }: {
2
2
  loop: boolean;
3
3
  playbackRate: number;
4
+ moveToBeginningWhenEnded: boolean;
5
+ inFrame: number | null;
6
+ outFrame: number | null;
4
7
  }) => void;
@@ -5,12 +5,11 @@ const react_1 = require("react");
5
5
  const remotion_1 = require("remotion");
6
6
  const calculate_next_frame_1 = require("./calculate-next-frame");
7
7
  const use_player_1 = require("./use-player");
8
- const usePlayback = ({ loop, playbackRate, }) => {
8
+ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }) => {
9
9
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
10
10
  const config = remotion_1.Internals.useUnsafeVideoConfig();
11
11
  const { playing, pause, emitter } = (0, use_player_1.usePlayer)();
12
12
  const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
13
- const { inFrame, outFrame } = remotion_1.Internals.Timeline.useTimelineInOutFramePosition();
14
13
  const frameRef = (0, react_1.useRef)(frame);
15
14
  frameRef.current = frame;
16
15
  const lastTimeUpdateEvent = (0, react_1.useRef)(null);
@@ -46,7 +45,8 @@ const usePlayback = ({ loop, playbackRate, }) => {
46
45
  shouldLoop: loop,
47
46
  });
48
47
  framesAdvanced += framesToAdvance;
49
- if (nextFrame !== frameRef.current) {
48
+ if (nextFrame !== frameRef.current &&
49
+ (!hasEnded || moveToBeginningWhenEnded)) {
50
50
  setFrame(nextFrame);
51
51
  }
52
52
  if (hasEnded) {
@@ -73,6 +73,7 @@ const usePlayback = ({ loop, playbackRate, }) => {
73
73
  playbackRate,
74
74
  inFrame,
75
75
  outFrame,
76
+ moveToBeginningWhenEnded,
76
77
  ]);
77
78
  (0, react_1.useEffect)(() => {
78
79
  const interval = setInterval(() => {
@@ -1,14 +1,17 @@
1
- import { SyntheticEvent } from 'react';
2
- import { PlayerEmitter } from './event-emitter';
3
- export declare const usePlayer: () => {
1
+ import type { SyntheticEvent } from 'react';
2
+ import type { PlayerEmitter } from './event-emitter';
3
+ declare type UsePlayerMethods = {
4
4
  frameBack: (frames: number) => void;
5
5
  frameForward: (frames: number) => void;
6
6
  isLastFrame: boolean;
7
7
  emitter: PlayerEmitter;
8
8
  playing: boolean;
9
- play: (e?: SyntheticEvent<Element, Event> | undefined) => void;
9
+ play: (e?: SyntheticEvent) => void;
10
10
  pause: () => void;
11
+ pauseAndReturnToPlayStart: () => void;
11
12
  seek: (newFrame: number) => void;
12
13
  getCurrentFrame: () => number;
13
14
  isPlaying: () => boolean;
14
15
  };
16
+ export declare const usePlayer: () => UsePlayerMethods;
17
+ export {};
@@ -8,6 +8,7 @@ const usePlayer = () => {
8
8
  var _a;
9
9
  const [playing, setPlaying, imperativePlaying] = remotion_1.Internals.Timeline.usePlayingState();
10
10
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
11
+ const playStart = (0, react_1.useRef)(0);
11
12
  const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
12
13
  const setTimelinePosition = remotion_1.Internals.Timeline.useTimelineSetFrame();
13
14
  const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
@@ -46,6 +47,7 @@ const usePlayer = () => {
46
47
  audioAndVideoTags.current.forEach((a) => a.play());
47
48
  imperativePlaying.current = true;
48
49
  setPlaying(true);
50
+ playStart.current = frameRef.current;
49
51
  emitter.dispatchPlay();
50
52
  }, [
51
53
  imperativePlaying,
@@ -63,6 +65,14 @@ const usePlayer = () => {
63
65
  emitter.dispatchPause();
64
66
  }
65
67
  }, [emitter, imperativePlaying, setPlaying]);
68
+ const pauseAndReturnToPlayStart = (0, react_1.useCallback)(() => {
69
+ if (imperativePlaying.current) {
70
+ imperativePlaying.current = false;
71
+ setTimelinePosition(playStart.current);
72
+ setPlaying(false);
73
+ emitter.dispatchPause();
74
+ }
75
+ }, [emitter, imperativePlaying, setPlaying, setTimelinePosition]);
66
76
  const hasVideo = Boolean(video);
67
77
  const frameBack = (0, react_1.useCallback)((frames) => {
68
78
  if (!hasVideo) {
@@ -96,6 +106,7 @@ const usePlayer = () => {
96
106
  seek,
97
107
  getCurrentFrame: () => frameRef.current,
98
108
  isPlaying: () => imperativePlaying.current,
109
+ pauseAndReturnToPlayStart,
99
110
  };
100
111
  }, [
101
112
  emitter,
@@ -106,6 +117,7 @@ const usePlayer = () => {
106
117
  pause,
107
118
  play,
108
119
  playing,
120
+ pauseAndReturnToPlayStart,
109
121
  seek,
110
122
  ]);
111
123
  return returnValue;
@@ -1,5 +1,5 @@
1
- import { StandardLonghandProperties } from 'csstype';
2
- import { Size } from './use-element-size';
1
+ import type { StandardLonghandProperties } from 'csstype';
2
+ import type { Size } from './use-element-size';
3
3
  export declare const calculatePlayerSize: ({ currentSize, width, height, compositionWidth, compositionHeight, }: {
4
4
  currentSize: Size | null;
5
5
  width: StandardLonghandProperties['width'] | undefined;
@@ -1,4 +1,4 @@
1
- import { CancellablePromise } from './cancellable-promise';
1
+ import type { CancellablePromise } from './cancellable-promise';
2
2
  declare const useCancellablePromises: () => {
3
3
  appendPendingPromise: (promise: CancellablePromise) => void;
4
4
  removePendingPromise: (promise: CancellablePromise) => void;
@@ -1,3 +1,3 @@
1
- import { SyntheticEvent } from 'react';
1
+ import type { SyntheticEvent } from 'react';
2
2
  declare const useClickPreventionOnDoubleClick: (onClick: (e: SyntheticEvent) => void, onDoubleClick: () => void, doubleClickToFullscreen: boolean) => [(e: SyntheticEvent) => void, () => void];
3
3
  export { useClickPreventionOnDoubleClick };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/player",
3
- "version": "4.0.0-preload.17+14cd6033f",
3
+ "version": "4.0.0-reorg.27+4014eaff1",
4
4
  "description": "Remotion Player",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -28,14 +28,14 @@
28
28
  ],
29
29
  "license": "SEE LICENSE IN LICENSE.md",
30
30
  "dependencies": {
31
- "remotion": "4.0.0-preload.17+14cd6033f"
31
+ "remotion": "4.0.0-reorg.27+4014eaff1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=16.8.0",
35
35
  "react-dom": ">=16.8.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@jonny/eslint-config": "3.0.259",
38
+ "@jonny/eslint-config": "3.0.266",
39
39
  "@testing-library/react": "13.1.1",
40
40
  "@types/jest": "^27.4.0",
41
41
  "@types/node": "^14.14.14",
@@ -49,7 +49,7 @@
49
49
  "react": "^18.0.0",
50
50
  "react-dom": "^18.0.0",
51
51
  "ts-jest": "^27.0.5",
52
- "typescript": "^4.5.5",
52
+ "typescript": "^4.7.0",
53
53
  "webpack": "5.72.0"
54
54
  },
55
55
  "keywords": [
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "14cd6033f4ad0fa75af142d54a4cd1a23aff3f21"
66
+ "gitHead": "4014eaff1494315139386236138584496ffc6654"
67
67
  }
@@ -1,11 +0,0 @@
1
- declare global {
2
- interface Document {
3
- webkitFullscreenEnabled?: boolean;
4
- webkitFullscreenElement?: Element;
5
- webkitExitFullscreen?: Document['exitFullscreen'];
6
- }
7
- interface HTMLDivElement {
8
- webkitRequestFullScreen: HTMLDivElement['requestFullscreen'];
9
- }
10
- }
11
- export declare const browserSupportsFullscreen: boolean | undefined;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.browserSupportsFullscreen = void 0;
4
- exports.browserSupportsFullscreen = typeof document !== 'undefined' &&
5
- (document.fullscreenEnabled || document.webkitFullscreenEnabled);