Skip to content

Commit

Permalink
fix scrubbing preview and progress bar not always agreeing
Browse files Browse the repository at this point in the history
  • Loading branch information
breunigs committed Dec 22, 2023
1 parent 0576d3e commit 3e0d01e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions assets/js/video_player.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,23 +528,19 @@ function seekFromProgress(e) {
seekToTime(time);
};

let progressPreviewTime = 0
let progressPreviewPos = 0.0
let progressPreviewRAF = null
function previewProgress(e) {
const [time, pos] = timeFromProgressPosition(e)
progressPreviewPos = pos
progressPreviewTime = time
if (progressPreviewRAF !== null) return

progressPreviewRAF = requestAnimationFrame(() => {
const time = progressPreviewTime;
const [time, pos] = timeFromProgressPosition(e)
const { recDate, street } = metadataForTime(time)
let text = '';
if (street !== "") text += `${street}<br>`
if (recDate !== "") text += `${recDate}<br>`
if (!isNaN(time)) text += `<b>${ms2text(time)}</b>`
progressPreviewEl.innerHTML = text
progressPreviewEl.style.left = (progressPreviewPos * 100) + '%'
progressPreviewEl.style.left = (pos * 100) + '%'
progressPreviewRAF = null
})
}
Expand Down

0 comments on commit 3e0d01e

Please sign in to comment.