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 => {