From dd8ea22d450d9de722e72fe9d11d85cba7ab4de6 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 14 Dec 2024 20:15:47 +0000 Subject: [PATCH] preview new timecode --- static/mobile/js/VideoPlayer.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/static/mobile/js/VideoPlayer.js b/static/mobile/js/VideoPlayer.js index c1f34850..95720e2d 100644 --- a/static/mobile/js/VideoPlayer.js +++ b/static/mobile/js/VideoPlayer.js @@ -360,14 +360,24 @@ window.VideoPlayer = function(options) { progressbar.setAttribute('aria-valuenow', value); } - that.querySelector('.controls .position input').addEventListener('input', function(event){ + that.querySelector('.controls .position input').addEventListener('input', event => { event.preventDefault() event.stopPropagation() - setProgressPosition(this.value) - var position = this.value/100 * self.options.duration + setProgressPosition(event.target.value) + var position = event.target.value/100 * self.options.duration + displayTime(position) that.currentTime(position) hideControlsLater() }) + function displayTime(currentTime) { + duration = formatDuration(self.options.duration) + currentTime = formatDuration(currentTime) + while (duration && duration.startsWith('00:')) { + duration = duration.slice(3) + } + currentTime = currentTime.slice(currentTime.length - duration.length) + time.innerText = `${currentTime} / ${duration}` + } that.addEventListener("timeupdate", event => { var currentTime = that.currentTime(), @@ -376,14 +386,7 @@ window.VideoPlayer = function(options) { currentTime -= self.options.position } setProgressPosition(100 * currentTime / duration) - duration = formatDuration(duration) - currentTime = formatDuration(currentTime) - while (duration && duration.startsWith('00:')) { - duration = duration.slice(3) - } - currentTime = currentTime.slice(currentTime.length - duration.length) - time.innerText = `${currentTime} / ${duration}` - + displayTime(currentTime) }) that.addEventListener("play", event => {