remotion 4.0.216 → 4.0.218

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.
@@ -23,4 +23,5 @@ export declare const BufferingContextReact: React.Context<BufferManager | null>;
23
23
  export declare const BufferingProvider: React.FC<{
24
24
  readonly children: React.ReactNode;
25
25
  }>;
26
+ export declare const useIsPlayerBuffering: (bufferManager: BufferManager) => boolean;
26
27
  export {};
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.BufferingProvider = exports.BufferingContextReact = void 0;
26
+ exports.useIsPlayerBuffering = exports.BufferingProvider = exports.BufferingContextReact = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
28
  const react_1 = __importStar(require("react"));
29
29
  const useBufferManager = () => {
@@ -89,3 +89,22 @@ const BufferingProvider = ({ children }) => {
89
89
  return ((0, jsx_runtime_1.jsx)(exports.BufferingContextReact.Provider, { value: bufferManager, children: children }));
90
90
  };
91
91
  exports.BufferingProvider = BufferingProvider;
92
+ const useIsPlayerBuffering = (bufferManager) => {
93
+ const [isBuffering, setIsBuffering] = (0, react_1.useState)(bufferManager.buffering.current);
94
+ (0, react_1.useEffect)(() => {
95
+ const onBuffer = () => {
96
+ setIsBuffering(true);
97
+ };
98
+ const onResume = () => {
99
+ setIsBuffering(false);
100
+ };
101
+ bufferManager.listenForBuffering(onBuffer);
102
+ bufferManager.listenForResume(onResume);
103
+ return () => {
104
+ bufferManager.listenForBuffering(() => undefined);
105
+ bufferManager.listenForResume(() => undefined);
106
+ };
107
+ }, [bufferManager]);
108
+ return isBuffering;
109
+ };
110
+ exports.useIsPlayerBuffering = useIsPlayerBuffering;
@@ -79,24 +79,18 @@ const useMediaPlayback = ({ mediaRef, src, mediaType, playbackRate: localPlaybac
79
79
  }
80
80
  return acceptableTimeshift;
81
81
  })();
