-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
341 lines (292 loc) · 12.3 KB
/
index.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HLS & DASH</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(to right, #7D3F98, #00AEEF, #1D1E6E);
text-align: center;
padding: 20px;
}
h1 {
font-family: 'Roboto', sans-serif;
font-weight: 700;
font-size: 1.5em;
color: #FFFFFF;
margin-bottom: 20px;
text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
background: #333333;
padding: 10px 20px;
border-radius: 2px;
}
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.stream-box {
background-color: #fff;
border: 2px solid #000;
padding: 15px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
}
video {
width: 90%;
height: auto;
margin-bottom: 10px;
}
.stream-url {
width: 65%;
padding: 8px;
margin-bottom: 10px;
font-size: 14px;
}
.media-section {
display: flex;
align-items: center;
justify-content: center;
}
.audio-visualizer {
display: flex;
flex-direction: column;
margin-left: 10px;
border: 2px solid #000;
width: 20px;
height: 130px;
justify-content: space-between;
}
.bar {
width: 100%;
background-color: #28a745;
}
button {
padding: 5px 10px;
background-color: #007bff;
color: white;
border: 2px solid #000;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
select {
padding: 5px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>HLS & DASH</h1>
<div class="container">
<!-- Stream Box 1 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType1" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url1" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video1" controls></video>
<div class="audio-visualizer" id="visualizer1"></div>
</div>
<button onclick="playStream('video1', 'visualizer1', 'url1', 'playerType1')">Play</button>
</div>
<!-- Stream Box 2 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType2" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url2" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video2" controls></video>
<div class="audio-visualizer" id="visualizer2"></div>
</div>
<button onclick="playStream('video2', 'visualizer2', 'url2', 'playerType2')">Play</button>
</div>
<!-- Stream Box 3 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType3" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url3" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video3" controls></video>
<div class="audio-visualizer" id="visualizer3"></div>
</div>
<button onclick="playStream('video3', 'visualizer3', 'url3', 'playerType3')">Play</button>
</div>
<!-- Stream Box 4 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType4" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url4" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video4" controls></video>
<div class="audio-visualizer" id="visualizer4"></div>
</div>
<button onclick="playStream('video4', 'visualizer4', 'url4', 'playerType4')">Play</button>
</div>
<!-- Stream Box 5 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType5" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url5" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video5" controls></video>
<div class="audio-visualizer" id="visualizer5"></div>
</div>
<button onclick="playStream('video5', 'visualizer5', 'url1', 'playerType5')">Play</button>
</div>
<!-- Stream Box 6 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType6" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url1" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video6" controls></video>
<div class="audio-visualizer" id="visualizer6"></div>
</div>
<button onclick="playStream('video6', 'visualizer6', 'url6', 'playerType6')">Play</button>
</div>
<!-- Stream Box 7 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType7" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url7" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video7" controls></video>
<div class="audio-visualizer" id="visualizer7"></div>
</div>
<button onclick="playStream('video7', 'visualizer7', 'url7', 'playerType7')">Play</button>
</div>
<!-- Stream Box 8 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType8" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url8" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video8" controls></video>
<div class="audio-visualizer" id="visualizer8"></div>
</div>
<button onclick="playStream('video8', 'visualizer8', 'url8', 'playerType8')">Play</button>
</div>
<!-- Stream Box 9 -->
<div class="stream-box">
<!-- Dropdown to select HLS or DASH -->
<select id="playerType9" class="url-input">
<option value="hls">HLS</option>
<option value="dash">DASH</option>
</select>
<input type="text" class="url-input" id="url9" placeholder="Enter Stream URL">
<div class="media-section">
<video id="video9" controls></video>
<div class="audio-visualizer" id="visualizer9"></div>
</div>
<button onclick="playStream('video9', 'visualizer9', 'url9', 'playerType9')">Play</button>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script>
<script>
function createAudioVisualizer(audioContext, analyser, visualizerId) {
const visualizer = document.getElementById(visualizerId);
visualizer.innerHTML = ''; // Clear any existing bars
const bars = 16; // Number of bars in visualizer
// Create bars dynamically
for (let i = 0; i < bars; i++) {
const bar = document.createElement('div');
bar.classList.add('bar');
bar.style.height = `${100 / bars}%`;
visualizer.appendChild(bar);
}
const barElements = visualizer.getElementsByClassName('bar');
const frequencyData = new Uint8Array(analyser.frequencyBinCount);
function renderFrame() {
analyser.getByteFrequencyData(frequencyData);
for (let i = 0; i < bars; i++) {
const barHeight = (frequencyData[i] / 255) * 100;
barElements[i].style.backgroundColor = `hsl(${barHeight * 1.2}, 100%, 50%)`; // Adjust height based on frequency data
}
requestAnimationFrame(renderFrame);
}
renderFrame();
}
function playStream(videoId, visualizerId, urlInputId, playerTypeId) {
const video = document.getElementById(videoId);
const streamUrl = document.getElementById(urlInputId).value;
const playerType = document.getElementById(playerTypeId).value;
if (streamUrl.trim() === "") {
alert("Please enter a valid stream URL.");
return;
}
if (playerType === 'hls') {
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(streamUrl);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () {
video.play();
// Set up Web Audio API for visualizer
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const source = audioContext.createMediaElementSource(video);
const analyser = audioContext.createAnalyser();
analyser.fftSize = 32; // Lower size for fewer bars
source.connect(analyser);
analyser.connect(audioContext.destination);
// Create visualizer
createAudioVisualizer(audioContext, analyser, visualizerId);
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = hlsUrl;
video.play();
// Set up Web Audio API for visualizer
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const source = audioContext.createMediaElementSource(video);
const analyser = audioContext.createAnalyser();
analyser.fftSize = 32;
source.connect(analyser);
analyser.connect(audioContext.destination);
// Create visualizer
createAudioVisualizer(audioContext, analyser, visualizerId);
}
} else if (playerType === 'dash') {
const player = dashjs.MediaPlayer().create();
player.initialize(video, streamUrl, true);
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const source = audioContext.createMediaElementSource(video);
const analyser = audioContext.createAnalyser();
analyser.fftSize = 32;
source.connect(analyser);
analyser.connect(audioContext.destination);
createAudioVisualizer(audioContext, analyser, visualizerId);
}
}
</script>
</body>
</html>