mirror of
https://github.com/frappe/lms.git
synced 2026-04-23 00:38:00 +03:00
fix: progress updated on video completion
This commit is contained in:
@@ -700,6 +700,31 @@ const updateVideoWatchDuration = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
attachVideoEndedListeners()
|
||||
}
|
||||
|
||||
const attachVideoEndedListeners = () => {
|
||||
const onVideoEnded = () => {
|
||||
markProgress()
|
||||
trackVideoWatchDuration()
|
||||
}
|
||||
|
||||
document.querySelectorAll('video').forEach((video) => {
|
||||
if (!video._lmsEndedAttached) {
|
||||
video.addEventListener('ended', onVideoEnded)
|
||||
video._lmsEndedAttached = true
|
||||
}
|
||||
})
|
||||
|
||||
plyrSources.value.forEach((plyrSource) => {
|
||||
if (!plyrSource._lmsEndedAttached) {
|
||||
plyrSource.on('ended', onVideoEnded)
|
||||
plyrSource.on('statechange', (event) => {
|
||||
if (event.detail?.code === 0) onVideoEnded()
|
||||
})
|
||||
plyrSource._lmsEndedAttached = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const updatePlyrVideoTime = (video) => {
|
||||
|
||||
Reference in New Issue
Block a user