82
+ const isPlayerBuffering = (0, buffering_js_1.useIsPlayerBuffering)(buffering);
82
83
  (0, react_1.useEffect)(() => {
83
84
  var _a, _b;
84
85
  if (!playing) {
85
86
  (_a = mediaRef.current) === null || _a === void 0 ? void 0 : _a.pause();
86
87
  return;
87
88
  }
88
- const isPlayerBuffering = buffering.buffering.current;
89
89
  const isMediaTagBufferingOrStalled = isMediaTagBuffering || isBuffering();
90
90
  if (isPlayerBuffering && !isMediaTagBufferingOrStalled) {
91
91
  (_b = mediaRef.current) === null || _b === void 0 ? void 0 : _b.pause();
92
92
  }
93
- }, [
94
- buffering.buffering,
95
- isBuffering,
96
- isMediaTagBuffering,
97
- mediaRef,
98
- playing,
99
- ]);
93
+ }, [isBuffering, isMediaTagBuffering, isPlayerBuffering, mediaRef, playing]);
100
94
  (0, react_1.useEffect)(() => {
101
95
  var _a;
102
96
  const tagName = mediaType === 'audio' ? '<Audio>' : '<Video>';
@@ -3,4 +3,4 @@
3
3
  * @see [Documentation](https://remotion.dev/docs/version)
4
4
  * @returns {string} The current version of the remotion package
5
5
  */
6
- export declare const VERSION = "4.0.216";
6
+ export declare const VERSION = "4.0.218";
@@ -7,4 +7,4 @@ exports.VERSION = void 0;
7
7
  * @see [Documentation](https://remotion.dev/docs/version)
8
8
  * @returns {string} The current version of the remotion package
9
9
  */
10
- exports.VERSION = '4.0.216';
10
+ exports.VERSION = '4.0.218';
@@ -105,6 +105,9 @@ const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate,
105
105
  }, [toneMapped, currentTime, src, transparent]);
106
106
  const [imageSrc, setImageSrc] = (0, react_1.useState)(null);
107
107
  (0, react_1.useLayoutEffect)(() => {
108
+ if (!window.remotion_videoEnabled) {
109
+ return;
110
+ }
108
111
  const cleanup = [];
109
112
  setImageSrc(null);
110
113
  const controller = new AbortController();
@@ -191,7 +194,7 @@ const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate,
191
194
  onVideoFrame(img);
192
195
  }
193
196
  }, [onVideoFrame]);
194
- if (!imageSrc) {
197
+ if (!imageSrc || !window.remotion_videoEnabled) {
195
198
  return null;
196
199
  }
197
200
  (0, delay_render_js_1.continueRender)(imageSrc.handle);
@@ -19,7 +19,7 @@ const VideoForRendering_js_1 = require("./VideoForRendering.js");
19
19
  const duration_state_js_1 = require("./duration-state.js");
20
20
  const VideoForwardingFunction = (props, ref) => {
21
21
  var _a, _b;
22
- const { startFrom, endAt, name, pauseWhenBuffering, stack, _remotionInternalNativeLoopPassed, showInTimeline, onAutoPlayError, crossOrigin, ...otherProps } = props;
22
+ const { startFrom, endAt, name, pauseWhenBuffering, stack, _remotionInternalNativeLoopPassed, showInTimeline, onAutoPlayError, ...otherProps } = props;
23
23
  const { loop, _remotionDebugSeeking, ...propsOtherThanLoop } = props;
24
24
  const { fps } = (0, use_video_config_js_1.useVideoConfig)();
25
25
  const environment = (0, get_remotion_environment_js_1.getRemotionEnvironment)();
@@ -57,7 +57,7 @@ const VideoForwardingFunction = (props, ref) => {
57
57
  }
58
58
  return ((0, jsx_runtime_1.jsx)(VideoForPreview_js_1.VideoForPreview, { onlyWarnForMediaSeekingError: false, ...otherProps, ref: ref, onVideoFrame: null,
59
59
  // Proposal: Make this default to true in v5
60
- pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, onDuration: onDuration, _remotionInternalStack: stack !== null && stack !== void 0 ? stack : null, _remotionInternalNativeLoopPassed: _remotionInternalNativeLoopPassed !== null && _remotionInternalNativeLoopPassed !== void 0 ? _remotionInternalNativeLoopPassed : false, _remotionDebugSeeking: _remotionDebugSeeking !== null && _remotionDebugSeeking !== void 0 ? _remotionDebugSeeking : false, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, onAutoPlayError: onAutoPlayError !== null && onAutoPlayError !== void 0 ? onAutoPlayError : undefined, crossOrigin: crossOrigin }));
60
+ pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, onDuration: onDuration, _remotionInternalStack: stack !== null && stack !== void 0 ? stack : null, _remotionInternalNativeLoopPassed: _remotionInternalNativeLoopPassed !== null && _remotionInternalNativeLoopPassed !== void 0 ? _remotionInternalNativeLoopPassed : false, _remotionDebugSeeking: _remotionDebugSeeking !== null && _remotionDebugSeeking !== void 0 ? _remotionDebugSeeking : false, showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true, onAutoPlayError: onAutoPlayError !== null && onAutoPlayError !== void 0 ? onAutoPlayError : undefined }));
61
61
  };
