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:
@@ -94,7 +94,12 @@ export const MediaParticleView = forwardRef<MediaParticleHandle, MediaParticleVi
|
|||||||
const handleTimeUpdate = (e: React.SyntheticEvent<HTMLAudioElement | HTMLVideoElement>) => {
|
const handleTimeUpdate = (e: React.SyntheticEvent<HTMLAudioElement | HTMLVideoElement>) => {
|
||||||
const { currentTime: time, duration } = e.currentTarget;
|
const { currentTime: time, duration } = e.currentTarget;
|
||||||
setCurrentTime(time);
|
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 && (
|
const attachmentOverlay = attachments.length > 0 && (
|
||||||
|
|||||||
Reference in New Issue
Block a user