feat: implement e-learning classroom page with video player, lesson navigation, progress tracking, and announcements.

This commit is contained in:
supalerk-ar66 2026-02-05 09:56:10 +07:00
parent be5b9756be
commit 42b7399868
5 changed files with 74 additions and 23 deletions

View file

@ -124,18 +124,33 @@ const stopYTTracking = () => {
if (ytInterval) clearInterval(ytInterval);
};
const destroyYoutubePlayer = () => {
stopYTTracking();
if (ytPlayer) {
try {
if (ytPlayer.destroy) ytPlayer.destroy();
} catch (e) {
console.warn('Error destroying YT player:', e);
}
ytPlayer = null;
}
};
onMounted(() => {
if (isYoutube.value) initYoutubeAPI();
});
onUnmounted(() => {
stopYTTracking();
destroyYoutubePlayer();
});
// Watch for src change to re-init
watch(() => props.src, () => {
if (isYoutube.value) {
setTimeout(initYoutubeAPI, 500);
watch(() => props.src, (newSrc, oldSrc) => {
if (newSrc !== oldSrc) {
destroyYoutubePlayer();
if (isYoutube.value) {
setTimeout(initYoutubeAPI, 300);
}
}
});