@remotion/player 4.0.394 → 4.0.396

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.
@@ -11,7 +11,7 @@ const use_player_js_1 = require("./use-player.js");
11
11
  const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, browserMediaControlsBehavior, getCurrentFrame, }) => {
12
12
  const config = remotion_1.Internals.useUnsafeVideoConfig();
13
13
  const frame = remotion_1.Internals.Timeline.useTimelinePosition();
14
- const { playing, pause, emitter } = (0, use_player_js_1.usePlayer)();
14
+ const { playing, pause, emitter, isPlaying } = (0, use_player_js_1.usePlayer)();
15
15
  const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
16
16
  // requestAnimationFrame() does not work if the tab is not active.
17
17
  // This means that audio will keep playing even if it has ended.
@@ -57,6 +57,9 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
57
57
  if (hasBeenStopped) {
58
58
  return;
59
59
  }
60
+ if (!isPlaying()) {
61
+ return;
62
+ }
60
63
  const time = performance.now() - startedTime;
61
64
  const actualLastFrame = outFrame !== null && outFrame !== void 0 ? outFrame : config.durationInFrames - 1;
62
65
  const actualFirstFrame = inFrame !== null && inFrame !== void 0 ? inFrame : 0;
@@ -133,6 +136,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
133
136
  isBackgroundedRef,
134
137
  getCurrentFrame,
135
138
  context,
139
+ isPlaying,
136
140
  ]);
137
141
  (0, react_1.useEffect)(() => {
138
142
  const interval = setInterval(() => {
@@ -143,6 +143,15 @@ const usePlayer = () => {
143
143
  play(e);
144
144
  }
145
145
  }, [imperativePlaying, pause, play]);
146
+ const isPlaying = (0, react_1.useCallback)(() => {
147
+ return imperativePlaying.current;
148
+ }, [imperativePlaying]);
149
+ const getCurrentFrame = (0, react_1.useCallback)(() => {
150
+ return frameRef.current;
151
+ }, [frameRef]);
152
+ const isBuffering = (0, react_1.useCallback)(() => {
153
+ return buffering.current;
154
+ }, [buffering]);
146
155
  const returnValue = (0, react_1.useMemo)(() => {
147
156
  return {
148
157
  frameBack,
@@ -154,28 +163,29 @@ const usePlayer = () => {
154
163
  pause,
155
164
  seek,
156
165
  isFirstFrame,
157
- getCurrentFrame: () => frameRef.current,
158
- isPlaying: () => imperativePlaying.current,
159
- isBuffering: () => buffering.current,
166
+ getCurrentFrame,
167
+ isPlaying,
168
+ isBuffering,
160
169
  pauseAndReturnToPlayStart,
161
170
  hasPlayed,
162
171
  toggle,
163
172
  };
164
173
  }, [
165
- buffering,
166
174
  emitter,
167
175
  frameBack,
168
176
  frameForward,
169
177
  hasPlayed,
170
- imperativePlaying,
171
178
  isFirstFrame,
172
179
  isLastFrame,
180
+ getCurrentFrame,
173
181
  pause,
174
182
  pauseAndReturnToPlayStart,
175
183
  play,
176
184
  playing,
177
185
  seek,
178
186
  toggle,
187
+ isPlaying,
188
+ isBuffering,
179
189
  ]);
180
190
  return returnValue;
181
191
  };
@@ -687,6 +687,15 @@ var usePlayer = () => {
687
687
  play(e);
688
688
  }
689
689
  }, [imperativePlaying, pause, play]);
690
+ const isPlaying = useCallback2(() => {
691
+ return imperativePlaying.current;
692
+ }, [imperativePlaying]);
693
+ const getCurrentFrame = useCallback2(() => {
694
+ return frameRef.current;
695
+ }, [frameRef]);
696
+ const isBuffering = useCallback2(() => {
697
+ return buffering.current;
698
+ }, [buffering]);
690
699
  const returnValue = useMemo(() => {
691
700
  return {
692
701
  frameBack,
@@ -698,28 +707,29 @@ var usePlayer = () => {
698
707
  pause,
699
708
  seek,
700
709
  isFirstFrame,
701
- getCurrentFrame: () => frameRef.current,
702
- isPlaying: () => imperativePlaying.current,
703
- isBuffering: () => buffering.current,
710
+ getCurrentFrame,
711
+ isPlaying,
712
+ isBuffering,
704
713
  pauseAndReturnToPlayStart,
705
714
  hasPlayed,
706
715
  toggle
707
716
  };
708
717
  }, [
709
- buffering,
710
718
  emitter,
711
719
  frameBack,
712
720
  frameForward,
713
721
  hasPlayed,
714
- imperativePlaying,
715
722
  isFirstFrame,
716
723
  isLastFrame,
724
+ getCurrentFrame,
717
725
  pause,
718
726
  pauseAndReturnToPlayStart,
719
727
  play,
720
728
  playing,
721
729
  seek,
722
- toggle
730
+ toggle,
731
+ isPlaying,
732
+ isBuffering
723
733
  ]);
724
734
  return returnValue;
725
735
  };
@@ -897,7 +907,7 @@ var usePlayback = ({
897
907
  }) => {
898
908
  const config = Internals6.useUnsafeVideoConfig();
899
909
  const frame = Internals6.Timeline.useTimelinePosition();
900
- const { playing, pause, emitter } = usePlayer();
910
+ const { playing, pause, emitter, isPlaying } = usePlayer();
901
911
  const setFrame = Internals6.Timeline.useTimelineSetFrame();
902
912
  const isBackgroundedRef = useIsBackgrounded();
903
913
  const lastTimeUpdateEvent = useRef4(null);
@@ -938,6 +948,9 @@ var usePlayback = ({
938
948
  if (hasBeenStopped) {
939
949
  return;
940
950
  }
951
+ if (!isPlaying()) {
952
+ return;
953
+ }
941
954
  const time = performance.now() - startedTime;
942
955
  const actualLastFrame = outFrame ?? config.durationInFrames - 1;
943
956
  const actualFirstFrame = inFrame ?? 0;
@@ -1009,7 +1022,8 @@ var usePlayback = ({
1009
1022
  moveToBeginningWhenEnded,
1010
1023
  isBackgroundedRef,
1011
1024
  getCurrentFrame,
1012
- context
1025
+ context,
1026
+ isPlaying
1013
1027
  ]);
1014
1028
  useEffect5(() => {
1015
1029
  const interval = setInterval(() => {
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.394",
6
+ "version": "4.0.396",
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.394"
38
+ "remotion": "4.0.396"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=16.8.0",
@@ -49,7 +49,7 @@
49
49
  "react-dom": "19.2.3",
50
50
  "webpack": "5.96.1",
51
51
  "zod": "3.22.3",
52
- "@remotion/eslint-config-internal": "4.0.394",
52
+ "@remotion/eslint-config-internal": "4.0.396",
53
53
  "eslint": "9.19.0"
54
54
  },
55
55
  "keywords": [