/** * ========================================================================== * VIDEO PLAYER & PLAYLIST MANAGER - OPTIMIZED FOR DESKTOP & MOBILE * ========================================================================== */ window.VideoPlayer = { activeVideoId: null, isMobile: function() { return window.innerWidth <= 768; }, init: function() { const countBadge = document.getElementById('videoCountBadge'); if (countBadge) { countBadge.textContent = `${TVSI_DATA.videoList.length} Clips`; } this.renderPlaylist(TVSI_DATA.videoList); // Mặc định chọn video đầu tiên nếu chưa chọn if (!this.activeVideoId && TVSI_DATA.videoList.length > 0) { this.selectVideo(TVSI_DATA.videoList[0].id, false); } }, // Render danh sách video bên cột playlist renderPlaylist: function(list) { const container = document.getElementById('videoItemsList'); if (!container) return; container.innerHTML = list.map((item, index) => `
${item.title}
${item.title}
`).join(''); }, // Chọn video và phát selectVideo: function(videoId, userClicked = true) { const item = TVSI_DATA.videoList.find(v => v.id === videoId); if (!item) return; this.activeVideoId = videoId; // Cập nhật trạng thái active trong playlist document.querySelectorAll('.video-item').forEach(el => { if (el.dataset.id === videoId) { el.classList.add('active'); } else { el.classList.remove('active'); } }); // Cập nhật tiêu đề video đang phát (gọn gàng, không dài dòng) const titleEl = document.getElementById('videoPlayingTitle'); if (titleEl) titleEl.textContent = item.title; const descEl = document.getElementById('videoPlayingDesc'); if (descEl) descEl.style.display = 'none'; // Tải và phát video trên thẻ