src = url;

// 恢复播放时间
const savedTime = localStorage.getItem(`episode_${index}_time`);
if (savedTime) {
videoPlayer.currentTime = parseFloat(savedTime);
}

videoPlayer.play();
currentEpisodeIndex = index;
updateCurrentEpisodeDisplay();
highlightCurrentEpisode();

// 监听视频播放时间更新
videoPlayer.ontimeupdate = function() {
localStorage.setItem(`episode_${index}_time`, videoPlayer.currentTime);
};

// 保存最后播放的剧集索引
localStorage.setItem('lastEpisodeIndex', index);
}

// 播放下一个剧集
function playNext() {
if (currentEpisodeIndex < episodes.length - 1) {
currentEpisodeIndex++;
playVideo(currentEpisodeIndex, episodes[currentEpisodeIndex].url);
}
}

// 更新当前剧集显示
function updateCurrentEpisodeDisplay() {
document.getElementById('currentEpisodeName').textContent = episodes[currentEpisodeIndex].name;
}

// 高亮当前剧集
function highlightCurrentEpisode() {
const episodeItems = document.querySelectorAll('.episode-list ul li');
episodeItems.forEach((item, index) => {
if (index === currentEpisodeIndex) {
item.classList.add('active');
} else {
item.classList.remove('active');
}
});
}

// 页面加载时自动播放上次的剧集
window.onload = function() {
initEpisodeList(); // 初始化剧集列表
const lastEpisodeIndex = parseInt(localStorage.getItem('lastEpisodeIndex')) || 0;
playVideo(lastEpisodeIndex, episodes[lastEpisodeIndex].url);
};
</script>
</body>

Prev | Next
Pg.: 1 2 3


Back to home | File page

Subscribe | Register | Login | N