Skip to content

🎥 Make videos programmatically with React

Merge branch 'main' into not-call-delay-playback

JonnyBurgerb69817b7bbd8
diff --cc packages/media/src/audio/audio-for-preview.tsx
index e224db6260,a28f4aa9ba..268221698d
--- a/packages/media/src/audio/audio-for-preview.tsx
+++ b/packages/media/src/audio/audio-for-preview.tsx
@@@ -162,8 -162,7 +164,9 @@@ const AudioForPreviewAssertedShowing: R
audioStreamIndex: audioStreamIndex ?? 0,
debugOverlay: false,
bufferState: buffer,
+ isPostmounting,
+ isPremounting,
+ globalPlaybackRate,
});
mediaPlayerRef.current = player;
@@@ -287,8 -286,7 +290,9 @@@
audioStreamIndex,
disallowFallbackToHtml5Audio,
buffer,
+ isPremounting,
+ isPostmounting,
+ globalPlaybackRate,
]);
useEffect(() => {
diff --cc packages/media/src/media-player.ts
index 909b6f9d30,f330147535..07e4bed0e3
--- a/packages/media/src/media-player.ts
+++ b/packages/media/src/media-player.ts
@@@ -77,8 -64,7 +64,9 @@@ export class MediaPlayer
private bufferState: ReturnType<typeof useBufferState>;
+ private isPremounting: boolean;
+ private isPostmounting: boolean;
+ private seekPromiseChain: Promise<void> = Promise.resolve();
constructor({
canvas,
@@@ -93,10 -80,8 +82,10 @@@
fps,
debugOverlay,
bufferState,
+ isPremounting,
+ isPostmounting,
}: {
- canvas: HTMLCanvasElement | null;
+ canvas: HTMLCanvasElement | OffscreenCanvas | null;
src: string;
logLevel: LogLevel;
sharedAudioContext: AudioContext;
@@@ -123,8 -108,12 +114,14 @@@
this.fps = fps;
this.debugOverlay = debugOverlay;
this.bufferState = bufferState;
+ this.isPremounting = isPremounting;
+ this.isPostmounting = isPostmounting;
+ this.nonceManager = makeNonceManager();
+
+ this.input = new Input({
+ source: new UrlSource(this.src),
+ formats: ALL_FORMATS,
+ });
if (canvas) {
const context = canvas.getContext('2d', {
diff --cc packages/media/src/video/video-for-preview.tsx
index 7bbdfe5721,8bdf60525b..5b1f8f3bfb
--- a/packages/media/src/video/video-for-preview.tsx
+++ b/packages/media/src/video/video-for-preview.tsx
@@@ -174,8 -179,7 +181,9 @@@ const VideoForPreviewAssertedShowing: R
audioStreamIndex,
debugOverlay,
bufferState: buffer,
+ isPremounting,
+ isPostmounting,
+ globalPlaybackRate,
});
mediaPlayerRef.current = player;
@@@ -294,8 -298,7 +302,9 @@@
audioStreamIndex,
debugOverlay,
buffer,
+ isPremounting,
+ isPostmounting,
+ globalPlaybackRate,
]);
const classNameValue = useMemo(() => {