-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo.html
More file actions
97 lines (86 loc) · 4.21 KB
/
video.html
File metadata and controls
97 lines (86 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title id="pagetitle">Video Player</title>
<link rel="stylesheet" href="/style.css" />
</head>
<body>
<div class="top-bar">Localhost Streaming Site</div>
<div class="sidebar">
<button class="back-button" onclick="window.location.href = '/'">Back</button>
<div id="episode-list"></div>
</div>
<div class="right-sidebar">
<h1 class="show-name-header" id="show-name-header"></h1>
<img id="cover-image" class="cover-image" alt="Cover Image" />
</div>
<div class="main-content">
<div class="video-container">
<video class="video-player" controls autoplay muted></video>
</div>
<div class="control-panel">
<button onclick="toggleMode()">Toggle Light/Dark Mode</button>
<div class="auto-next-container">
<input type="checkbox" id="autoNext" />
<label for="autoNext">Auto Next</label>
</div>
</div>
<p class="footer">Made with NodeJS</p>
</div>
<script>
function toggleMode() {
const isDarkMode = document.body.classList.contains('dark-mode');
document.body.classList.toggle('dark-mode', !isDarkMode);
document.body.classList.toggle('light-mode', isDarkMode);
}
const urlParams = new URLSearchParams(window.location.search);
const folder = urlParams.get('folder');
const contentName = decodeURIComponent(folder);
document.getElementById('show-name-header').textContent = contentName;
document.getElementById('pagetitle').textContent = `Video Player - ${contentName}`;
async function loadEpisodes() {
const response = await fetch(`/content/${folder}/episodes`);
const episodes = await response.json();
const episodeList = document.getElementById('episode-list');
const videoPlayer = document.querySelector('.video-player');
if (episodes.length > 0) {
videoPlayer.src = `/content/${folder}/${episodes[0]}`;
}
episodes.forEach((episode) => {
const episodeNumberMatch = episode.match(/(\d+)/);
const episodeNumber = episodeNumberMatch ? `Episode ${episodeNumberMatch[1]}` : episode;
const episodeLink = document.createElement('div');
episodeLink.textContent = episodeNumber;
episodeLink.style.color = 'white';
episodeLink.style.cursor = 'pointer';
episodeLink.style.marginBottom = '10px';
episodeLink.onclick = () => {
videoPlayer.src = `/content/${folder}/${episode}`;
};
episodeList.appendChild(episodeLink);
});
videoPlayer.onended = () => {
const autoNextCheckbox = document.getElementById('autoNext');
if (autoNextCheckbox.checked) {
const currentIndex = episodes.indexOf(videoPlayer.src.split('/').pop());
if (currentIndex >= 0 && currentIndex < episodes.length - 1) {
videoPlayer.src = `/content/${folder}/${episodes[currentIndex + 1]}`;
}
}
};
}
async function loadCoverImage() {
const response = await fetch(`/content/`);
const metadata = await response.json();
const folderMetadata = metadata.find(item => item.title === contentName);
const coverImage = document.getElementById('cover-image');
coverImage.src = folderMetadata.cover || 'default-cover.png';
}
loadEpisodes();
loadCoverImage();
</script>
</body>
</html>