-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtv.html
More file actions
416 lines (392 loc) · 15 KB
/
Copy pathtv.html
File metadata and controls
416 lines (392 loc) · 15 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
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>2Khemirix TV - Live Channels</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="css/style.css">
<style>
.live-badge {
display: inline-flex;
align-items: center;
gap: 5px;
font-size: 0.6rem;
font-weight: 700;
letter-spacing: 0.1em;
background: rgba(229, 9, 20, 0.15);
border: 1px solid rgba(229, 9, 20, 0.4);
color: #e50914;
padding: 3px 8px;
border-radius: 3px;
}
.live-dot {
width: 6px; height: 6px; border-radius: 50%;
background: #e50914;
animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }
.tv-hero {
padding: 90px 0 40px;
background: linear-gradient(180deg, rgba(229,9,20,0.08) 0%, transparent 100%);
border-bottom: 1px solid rgba(255,255,255,0.07);
}
.category-filters {
display: flex;
gap: 8px;
flex-wrap: wrap;
padding: 20px 0;
}
.cat-btn {
font-size: 0.78rem;
font-weight: 600;
padding: 6px 16px;
border-radius: 20px;
border: 1px solid rgba(255,255,255,0.15);
background: transparent;
color: rgba(255,255,255,0.5);
cursor: pointer;
transition: all 0.2s;
}
.cat-btn:hover { border-color: rgba(255,255,255,0.4); color: #fff; }
.cat-btn.active { background: #e50914; border-color: #e50914; color: #fff; }
.channel-card {
background: #1a1a1a;
border-radius: 8px;
overflow: hidden;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
border: 1px solid rgba(255,255,255,0.06);
position: relative;
}
.channel-card:hover {
transform: scale(1.04);
box-shadow: 0 8px 30px rgba(0,0,0,0.6);
border-color: rgba(229,9,20,0.4);
}
.channel-card:hover .card-play-overlay { opacity: 1; }
.channel-poster {
aspect-ratio: 16/9;
background: #111;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
position: relative;
}
.channel-poster img {
width: 60%;
height: 60%;
object-fit: contain;
transition: transform 0.3s;
}
.channel-card:hover .channel-poster img { transform: scale(1.08); }
.card-play-overlay {
position: absolute; inset: 0;
background: rgba(0,0,0,0.55);
display: flex; align-items: center; justify-content: center;
opacity: 0; transition: opacity 0.2s;
}
.card-play-overlay i { font-size: 2.5rem; color: #fff; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.7)); }
.card-live-tag {
position: absolute; top: 8px; left: 8px;
font-size: 0.55rem; font-weight: 700; letter-spacing: 0.1em;
background: #e50914; color: #fff; padding: 2px 6px; border-radius: 3px;
}
.channel-info { padding: 10px 12px; }
.channel-name {
font-size: 0.85rem; font-weight: 600; color: #fff;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px;
}
.channel-cat { font-size: 0.68rem; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.08em; }
.tv-player-modal .modal-content {
background: #0a0a0a;
border: 1px solid rgba(255,255,255,0.08);
border-radius: 12px;
overflow: hidden;
}
.tv-player-modal .modal-header {
background: #111;
border-bottom: 1px solid rgba(255,255,255,0.08);
padding: 12px 16px;
}
.modal-channel-logo {
width: 32px; height: 32px;
background: #1a1a1a; border-radius: 6px;
display: flex; align-items: center; justify-content: center;
overflow: hidden; flex-shrink: 0;
}
.modal-channel-logo img { width: 26px; height: 26px; object-fit: contain; }
.modal-channel-name { font-size: 0.95rem; font-weight: 700; color: #fff; }
.player-status {
font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em;
padding: 3px 8px; border-radius: 3px;
}
.player-status.loading { background: rgba(255,193,7,0.15); color: #ffc107; }
.player-status.playing { background: rgba(25,135,84,0.15); color: #198754; }
.player-status.error { background: rgba(229,9,20,0.15); color: #e50914; }
.video-container { position: relative; background: #000; aspect-ratio: 16/9; }
.video-container video { width: 100%; height: 100%; display: block; }
.video-loader {
position: absolute; inset: 0;
background: rgba(0,0,0,0.88);
display: flex; flex-direction: column;
align-items: center; justify-content: center; gap: 12px;
transition: opacity 0.3s;
}
.video-loader.hidden { opacity: 0; pointer-events: none; }
.spinner-tv {
width: 36px; height: 36px;
border: 3px solid rgba(255,255,255,0.1);
border-top-color: #e50914;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: 0.75rem; color: rgba(255,255,255,0.4); }
.no-channels { color: rgba(255,255,255,0.3); text-align: center; padding: 60px 0; font-size: 0.9rem; }
</style>
</head>
<body>
<nav class="navbar navbar-dark bg-dark fixed-top">
<div class="container-fluid d-flex justify-content-between align-items-center">
<span class="navbar-brand mb-0 h1">
<i class="fas fa-film"></i>
<img src="./css/img/Khemirix.png" alt="" width="50%">
</span>
<div class="d-flex gap-3 align-items-center">
<div class="nav-tabs-custom">
<a href="index.html" class="tab-btn">Movies</a>
<a href="index.html" class="tab-btn">TV Shows</a>
<a href="tv.html" class="tab-btn active">Live TV</a>
</div>
<input type="text" id="searchInput" class="form-control form-control-sm search-input" placeholder="Search channels..." aria-label="Search">
</div>
</div>
</nav>
<div class="tv-hero">
<div class="container-fluid px-4">
<div class="d-flex align-items-center gap-3 mb-2">
<div class="live-badge"><div class="live-dot"></div>LIVE NOW</div>
</div>
<h1 style="font-size:2.2rem;font-weight:800;color:#fff;margin-bottom:8px;">Live <span style="color:#e50914;">TV</span> Channels</h1>
<p style="color:rgba(255,255,255,0.45);font-size:0.95rem;max-width:480px;">Stream live channels directly in your browser. Click any channel to start watching.</p>
<div class="category-filters" id="categoryFilters"></div>
</div>
</div>
<div class="container-fluid px-4 py-4">
<div class="row g-3" id="channelsGrid"></div>
</div>
<!-- Player Modal -->
<div class="modal fade tv-player-modal" id="tvPlayerModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<div class="d-flex align-items-center gap-2 flex-grow-1">
<div class="modal-channel-logo">
<img id="modalLogo" src="" alt="">
</div>
<span class="modal-channel-name" id="modalName">Channel</span>
<span class="player-status loading ms-2" id="playerStatus">LOADING</span>
</div>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<div class="video-container">
<video id="tvVideo" controls playsinline></video>
<div class="video-loader" id="videoLoader">
<div class="spinner-tv"></div>
<div class="loader-text" id="loaderText">Connecting to stream...</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.7/dist/hls.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mpegts.js@1.7.3/dist/mpegts.js"></script>
<script>
var PROXY = 'https://t-ahg3.onrender.com';
var channels = [];
var activeCategory = 'All';
var currentPlayer = null;
var playerModal = null;
window.addEventListener('DOMContentLoaded', function() {
playerModal = new bootstrap.Modal(document.getElementById('tvPlayerModal'));
document.getElementById('tvPlayerModal').addEventListener('hidden.bs.modal', function() {
stopStream();
});
fetch('channels.json')
.then(function(r) { return r.json(); })
.then(function(data) {
channels = data;
buildCategories();
renderChannels(channels);
})
.catch(function() {
document.getElementById('channelsGrid').innerHTML =
'<div class="no-channels col-12">Could not load channels.json</div>';
});
document.getElementById('searchInput').addEventListener('input', function() {
var q = this.value.toLowerCase().trim();
var base = activeCategory === 'All' ? channels : channels.filter(function(c) { return c.category === activeCategory; });
var filtered = q ? base.filter(function(c) { return c.name.toLowerCase().indexOf(q) !== -1; }) : base;
renderChannels(filtered);
});
});
function buildCategories() {
var cats = ['All'];
channels.forEach(function(c) { if (cats.indexOf(c.category) === -1) cats.push(c.category); });
var html = '';
cats.forEach(function(cat) {
html += '<button class="cat-btn' + (cat === 'All' ? ' active' : '') + '" onclick="filterBy(\'' + cat + '\', this)">' + cat + '</button>';
});
document.getElementById('categoryFilters').innerHTML = html;
}
function filterBy(cat, btn) {
activeCategory = cat;
document.querySelectorAll('.cat-btn').forEach(function(b) { b.classList.remove('active'); });
btn.classList.add('active');
var filtered = cat === 'All' ? channels : channels.filter(function(c) { return c.category === cat; });
renderChannels(filtered);
}
function renderChannels(list) {
var grid = document.getElementById('channelsGrid');
if (!list.length) {
grid.innerHTML = '<div class="no-channels col-12">No channels found.</div>';
return;
}
grid.innerHTML = list.map(function(ch) {
var data = encodeURIComponent(JSON.stringify(ch));
return '<div class="col-6 col-sm-4 col-md-3 col-lg-2">' +
'<div class="channel-card" onclick="openChannel(decodeURIComponent(\'' + data + '\'))">' +
'<div class="channel-poster">' +
'<img src="' + ch.logo + '" alt="' + ch.name + '" onerror="this.src=\'https://placehold.co/320x180/111/444?text=TV\'">' +
'<div class="card-play-overlay"><i class="fas fa-play"></i></div>' +
'<span class="card-live-tag">LIVE</span>' +
'</div>' +
'<div class="channel-info">' +
'<div class="channel-name">' + ch.name + '</div>' +
'<div class="channel-cat">' + ch.category + '</div>' +
'</div>' +
'</div>' +
'</div>';
}).join('');
}
function openChannel(dataStr) {
var ch = JSON.parse(dataStr);
document.getElementById('modalLogo').src = ch.logo;
document.getElementById('modalName').textContent = ch.name;
setStatus('loading');
showLoader(true, 'Connecting to ' + ch.name + '...');
playerModal.show();
playStream(ch.stream);
}
function setStatus(state) {
var el = document.getElementById('playerStatus');
el.className = 'player-status ' + state + ' ms-2';
var labels = { loading: 'LOADING', playing: 'LIVE', error: 'ERROR' };
el.textContent = labels[state] || state.toUpperCase();
}
function showLoader(show, msg) {
var el = document.getElementById('videoLoader');
if (!show) { el.classList.add('hidden'); return; }
el.classList.remove('hidden');
if (msg) document.getElementById('loaderText').textContent = msg;
}
function stopStream() {
if (currentPlayer) {
try { currentPlayer.destroy(); } catch(e) {}
currentPlayer = null;
}
var video = document.getElementById('tvVideo');
video.pause();
video.src = '';
}
function playStream(streamUrl) {
var proxyUrl = PROXY + '/fetch?url=' + encodeURIComponent(streamUrl);
var video = document.getElementById('tvVideo');
stopStream();
video.onplaying = function() { setStatus('playing'); showLoader(false); };
video.onwaiting = function() { showLoader(true, 'Buffering...'); };
video.onerror = function() { setStatus('error'); showLoader(true, 'Stream error. Try another channel.'); };
var isTS = streamUrl.indexOf('.ts') !== -1;
var isM3U8 = streamUrl.indexOf('.m3u8') !== -1;
if (isTS && mpegts.isSupported()) {
// Raw MPEG-TS stream — use mpegts.js with pre-buffer
currentPlayer = mpegts.createPlayer({
type: 'mpegts',
isLive: true,
url: proxyUrl
}, {
enableWorker: true,
lazyLoad: false,
autoCleanupSourceBuffer: true,
liveBufferLatencyChasing: false,
liveSync: false,
liveSyncMaxLatency: 60,
liveSyncTargetLatency: 30,
stashInitialSize: 1024 * 1024
});
currentPlayer.attachMediaElement(video);
currentPlayer.load();
var prebuffered = false;
video.addEventListener('progress', function checkBuffer() {
if (prebuffered) return;
if (video.buffered.length > 0) {
var bufferedEnd = video.buffered.end(video.buffered.length - 1);
var bufferedAmount = bufferedEnd - video.currentTime;
showLoader(true, 'Buffering... ' + Math.min(30, Math.floor(bufferedAmount)) + 's / 30s');
if (bufferedAmount >= 30) {
prebuffered = true;
video.play().catch(function() {});
video.removeEventListener('progress', checkBuffer);
}
}
});
} else if (isM3U8 && Hls.isSupported()) {
// HLS stream — use hls.js
currentPlayer = new Hls({ enableWorker: true, lowLatencyMode: true });
currentPlayer.loadSource(proxyUrl);
currentPlayer.attachMedia(video);
currentPlayer.on(Hls.Events.MANIFEST_PARSED, function() {
video.play().catch(function() {});
});
currentPlayer.on(Hls.Events.ERROR, function(e, data) {
if (data.fatal) {
setStatus('error');
showLoader(true, 'Stream error.');
}
});
} else {
// Unknown or no extension — try mpegts.js first, fallback to hls.js
if (mpegts.isSupported()) {
currentPlayer = mpegts.createPlayer({
type: 'mpegts',
isLive: true,
url: proxyUrl
}, {
enableWorker: true,
liveBufferLatencyChasing: true,
liveSync: true
});
currentPlayer.attachMediaElement(video);
currentPlayer.load();
currentPlayer.play().catch(function() {});
} else if (Hls.isSupported()) {
currentPlayer = new Hls({ enableWorker: true, lowLatencyMode: true });
currentPlayer.loadSource(proxyUrl);
currentPlayer.attachMedia(video);
currentPlayer.on(Hls.Events.MANIFEST_PARSED, function() {
video.play().catch(function() {});
});
} else {
video.src = proxyUrl;
video.play().catch(function() {});
}
}
}
</script>
</body>
</html>