Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/media player: fix seek bar not working sometimes
Adorian Doran2c3b0905d417
diff --git a/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx b/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsxindex cb54261f2c..8f1a940ab2 100644--- a/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx+++ b/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx@@ -30,6 +30,13 @@ export function SeekBar({ mediaRef }: { mediaRef: RefObject<HTMLVideoElement | Hconst onTimeUpdate = () => setCurrentTime(media.currentTime);const onDurationChange = () => setDuration(media.duration);+ // Seed from the element now: if its metadata already loaded before this (passive) effect ran — common+ // for cached/fast media or a reused element — the initial durationchange/timeupdate already fired and+ // the listeners below would miss them, leaving duration 0. That pins max=0, so the slider sticks at the+ // start and any seek snaps playback back to 0.+ onTimeUpdate();+ onDurationChange();+media.addEventListener("timeupdate", onTimeUpdate);media.addEventListener("durationchange", onDurationChange);return () => {