@remotion/player 4.0.542 → 4.0.544

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.
@@ -4,8 +4,10 @@ exports.usePlayerMethods = void 0;
4
4
  const react_1 = require("react");
5
5
  const remotion_1 = require("remotion");
6
6
  const emitter_context_js_1 = require("./emitter-context.js");
7
+ const playback_range_context_js_1 = require("./playback-range-context.js");
7
8
  const usePlayerMethods = () => {
8
- var _a, _b, _c;
9
+ var _a;
10
+ var _b, _c, _d, _e;
9
11
  const seekFrame = remotion_1.Internals.Timeline.useTimelineSeekFrame();
10
12
  const { setPlaying, frameRef, audioAndVideoTags, isPlaying: readIsPlaying, isBuffering, } = (0, react_1.useContext)(remotion_1.Internals.SetTimelineContext);
11
13
  const audioContext = (0, react_1.useContext)(remotion_1.Internals.SharedAudioContext);
@@ -14,9 +16,11 @@ const usePlayerMethods = () => {
14
16
  const muted = playerMuted || mediaVolume === 0;
15
17
  const environment = (0, remotion_1.useRemotionEnvironment)();
16
18
  const video = remotion_1.Internals.useVideo();
17
- const videoId = (_a = video === null || video === void 0 ? void 0 : video.id) !== null && _a !== void 0 ? _a : null;
18
- const videoDurationInFrames = (_b = video === null || video === void 0 ? void 0 : video.durationInFrames) !== null && _b !== void 0 ? _b : null;
19
+ const videoId = (_b = video === null || video === void 0 ? void 0 : video.id) !== null && _b !== void 0 ? _b : null;
20
+ const videoDurationInFrames = (_c = video === null || video === void 0 ? void 0 : video.durationInFrames) !== null && _c !== void 0 ? _c : null;
19
21
  const config = remotion_1.Internals.useUnsafeVideoConfig();
22
+ const { inFrame, outFrame } = (0, react_1.useContext)(playback_range_context_js_1.PlaybackRangeContext);
23
+ const playbackRate = (_d = (_a = (0, react_1.useContext)(remotion_1.Internals.PlaybackRateContext)) === null || _a === void 0 ? void 0 : _a.playbackRate) !== null && _d !== void 0 ? _d : 1;
20
24
  const emitter = (0, react_1.useContext)(emitter_context_js_1.PlayerEventEmitterContext);
21
25
  const playStart = (0, react_1.useRef)(0);
22
26
  const fallbackFrame = (0, react_1.useRef)(null);
@@ -61,9 +65,11 @@ const usePlayerMethods = () => {
61
65
  if (readIsPlaying()) {
62
66
  return;
63
67
  }
64
- const lastFrameForPlayback = ((_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
65
- if (getCurrentFrame() === lastFrameForPlayback) {
66
- seek(0);
68
+ const rangeStart = inFrame !== null && inFrame !== void 0 ? inFrame : 0;
69
+ const rangeEnd = outFrame !== null && outFrame !== void 0 ? outFrame : ((_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
70
+ const reverse = playbackRate < 0;
71
+ if (getCurrentFrame() === (reverse ? rangeStart : rangeEnd)) {
72
+ seek(reverse ? rangeEnd : rangeStart);
67
73
  }
68
74
  if (!muted) {
69
75
  if (isAutoPlayAttempt) {
@@ -92,6 +98,9 @@ const usePlayerMethods = () => {
92
98
  audioContext,
93
99
  audioTagsContext,
94
100
  config === null || config === void 0 ? void 0 : config.durationInFrames,
101
+ inFrame,
102
+ outFrame,
103
+ playbackRate,
95
104
  emitter,
96
105
  getCurrentFrame,
97
106
  muted,
@@ -127,7 +136,7 @@ const usePlayerMethods = () => {
127
136
  }
128
137
  }
129
138
  }, [config, emitter, frameRef, readIsPlaying, setPlaying, seekFrame]);
130
- const lastFrame = ((_c = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _c !== void 0 ? _c : 1) - 1;
139
+ const lastFrame = ((_e = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _e !== void 0 ? _e : 1) - 1;
131
140
  const frameBack = (0, react_1.useCallback)((frames) => {
132
141
  var _a, _b;
133
142
  if (!videoId) {