@remotion/player 4.0.232 → 4.0.234

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.
@@ -15,10 +15,7 @@ type UsePlayerMethods = {
15
15
  isPlaying: () => boolean;
16
16
  hasPlayed: boolean;
17
17
  isBuffering: () => boolean;
18
- /**
19
- * @deprecated Remotion internal API
20
- */
21
- remotionInternal_currentFrameRef: React.MutableRefObject<number>;
18
+ toggle: (e?: SyntheticEvent | PointerEvent) => void;
22
19
  };
23
20
  export declare const usePlayer: () => UsePlayerMethods;
24
21
  export {};
@@ -4,6 +4,7 @@ exports.usePlayer = 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 use_frame_imperative_js_1 = require("./use-frame-imperative.js");
7
8
  const usePlayer = () => {
8
9
  var _a;
9
10
  const [playing, setPlaying, imperativePlaying] = remotion_1.Internals.Timeline.usePlayingState();
@@ -123,6 +124,15 @@ const usePlayer = () => {
123
124
  };
124
125
  });
125
126
  }, [videoId, imperativePlaying, lastFrame, setFrame]);
127
+ const getCurrentFrame = (0, use_frame_imperative_js_1.useFrameImperative)();
128
+ const toggle = (0, react_1.useCallback)((e) => {
129
+ if (imperativePlaying.current) {
130
+ pause();
131
+ }
132
+ else {
133
+ play(e);
134
+ }
135
+ }, [imperativePlaying, pause, play]);
126
136
  const returnValue = (0, react_1.useMemo)(() => {
127
137
  return {
128
138
  frameBack,
@@ -134,27 +144,30 @@ const usePlayer = () => {
134
144
  pause,
135
145
  seek,
136
146
  isFirstFrame,
137
- getCurrentFrame: () => frameRef.current,
147
+ getCurrentFrame,
138
148
  isPlaying: () => imperativePlaying.current,
139
149
  isBuffering: () => buffering.current,
140
150
  pauseAndReturnToPlayStart,
141
151
  hasPlayed,
142
152
  remotionInternal_currentFrameRef: frameRef,
153
+ toggle,
143
154
  };
144
155
  }, [
156
+ buffering,
157
+ emitter,
145
158
  frameBack,
146
159
  frameForward,
160
+ getCurrentFrame,
161
+ hasPlayed,
162
+ imperativePlaying,
163
+ isFirstFrame,
147
164
  isLastFrame,
148
- emitter,
149
- playing,
150
- play,
151
165
  pause,
152
- seek,
153
- isFirstFrame,
154
166
  pauseAndReturnToPlayStart,
155
- hasPlayed,
156
- imperativePlaying,
157
- buffering,
167
+ play,
168
+ playing,
169
+ seek,
170
+ toggle,
158
171
  ]);
159
172
  return returnValue;
160
173
  };