preview new timecode

This commit is contained in:
j 2024-12-14 20:15:47 +00:00
parent 85eba0bf09
commit dd8ea22d45

View file

@ -360,14 +360,24 @@ window.VideoPlayer = function(options) {
progressbar.setAttribute('aria-valuenow', value); 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.preventDefault()
event.stopPropagation() event.stopPropagation()
setProgressPosition(this.value) setProgressPosition(event.target.value)
var position = this.value/100 * self.options.duration var position = event.target.value/100 * self.options.duration
displayTime(position)
that.currentTime(position) that.currentTime(position)
hideControlsLater() 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 => { that.addEventListener("timeupdate", event => {
var currentTime = that.currentTime(), var currentTime = that.currentTime(),
@ -376,14 +386,7 @@ window.VideoPlayer = function(options) {
currentTime -= self.options.position currentTime -= self.options.position
} }
setProgressPosition(100 * currentTime / duration) setProgressPosition(100 * currentTime / duration)
duration = formatDuration(duration) displayTime(currentTime)
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("play", event => { that.addEventListener("play", event => {