-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking.html
109 lines (105 loc) · 3.12 KB
/
working.html
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
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Streaming</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f4f4f4;
}
h1 {
margin: 20px 0;
}
#container {
display: flex;
align-items: flex-start;
justify-content: center;
width: 80%;
max-width: 1000px;
}
#video-list {
margin-right: 20px;
background: white;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
#video-player {
width: 640px;
height: 360px;
background: black;
}
select {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 10px;
}
button {
width: 100%;
padding: 10px;
background: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
text-align: center;
}
button:hover {
background: #0056b3;
}
</style>
</head>
<body>
<h1>Video Streaming</h1>
<div id="container">
<div id="video-list">
<select id="video-select">
<option value="">Select a video</option>
</select>
<button id="play-button">Play Video</button>
</div>
<video id="video-player" controls>
Your browser does not support the video tag.
</video>
</div>
<script>
async function loadVideos() {
const response = await fetch('/videos');
const videoList = await response.text();
const select = document.getElementById('video-select');
// Populate the dropdown with video options
videoList.split('<br>').forEach(item => {
if (item.trim()) {
const videoName = item.match(/>(.*)</)[1];
const option = document.createElement('option');
option.value = item.match(/href="([^"]*)"/)[1];
option.textContent = videoName;
select.appendChild(option);
}
});
}
document.getElementById('play-button').addEventListener('click', () => {
const select = document.getElementById('video-select');
const videoSrc = select.value;
if (videoSrc) {
document.getElementById('video-player').src = videoSrc;
} else {
alert('Please select a video');
}
});
loadVideos();
</script>
</body>
</html>