Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript

fix: address code review comments in Preview.tsx

copilot-swe-agent[bot]90963d09b337
diff --git a/apps/web/src/components/editor/Preview.tsx b/apps/web/src/components/editor/Preview.tsx
index 62da54dd..30dfe336 100644
--- a/apps/web/src/components/editor/Preview.tsx
+++ b/apps/web/src/components/editor/Preview.tsx
@@ -210,7 +210,7 @@ export const Preview: React.FC = () => {
/** Returns the cache key for an audio buffer, accounting for multi-track audio files. */
const getAudioBufferCacheKey = (mediaId: string, audioTrackIndex?: number): string =>
- audioTrackIndex && audioTrackIndex > 0
+ audioTrackIndex !== undefined && audioTrackIndex > 0
? `${mediaId}:${audioTrackIndex}`
: mediaId;
@@ -268,9 +268,7 @@ export const Preview: React.FC = () => {
const sampleRate = chunks[0].buffer.sampleRate;
const numChannels = chunks[0].buffer.numberOfChannels;
const totalFrames = Math.ceil(duration * sampleRate);
- const combined = (audioContext as AudioContext).createBuffer
- ? (audioContext as AudioContext).createBuffer(numChannels, totalFrames, sampleRate)
- : new OfflineAudioContext(numChannels, totalFrames, sampleRate).createBuffer(numChannels, totalFrames, sampleRate);
+ const combined = audioContext.createBuffer(numChannels, totalFrames, sampleRate);
for (const chunk of chunks) {
const offsetFrames = Math.round(chunk.timestamp * sampleRate);
for (let ch = 0; ch < numChannels; ch++) {