62
62
  /**
63
63
  * @description allows you to include a video file in your Remotion project. It wraps the native HTMLVideoElement.
@@ -9,7 +9,7 @@ type VideoForPreviewProps = RemotionVideoProps & {
9
9
  readonly _remotionDebugSeeking: boolean;
10
10
  readonly showInTimeline: boolean;
11
11
  readonly onVideoFrame: null | OnVideoFrame;
12
- readonly crossOrigin: '' | 'anonymous' | 'use-credentials' | undefined;
12
+ readonly crossOrigin?: '' | 'anonymous' | 'use-credentials';
13
13
  };
14
14
  export declare const VideoForPreview: React.ForwardRefExoticComponent<Omit<VideoForPreviewProps, "ref"> & React.RefAttributes<HTMLVideoElement>>;
15
15
  export {};
@@ -151,7 +151,7 @@ function truthy(value) {
151
151
  }
152
152
 
153
153
  // src/version.ts
154
- var VERSION = "4.0.216";
154
+ var VERSION = "4.0.218";
155
155
 
156
156
  // src/multiple-versions-warning.ts
157
157
  var checkMultipleRemotionVersions = () => {
@@ -2373,6 +2373,28 @@ var BufferingProvider = ({ children }) => {
2373
2373
  children
2374
2374
  });
2375
2375
  };
2376
+ var useIsPlayerBuffering = (bufferManager) => {
2377
+ const [isBuffering, setIsBuffering] = useState10(bufferManager.buffering.current);
2378
+ useEffect9(() => {
2379
+ const onBuffer = () => {
2380
+ setIsBuffering(true);
2381
+ };
2382
+ const onResume = () => {
2383
+ setIsBuffering(false);
2384
+ };
2385
+ bufferManager.listenForBuffering(onBuffer);
2386
+ bufferManager.listenForResume(onResume);
2387
+ return () => {
2388
+ bufferManager.listenForBuffering(() => {
2389
+ return;
2390
+ });
2391
+ bufferManager.listenForResume(() => {
2392
+ return;
2393
+ });
2394
+ };
2395
+ }, [bufferManager]);
2396
+ return isBuffering;
2397
+ };
2376
2398
 
2377
2399
  // src/use-buffer-state.ts
2378
2400
  var useBufferState = () => {
@@ -2922,23 +2944,17 @@ var useMediaPlayback = ({
2922
2944
  }
2923
2945
  return acceptableTimeshift;
2924
2946
  })();
2947
+ const isPlayerBuffering = useIsPlayerBuffering(buffering);
2925
2948
  useEffect12(() => {
2926
2949
  if (!playing) {
2927
2950
  mediaRef.current?.pause();
2928
2951
  return;
2929
2952
  }
2930
- const isPlayerBuffering = buffering.buffering.current;
2931
2953
  const isMediaTagBufferingOrStalled = isMediaTagBuffering || isBuffering();
2932
2954
  if (isPlayerBuffering && !isMediaTagBufferingOrStalled) {
2933
2955
  mediaRef.current?.pause();
2934
2956
  }
2935
- }, [
2936
- buffering.buffering,
2937
- isBuffering,
2938
- isMediaTagBuffering,
2939
- mediaRef,
2940
- playing
2941
- ]);
2957
+ }, [isBuffering, isMediaTagBuffering, isPlayerBuffering, mediaRef, playing]);
2942
2958
  useEffect12(() => {
2943
2959
  const tagName = mediaType === "audio" ? "<Audio>" : "<Video>";
2944
2960
  if (!mediaRef.current) {
@@ -5876,6 +5892,9 @@ var OffthreadVideoForRendering = ({
5876
5892
  }, [toneMapped, currentTime, src, transparent]);
5877
5893
  const [imageSrc, setImageSrc] = useState18(null);
5878
5894
  useLayoutEffect6(() => {
5895
+ if (!window.remotion_videoEnabled) {
5896
+ return;
5897
+ }
5879
5898
  const cleanup = [];
5880
5899
  setImageSrc(null);
5881
5900
  const controller = new AbortController;
@@ -5955,7 +5974,7 @@ var OffthreadVideoForRendering = ({
5955
5974
  onVideoFrame(img);
5956
5975
  }
5957
5976
  }, [onVideoFrame]);
5958
- if (!imageSrc) {
5977
+ if (!imageSrc || !window.remotion_videoEnabled) {
5959
5978
  return null;
5960
5979
  }
5961
5980
  continueRender(imageSrc.handle);
@@ -6545,7 +6564,6 @@ var VideoForwardingFunction = (props2, ref) => {
6545
6564
  _remotionInternalNativeLoopPassed,
6546
6565
  showInTimeline,
6547
6566
  onAutoPlayError,
6548
- crossOrigin,
6549
6567
  ...otherProps
6550
6568
  } = props2;
6551
6569
  const { loop, _remotionDebugSeeking, ...propsOtherThanLoop } = props2;
@@ -6620,8 +6638,7 @@ var VideoForwardingFunction = (props2, ref) => {
6620
6638
  _remotionInternalNativeLoopPassed: _remotionInternalNativeLoopPassed ?? false,
6621
6639
  _remotionDebugSeeking: _remotionDebugSeeking ?? false,
6622
6640
  showInTimeline: showInTimeline ?? true,
6623
- onAutoPlayError: onAutoPlayError ?? undefined,
6624
- crossOrigin
6641
+ onAutoPlayError: onAutoPlayError ?? undefined
6625
6642
  });
6626
6643
  };
6627
6644
  var Video = forwardRef11(VideoForwardingFunction);
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.216";
2
+ var VERSION = "4.0.218";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
4
4
  },
5
5
  "name": "remotion",
6
- "version": "4.0.216",
6
+ "version": "4.0.218",
7
7
  "description": "Make videos programmatically",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",