@remotion/player 4.0.520 → 4.0.522

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.
@@ -399,10 +399,11 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
399
399
  const { handlePointerDown, handleDoubleClick } = (0, use_click_prevention_on_double_click_js_1.useClickPreventionOnDoubleClick)(onSingleClick, onDoubleClick, doubleClickToFullscreen && allowFullscreen && supportsFullScreen);
400
400
  (0, react_1.useEffect)(() => {
401
401
  if (shouldAutoplay) {
402
- play();
402
+ setHasPlayed(true);
403
+ player.playAsAutoPlay();
403
404
  setShouldAutoPlay(false);
404
405
  }
405
- }, [play, shouldAutoplay]);
406
+ }, [player, shouldAutoplay]);
406
407
  const loadingMarkup = (0, react_1.useMemo)(() => {
407
408
  return renderLoading
408
409
  ? renderLoading({
@@ -5,6 +5,7 @@ export type UsePlayerMethods = {
5
5
  frameForward: (frames: number) => void;
6
6
  emitter: PlayerEmitter;
7
7
  play: (e?: SyntheticEvent | PointerEvent) => void;
8
+ playAsAutoPlay: () => void;
8
9
  pause: () => void;
9
10
  pauseAndReturnToPlayStart: () => void;
10
11
  seek: (newFrame: number) => void;
@@ -17,6 +17,7 @@ const usePlayerMethods = () => {
17
17
  const emitter = (0, react_1.useContext)(emitter_context_js_1.PlayerEventEmitterContext);
18
18
  const playStart = (0, react_1.useRef)(0);
19
19
  const fallbackFrame = (0, react_1.useRef)(null);
20
+ const nextPlayIsAutoPlayAttempt = (0, react_1.useRef)(false);
20
21
  if (!emitter) {
21
22
  throw new TypeError('Expected Player event emitter context');
22
23
  }
@@ -52,6 +53,8 @@ const usePlayerMethods = () => {
52
53
  }, [config, emitter, frameRef, setTimelinePosition, video === null || video === void 0 ? void 0 : video.id]);
53
54
  const play = (0, react_1.useCallback)((e) => {
54
55
  var _a;
56
+ const isAutoPlayAttempt = nextPlayIsAutoPlayAttempt.current;
57
+ nextPlayIsAutoPlayAttempt.current = false;
55
58
  if (readIsPlaying()) {
56
59
  return;
57
60
  }
@@ -59,7 +62,12 @@ const usePlayerMethods = () => {
59
62
  if (getCurrentFrame() === lastFrameForPlayback) {
60
63
  seek(0);
61
64
  }
62
- audioContext === null || audioContext === void 0 ? void 0 : audioContext.resume();
65
+ if (isAutoPlayAttempt) {
66
+ audioContext === null || audioContext === void 0 ? void 0 : audioContext.resumeAsAutoPlay();
67
+ }
68
+ else {
69
+ audioContext === null || audioContext === void 0 ? void 0 : audioContext.resume();
70
+ }
63
71
  /**
64
72
  * Play silent audio tags to warm them up for autoplay
65
73
  */
@@ -85,6 +93,10 @@ const usePlayerMethods = () => {
85
93
  seek,
86
94
  setPlaying,
87
95
  ]);
96
+ const playAsAutoPlay = (0, react_1.useCallback)(() => {
97
+ nextPlayIsAutoPlayAttempt.current = true;
98
+ play();
99
+ }, [play]);
88
100
  const pause = (0, react_1.useCallback)(() => {
89
101
  if (readIsPlaying()) {
90
102
  setPlaying(false);
@@ -174,6 +186,7 @@ const usePlayerMethods = () => {
174
186
  frameForward,
175
187
  emitter,
176
188
  play,
189
+ playAsAutoPlay,
177
190
  pause,
178
191
  seek,
179
192
  getCurrentFrame,
@@ -191,6 +204,7 @@ const usePlayerMethods = () => {
191
204
  pause,
192
205
  pauseAndReturnToPlayStart,
193
206
  play,
207
+ playAsAutoPlay,
194
208
  isBuffering,
195
209
  seek,
196
210
  toggle,
@@ -577,6 +577,7 @@ var usePlayerMethods = () => {
577
577
  const emitter = useContext2(PlayerEventEmitterContext);
578
578
  const playStart = useRef(0);
579
579
  const fallbackFrame = useRef(null);
580
+ const nextPlayIsAutoPlayAttempt = useRef(false);
580
581
  if (!emitter) {
581
582
  throw new TypeError("Expected Player event emitter context");
582
583
  }
@@ -602,6 +603,8 @@ var usePlayerMethods = () => {
602
603
  emitter.dispatchSeek(frameToSeekTo);
603
604
  }, [config, emitter, frameRef, setTimelinePosition, video?.id]);
604
605
  const play = useCallback((e) => {
606
+ const isAutoPlayAttempt = nextPlayIsAutoPlayAttempt.current;
607
+ nextPlayIsAutoPlayAttempt.current = false;
605
608
  if (readIsPlaying()) {
606
609
  return;
607
610
  }
@@ -609,7 +612,11 @@ var usePlayerMethods = () => {
609
612
  if (getCurrentFrame() === lastFrameForPlayback) {
610
613
  seek(0);
611
614
  }
612
- audioContext?.resume();
615
+ if (isAutoPlayAttempt) {
616
+ audioContext?.resumeAsAutoPlay();
617
+ } else {
618
+ audioContext?.resume();
619
+ }
613
620
  if (audioTagsContext && audioTagsContext.numberOfAudioTags > 0 && e) {
614
621
  audioTagsContext.playAllAudios();
615
622
  }
@@ -628,6 +635,10 @@ var usePlayerMethods = () => {
628
635
  seek,
629
636
  setPlaying
630
637
  ]);
638
+ const playAsAutoPlay = useCallback(() => {
639
+ nextPlayIsAutoPlayAttempt.current = true;
640
+ play();
641
+ }, [play]);
631
642
  const pause = useCallback(() => {
632
643
  if (readIsPlaying()) {
633
644
  setPlaying(false);
@@ -710,6 +721,7 @@ var usePlayerMethods = () => {
710
721
  frameForward,
711
722
  emitter,
712
723
  play,
724
+ playAsAutoPlay,
713
725
  pause,
714
726
  seek,
715
727
  getCurrentFrame,
@@ -727,6 +739,7 @@ var usePlayerMethods = () => {
727
739
  pause,
728
740
  pauseAndReturnToPlayStart,
729
741
  play,
742
+ playAsAutoPlay,
730
743
  isBuffering,
731
744
  seek,
732
745
  toggle
@@ -2922,10 +2935,11 @@ var PlayerUI = ({
2922
2935
  const { handlePointerDown, handleDoubleClick } = useClickPreventionOnDoubleClick(onSingleClick, onDoubleClick, doubleClickToFullscreen && allowFullscreen && supportsFullScreen);
2923
2936
  useEffect12(() => {
2924
2937
  if (shouldAutoplay) {
2925
- play();
2938
+ setHasPlayed(true);
2939
+ player.playAsAutoPlay();
2926
2940
  setShouldAutoPlay(false);
2927
2941
  }
2928
- }, [play, shouldAutoplay]);
2942
+ }, [player, shouldAutoplay]);
2929
2943
  const loadingMarkup = useMemo12(() => {
2930
2944
  return renderLoading ? renderLoading({
2931
2945
  height: outerStyle.height,
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.520",
6
+ "version": "4.0.522",
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.520"
38
+ "remotion": "4.0.522"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=16.8.0",
@@ -48,8 +48,8 @@
48
48
  "react": "19.2.3",
49
49
  "react-dom": "19.2.3",
50
50
  "webpack": "5.105.0",
51
- "zod": "4.4.3",
52
- "@remotion/eslint-config-internal": "4.0.520",
51
+ "zod": "4.5.4",
52
+ "@remotion/eslint-config-internal": "4.0.522",
53
53
  "eslint": "9.19.0",
54
54
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
55
55
  },