@remotion/player 3.1.1 → 3.1.4

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/Player.d.ts CHANGED
@@ -29,9 +29,11 @@ export declare type PlayerProps<T> = {
29
29
  numberOfSharedAudioTags?: number;
30
30
  playbackRate?: number;
31
31
  renderLoading?: RenderLoading;
32
+ moveToBeginningWhenEnded?: boolean;
33
+ className?: string;
32
34
  } & PropsIfHasProps<T> & CompProps<T>;
33
35
  export declare const componentOrNullIfLazy: <T>(props: CompProps<T>) => ComponentType<T> | null;
34
- 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;
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;
35
37
  declare module 'react' {
36
38
  function forwardRef<T, P = {}>(render: (props: P, ref: React.MutableRefObject<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
37
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)(() => {
@@ -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.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), clickToPlay: typeof clickToPlay === 'boolean'
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
183
  ? clickToPlay
184
- : Boolean(controls), showVolumeControls: Boolean(showVolumeControls), setMediaVolume: setMediaVolumeAndPersist, mediaVolume: mediaVolume, mediaMuted: mediaMuted, doubleClickToFullscreen: Boolean(doubleClickToFullscreen), setMediaMuted: setMediaMuted, spaceKeyToPlayOrPause: Boolean(spaceKeyToPlayOrPause), playbackRate: playbackRate }) }) }) }) }) }) }) }) }));
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);
@@ -77,7 +77,9 @@ 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
85
  (0, react_1.useEffect)(() => {
@@ -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
@@ -42,7 +42,7 @@ if (reactVersion === '0') {
42
42
  throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
43
43
  }
44
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, }, ref) => {
45
+ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, mediaVolume, mediaMuted, doubleClickToFullscreen, setMediaMuted, setMediaVolume, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, className, moveToBeginningWhenEnded, }, ref) => {
46
46
  var _a, _b, _c;
47
47
  const config = remotion_1.Internals.useUnsafeVideoConfig();
48
48
  const video = remotion_1.Internals.useVideo();
@@ -55,7 +55,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
55
55
  const [hasPausedToResume, setHasPausedToResume] = (0, react_1.useState)(false);
56
56
  const [shouldAutoplay, setShouldAutoPlay] = (0, react_1.useState)(autoPlay);
57
57
  const [isFullscreen, setIsFullscreen] = (0, react_1.useState)(() => false);
58
- (0, use_playback_1.usePlayback)({ loop, playbackRate });
58
+ (0, use_playback_1.usePlayback)({ loop, playbackRate, moveToBeginningWhenEnded });
59
59
  const player = (0, use_player_1.usePlayer)();
60
60
  (0, react_1.useEffect)(() => {
61
61
  if (hasPausedToResume && !player.playing) {
@@ -280,7 +280,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
280
280
  }
281
281
  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] }));
282
282
  if (is_node_1.IS_NODE && !doesReactVersionSupportSuspense) {
283
- return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, children: content }));
283
+ return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
284
284
  }
285
285
  const loadingMarkup = renderLoading
286
286
  ? renderLoading({
@@ -288,6 +288,6 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
288
288
  width: outerStyle.width,
289
289
  })
290
290
  : null;
291
- return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }) }));
291
+ 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 }) }));
292
292
  };
293
293
  exports.default = (0, react_1.forwardRef)(PlayerUI);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { CallbackListener, EventTypes } from './event-emitter';
3
2
  import { PlayerEmitter } from './event-emitter';
4
3
  export { ErrorFallback, Player } from './Player';
@@ -23,9 +22,10 @@ export declare const PlayerInternals: {
23
22
  getCurrentFrame: () => number;
24
23
  isPlaying: () => boolean;
25
24
  };
26
- usePlayback: ({ loop, playbackRate, }: {
25
+ usePlayback: ({ loop, playbackRate, moveToBeginningWhenEnded, }: {
27
26
  loop: boolean;
28
27
  playbackRate: number;
28
+ moveToBeginningWhenEnded: boolean;
29
29
  }) => void;
30
30
  useElementSize: (ref: import("react").RefObject<HTMLElement>, options: {
31
31
  triggerOnWindowResize: boolean;
@@ -1,4 +1,5 @@
1
- export declare const usePlayback: ({ loop, playbackRate, }: {
1
+ export declare const usePlayback: ({ loop, playbackRate, moveToBeginningWhenEnded, }: {
2
2
  loop: boolean;
3
3
  playbackRate: number;
4
+ moveToBeginningWhenEnded: boolean;
4
5
  }) => void;
@@ -5,7 +5,7 @@ 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, }) => {
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)();
@@ -46,7 +46,8 @@ const usePlayback = ({ loop, playbackRate, }) => {
46
46
  shouldLoop: loop,
47
47
  });
48
48
  framesAdvanced += framesToAdvance;
49
- if (nextFrame !== frameRef.current) {
49
+ if (nextFrame !== frameRef.current &&
50
+ (!hasEnded || moveToBeginningWhenEnded)) {
50
51
  setFrame(nextFrame);
51
52
  }
52
53
  if (hasEnded) {
@@ -73,6 +74,7 @@ const usePlayback = ({ loop, playbackRate, }) => {
73
74
  playbackRate,
74
75
  inFrame,
75
76
  outFrame,
77
+ moveToBeginningWhenEnded,
76
78
  ]);
77
79
  (0, react_1.useEffect)(() => {
78
80
  const interval = setInterval(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/player",
3
- "version": "3.1.1",
3
+ "version": "3.1.4",
4
4
  "description": "Remotion Player",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "license": "SEE LICENSE IN LICENSE.md",
30
30
  "dependencies": {
31
- "remotion": "3.1.1"
31
+ "remotion": "3.1.4"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=16.8.0",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "c48f9b57f744d40f9bf868c84b0f8e165ca5e679"
66
+ "gitHead": "cb662e72c635e5e70c5541d85e276ce2f4075099"
67
67
  }