feat: add classroom learning page with video player and robust progress tracking
This commit is contained in:
parent
18816c4fb2
commit
90a8cb6509
1 changed files with 5 additions and 5 deletions
|
|
@ -169,7 +169,7 @@ const loadLesson = async (lessonId: number) => {
|
|||
const resumeTime = Math.max(serverProgress, localProgress)
|
||||
|
||||
if (resumeTime > 0) {
|
||||
console.log(`Resuming at: ${resumeTime}s (Server: ${serverProgress}, Local: ${localProgress})`)
|
||||
|
||||
initialSeekTime.value = resumeTime
|
||||
maxWatchedTime.value = resumeTime
|
||||
currentTime.value = resumeTime
|
||||
|
|
@ -266,7 +266,7 @@ const performSaveProgress = async (force: boolean = false, keepalive: boolean =
|
|||
lastSavedTime.value = maxSec
|
||||
lastSavedTimestamp.value = now
|
||||
|
||||
console.log(`Saving Server: ${maxSec}/${durationSec} (KeepAlive: ${keepalive})`)
|
||||
|
||||
|
||||
const res = await saveVideoProgress(currentLesson.value.id, maxSec, durationSec, keepalive)
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ onBeforeUnmount(() => {
|
|||
|
||||
const handleVisibilityChange = () => {
|
||||
if (document.hidden) {
|
||||
console.log('Tab hidden, saving progress...')
|
||||
|
||||
if (currentLesson.value?.id) {
|
||||
saveLocalProgress(currentLesson.value.id, maxWatchedTime.value)
|
||||
}
|
||||
|
|
@ -407,7 +407,7 @@ watch(isPlaying, (playing) => {
|
|||
// เมื่อวิดีโอจบ ให้บันทึกว่าเรียนจบ (Complete)
|
||||
const onVideoEnded = async () => {
|
||||
isPlaying.value = false
|
||||
console.log('Video Ended')
|
||||
|
||||
// Force save progress at 100%
|
||||
await performSaveProgress(true, false)
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ const onVideoEnded = async () => {
|
|||
} else if (res.data.next_lesson_id) {
|
||||
// Auto-advance removed as per request.
|
||||
// User will manually select the next lesson from the sidebar.
|
||||
console.log('Video finished. Next lesson available:', res.data.next_lesson_id)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue