fix seek for items

This commit is contained in:
j 2025-01-30 08:53:25 +05:30
commit 5591739531
4 changed files with 24 additions and 13 deletions

View file

@ -75,7 +75,8 @@ function renderItem(data) {
var video = window.video = VideoPlayer({
items: data.videos,
poster: data.poster,
position: data["in"] || 0,
"in": data["in"] || 0,
position: 0,
duration: data.duration,
aspectratio: data.aspectratio
})
@ -85,16 +86,10 @@ function renderItem(data) {
video.addEventListener("loadedmetadata", event => {
//
})
video.addEventListener("timeupdate", event => {
var currentTime = video.currentTime()
if (currentTime >= data['out']) {
if (!video.paused) {
video.pause()
}
video.currentTime(data['in'])
}
function updateAnnotations(currentTime) {
div.querySelectorAll('.annotation').forEach(annot => {
var now = currentTime
var now = currentTime + (data["in"] || 0)
var start = parseFloat(annot.dataset.in)
var end = parseFloat(annot.dataset.out)
if (now >= start && now <= end) {
@ -107,8 +102,18 @@ function renderItem(data) {
}
}
})
}
video.addEventListener("timeupdate", event => {
var currentTime = video.currentTime()
if ((currentTime + (data["in"] || 0)) >= data['out']) {
if (!video.paused) {
video.pause()
}
video.currentTime(0)
}
updateAnnotations(currentTime)
})
updateAnnotations(data["position"] || 0)
if (item.next || item.previous) {
var nav = document.createElement('nav')
nav.classList.add('items')