fix: broken screen clip playback progress

It wasn't progressing, likely because the metadata for a screen
recording was not read by the video html element. So we fallback to our
own duration metadata.

Closes #135
This commit is contained in:
talksik
2026-04-09 11:00:55 -07:00
parent 47b0d320f6
commit ce368c9e6e
@@ -94,7 +94,12 @@ export const MediaParticleView = forwardRef<MediaParticleHandle, MediaParticleVi
const handleTimeUpdate = (e: React.SyntheticEvent<HTMLAudioElement | HTMLVideoElement>) => {
const { currentTime: time, duration } = e.currentTarget;
setCurrentTime(time);
if (duration > 0) onProgress?.(time / duration);
// WebM files from MediaRecorder (screen recordings) often report Infinity/NaN
// duration until fully buffered — fall back to the known duration from metadata.
const effectiveDuration = Number.isFinite(duration) && duration > 0
? duration
: particle.properties.duration_ms / 1000;
if (effectiveDuration > 0) onProgress?.(time / effectiveDuration);
};
const attachmentOverlay = attachments.length > 0 && (