-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream.html
More file actions
911 lines (786 loc) · 33.8 KB
/
Copy pathstream.html
File metadata and controls
911 lines (786 loc) · 33.8 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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Freedom Phoenix - 24/7 Stream</title>
<link rel="stylesheet" href="styles.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Orbitron:wght@400;700;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="icon" href="phoenix-new.jpg" type="image/jpeg">
<style>
/* CSS Variables for consistency */
:root {
--phoenix-red: #FF4500;
--phoenix-orange: #FF6B35;
--phoenix-yellow: #FFD700;
--flame-red: #DC143C;
--flame-orange: #FF7F00;
--deep-red: #8B0000;
--ash-gray: #2C2C2C;
--charcoal: #1A1A1A;
--ember-glow: #FF4500;
--golden-flame: #FFA500;
--flame-gradient: linear-gradient(45deg, var(--flame-red), var(--phoenix-orange), var(--phoenix-yellow));
--phoenix-gradient: linear-gradient(135deg, var(--deep-red), var(--phoenix-red), var(--phoenix-orange));
--ember-gradient: radial-gradient(circle, var(--ember-glow), var(--flame-red));
--font-primary: 'Cinzel', serif;
--font-secondary: 'Orbitron', monospace;
}
/* Stream-specific styles */
.stream-container {
max-width: 1200px;
margin: 120px auto 0;
padding: 20px;
background: rgba(26, 26, 26, 0.9);
border-radius: 20px;
border: 2px solid var(--phoenix-orange);
box-shadow: 0 0 30px rgba(255, 69, 0, 0.3);
}
.stream-header {
text-align: center;
margin-bottom: 30px;
}
.stream-title {
font-family: var(--font-primary);
font-size: 2.5rem;
color: var(--phoenix-orange);
text-shadow: 0 0 20px rgba(255, 69, 0, 0.5);
margin-bottom: 10px;
}
.stream-status {
font-size: 1.1rem;
color: var(--phoenix-yellow);
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.live-indicator {
width: 12px;
height: 12px;
background: #ff0000;
border-radius: 50%;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.3; }
100% { opacity: 1; }
}
.video-container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
margin-bottom: 20px;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 0 25px rgba(255, 69, 0, 0.4);
}
#youtube-player {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.stream-info {
background: rgba(44, 44, 44, 0.8);
padding: 20px;
border-radius: 15px;
margin-bottom: 20px;
border: 1px solid var(--phoenix-orange);
}
.current-video {
display: flex;
align-items: center;
gap: 15px;
margin-bottom: 15px;
}
.video-thumbnail {
width: 80px;
height: 45px;
border-radius: 8px;
object-fit: cover;
}
.video-details h3 {
color: var(--phoenix-yellow);
font-size: 1.2rem;
margin-bottom: 5px;
}
.video-details p {
color: #ccc;
font-size: 0.9rem;
}
.stream-controls {
display: flex;
justify-content: center;
gap: 20px;
margin-bottom: 20px;
}
.control-btn {
background: var(--phoenix-gradient);
border: none;
padding: 10px 20px;
border-radius: 25px;
color: white;
font-family: var(--font-secondary);
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(255, 69, 0, 0.3);
}
.control-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(255, 69, 0, 0.5);
}
.control-btn:active {
transform: translateY(0);
}
.volume-control {
display: flex;
align-items: center;
gap: 10px;
color: var(--phoenix-yellow);
}
.volume-slider {
width: 100px;
height: 5px;
border-radius: 5px;
background: var(--ash-gray);
outline: none;
opacity: 0.7;
transition: opacity 0.2s;
}
.volume-slider:hover {
opacity: 1;
}
.volume-slider::-webkit-slider-thumb {
appearance: none;
width: 15px;
height: 15px;
border-radius: 50%;
background: var(--phoenix-orange);
cursor: pointer;
}
.loading-message {
text-align: center;
color: var(--phoenix-yellow);
font-size: 1.1rem;
padding: 40px;
}
.error-message {
text-align: center;
color: #ff4444;
font-size: 1.1rem;
padding: 20px;
background: rgba(255, 68, 68, 0.1);
border-radius: 10px;
border: 1px solid #ff4444;
}
@media (max-width: 768px) {
.stream-container {
margin-top: 100px;
padding: 15px;
}
.stream-title {
font-size: 2rem;
}
.stream-controls {
flex-wrap: wrap;
gap: 10px;
}
.control-btn {
padding: 8px 15px;
font-size: 0.9rem;
}
}
/* Enhanced Video Information Panel */
.video-info-panel {
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 25px;
margin-top: 30px;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 107, 53, 0.3);
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
}
.now-playing-section h3,
.up-next-section h3 {
color: var(--phoenix-orange);
margin-bottom: 20px;
font-size: 1.3rem;
display: flex;
align-items: center;
gap: 10px;
border-bottom: 2px solid rgba(255, 107, 53, 0.3);
padding-bottom: 10px;
}
.video-details-enhanced {
display: grid;
grid-template-columns: auto 1fr;
gap: 15px;
align-items: start;
}
.video-thumbnail-enhanced {
position: relative;
width: 120px;
height: 90px;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.video-thumbnail-enhanced img {
width: 100%;
height: 100%;
object-fit: cover;
}
.live-indicator-enhanced {
position: absolute;
top: 8px;
right: 8px;
background: rgba(255, 0, 0, 0.9);
color: white;
padding: 4px 8px;
border-radius: 12px;
font-size: 0.7rem;
font-weight: bold;
display: flex;
align-items: center;
gap: 4px;
}
.live-dot-enhanced {
width: 6px;
height: 6px;
background: white;
border-radius: 50%;
animation: pulse-enhanced 2s infinite;
}
@keyframes pulse-enhanced {
0%, 100% { opacity: 1; }
50% { opacity: 0.3; }
}
.video-meta-enhanced h4 {
color: #fff;
font-size: 1.1rem;
margin-bottom: 8px;
line-height: 1.3;
}
.video-meta-enhanced p {
color: rgba(255, 255, 255, 0.8);
margin-bottom: 8px;
font-size: 0.9rem;
}
.video-description-enhanced {
font-size: 0.8rem !important;
color: rgba(255, 255, 255, 0.6) !important;
max-height: 60px;
overflow: hidden;
line-height: 1.4;
}
.video-stats-enhanced {
display: flex;
gap: 15px;
flex-wrap: wrap;
margin: 10px 0;
}
.video-stats-enhanced span {
color: var(--phoenix-orange);
font-size: 0.8rem;
display: flex;
align-items: center;
gap: 4px;
}
.video-stats-enhanced i {
color: rgba(255, 107, 53, 0.8);
}
/* Up Next Section */
.up-next-container {
max-height: 300px;
overflow-y: auto;
overflow-x: hidden;
}
.up-next-item {
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
padding: 12px;
margin-bottom: 10px;
border-left: 3px solid var(--phoenix-orange);
transition: all 0.3s ease;
cursor: pointer;
}
.up-next-item:hover {
background: rgba(255, 107, 53, 0.1);
transform: translateX(5px);
}
.queue-position {
color: var(--phoenix-orange);
font-weight: bold;
font-size: 0.9rem;
margin-bottom: 5px;
}
.queue-song-title {
color: #fff;
font-size: 0.95rem;
margin-bottom: 4px;
font-weight: 500;
}
.queue-requester {
color: rgba(255, 255, 255, 0.7);
font-size: 0.8rem;
margin-bottom: 4px;
}
.queue-timestamp {
color: rgba(255, 255, 255, 0.5);
font-size: 0.75rem;
}
.loading {
text-align: center;
color: rgba(255, 255, 255, 0.6);
font-style: italic;
padding: 20px;
}
/* Custom Scrollbar for Up Next */
.up-next-container::-webkit-scrollbar {
width: 6px;
}
.up-next-container::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
}
.up-next-container::-webkit-scrollbar-thumb {
background: linear-gradient(180deg, var(--phoenix-orange), #ff8c42);
border-radius: 3px;
}
.up-next-container::-webkit-scrollbar-thumb:hover {
background: linear-gradient(180deg, #ff8c42, var(--phoenix-orange));
}
/* Mobile Responsive for Enhanced Panel */
@media (max-width: 768px) {
.video-info-panel {
grid-template-columns: 1fr;
gap: 20px;
padding: 20px;
}
.video-details-enhanced {
grid-template-columns: 1fr;
text-align: center;
gap: 10px;
}
.video-thumbnail-enhanced {
width: 100%;
height: 180px;
margin: 0 auto;
}
.video-stats-enhanced {
justify-content: center;
gap: 10px;
}
.up-next-container {
max-height: 200px;
}
}
</style>
</head>
<body>
<!-- Animated Background -->
<div class="flame-background">
<div class="flame flame-1"></div>
<div class="flame flame-2"></div>
<div class="flame flame-3"></div>
<div class="flame flame-4"></div>
<div class="flame flame-5"></div>
</div>
<!-- Navigation -->
<nav class="navbar">
<div class="nav-container">
<div class="nav-logo">
<i class="fas fa-fire-flame-curved"></i>
<span>Freedom Phoenix</span>
</div>
<ul class="nav-menu">
<li><a href="index.html" class="nav-link">Home</a></li>
<li><a href="index.html#radio" class="nav-link">Jungle Radio</a></li>
<li><a href="stream.html" class="nav-link active">24/7 Stream</a></li>
<li><a href="index.html#token" class="nav-link">$FPT Token</a></li>
<li><a href="index.html#nft" class="nav-link">NFT Collection</a></li>
<li><a href="whitepaper.html" class="nav-link">White Paper</a></li>
</ul>
<div class="hamburger">
<span></span>
<span></span>
<span></span>
</div>
</div>
</nav>
<!-- Top Right Phoenix -->
<div class="top-phoenix">
<img src="phoenix-new.jpg" alt="Freedom Phoenix Profile" class="top-phoenix-img">
</div>
<!-- Stream Container -->
<div class="stream-container">
<div class="stream-header">
<h1 class="stream-title">
<i class="fas fa-play-circle"></i>
24/7 Live Stream
</h1>
<div class="stream-status">
<div class="live-indicator"></div>
<span id="stream-status-text">Connecting...</span>
</div>
</div>
<!-- Video Player -->
<div class="video-container">
<div id="youtube-player"></div>
</div>
<!-- Current Video Info -->
<div class="stream-info">
<div class="current-video">
<img id="video-thumbnail" src="" alt="Video thumbnail" class="video-thumbnail" style="display: none;">
<div class="video-details">
<h3 id="video-title">Loading stream...</h3>
<p id="video-description">Preparing the next video in our 24/7 stream</p>
</div>
</div>
</div>
<!-- Enhanced Video Information Panel -->
<div class="video-info-panel">
<div class="now-playing-section">
<h3><i class="fas fa-music"></i> Now Playing</h3>
<div id="currentVideoInfo" class="video-details-enhanced">
<div class="video-thumbnail-enhanced">
<img id="currentThumbnail" src="" alt="Current video thumbnail">
<div class="live-indicator-enhanced">
<span class="live-dot-enhanced"></span>
LIVE
</div>
</div>
<div class="video-meta-enhanced">
<h4 id="currentTitle">Loading current track...</h4>
<p id="currentChannel">Freedom Phoenix Radio</p>
<div class="video-stats-enhanced">
<span id="currentViews"><i class="fas fa-eye"></i> Loading...</span>
<span id="currentDuration"><i class="fas fa-clock"></i> Live Stream</span>
<span id="streamStatus"><i class="fas fa-broadcast-tower"></i> 24/7 Active</span>
</div>
<p id="currentDescription" class="video-description-enhanced">Getting video information...</p>
</div>
</div>
</div>
<div class="up-next-section">
<h3><i class="fas fa-forward"></i> Up Next</h3>
<div id="upNextQueue" class="up-next-container">
<p class="loading">Loading upcoming songs...</p>
</div>
</div>
</div>
<!-- Stream Controls -->
<div class="stream-controls">
<button id="mute-btn" class="control-btn">
<i class="fas fa-volume-up"></i> Mute
</button>
<div class="volume-control">
<i class="fas fa-volume-down"></i>
<input type="range" id="volume-slider" class="volume-slider" min="0" max="100" value="50">
<i class="fas fa-volume-up"></i>
</div>
<button id="refresh-btn" class="control-btn">
<i class="fas fa-refresh"></i> Refresh
</button>
</div>
<!-- Loading/Error Messages -->
<div id="loading-message" class="loading-message" style="display: none;">
<i class="fas fa-spinner fa-spin"></i> Loading stream...
</div>
<div id="error-message" class="error-message" style="display: none;">
<i class="fas fa-exclamation-triangle"></i>
<span id="error-text">Unable to load stream. Please try again later.</span>
</div>
</div>
<!-- Firebase SDK -->
<script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-database-compat.js"></script>
<!-- YouTube Player API -->
<script src="https://www.youtube.com/iframe_api"></script>
<!-- Local Stream Manager -->
<script src="local-stream.js"></script>
<!-- Stream Script -->
<script src="stream.js"></script>
<!-- Navigation Script (reuse from main site) -->
<script>
// Mobile menu toggle
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
// Close menu when clicking on a link
document.querySelectorAll('.nav-link').forEach(n => n.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
}));
// Stream Information Manager
class StreamInfo {
constructor() {
this.currentVideoUrl = null; // Will be fetched from Firebase
this.currentVideoId = null;
this.titleCache = new Map(); // Cache for YouTube titles
this.firebaseConfig = {
apiKey: "AIzaSyBiwWy-J_C83MWeD88ZODIw2H6r2suUPTY",
authDomain: "fpt-radio.firebaseapp.com",
databaseURL: "https://fpt-radio-default-rtdb.firebaseio.com",
projectId: "fpt-radio",
storageBucket: "fpt-radio.firebasestorage.app",
messagingSenderId: "121288710296",
appId: "1:121288710296:web:041addd1c3a91f2c8f58ed"
};
this.init();
}
init() {
this.initFirebase();
// Initial load
this.loadCurrentStreamInfo();
this.loadStreamPlaylist();
// Refresh current video info every 2 minutes (more frequent for stream)
setInterval(() => {
this.loadCurrentStreamInfo();
}, 120000);
// Refresh playlist every 30 seconds
setInterval(() => {
this.loadStreamPlaylist();
}, 30000);
}
initFirebase() {
if (typeof firebase !== 'undefined') {
firebase.initializeApp(this.firebaseConfig);
this.database = firebase.database();
console.log('Firebase initialized for StreamInfo');
} else {
console.error('Firebase not loaded');
}
}
// Extract video ID from YouTube URL
extractVideoId(url) {
const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
const match = url.match(regExp);
return (match && match[2].length === 11) ? match[2] : null;
}
// Get video info using oEmbed (free, no API key required) with caching
async getVideoInfoOEmbed(videoUrl) {
console.log('Fetching video info for:', videoUrl);
// Check cache first
if (this.titleCache.has(videoUrl)) {
console.log('Using cached result for:', videoUrl);
return this.titleCache.get(videoUrl);
}
try {
const oEmbedUrl = `https://www.youtube.com/oembed?url=${encodeURIComponent(videoUrl)}&format=json`;
console.log('Making oEmbed request to:', oEmbedUrl);
const response = await fetch(oEmbedUrl);
console.log('oEmbed response status:', response.status);
if (!response.ok) {
console.error('oEmbed API error:', response.status, response.statusText);
throw new Error(`Failed to fetch video info: ${response.status}`);
}
const data = await response.json();
console.log('oEmbed data received:', data);
// Cache the result for 5 minutes
this.titleCache.set(videoUrl, data);
setTimeout(() => this.titleCache.delete(videoUrl), 5 * 60 * 1000);
return data;
} catch (error) {
console.error('Error fetching video info via oEmbed:', error);
// Cache null result for 1 minute to prevent repeated failed calls
this.titleCache.set(videoUrl, null);
setTimeout(() => this.titleCache.delete(videoUrl), 60 * 1000);
return null;
}
}
// Load current stream information from Firebase
async loadCurrentStreamInfo() {
if (!this.database) {
console.error('Firebase database not initialized');
return;
}
try {
// Get current video from Firebase stream data
const streamRef = this.database.ref('stream/currentVideo');
streamRef.once('value', async (snapshot) => {
const currentVideo = snapshot.val();
if (currentVideo && currentVideo.videoId) {
this.currentVideoId = currentVideo.videoId;
this.currentVideoUrl = `https://www.youtube.com/watch?v=${currentVideo.videoId}`;
// Get video info from YouTube using oEmbed
const videoData = await this.getVideoInfoOEmbed(this.currentVideoUrl);
if (videoData) {
this.updateCurrentVideoDisplay(videoData, currentVideo);
} else {
// If oEmbed fails, try to use any title from Firebase or show fallback
const fallbackTitle = currentVideo.title && currentVideo.title !== currentVideo.videoId
? currentVideo.title
: 'Freedom Phoenix Live Stream';
this.showFallbackCurrentVideo({
...currentVideo,
title: fallbackTitle
});
}
} else {
// No current video in Firebase, show fallback
this.showDefaultCurrentVideo();
}
});
} catch (error) {
console.error('Error loading current stream info:', error);
this.showDefaultCurrentVideo();
}
}
// Load stream playlist (up next) from Firebase
loadStreamPlaylist() {
if (!this.database) {
console.error('Firebase database not initialized');
return;
}
const playlistRef = this.database.ref('stream/playlist');
playlistRef.on('value', async (snapshot) => {
const playlist = snapshot.val();
await this.displayStreamPlaylist(playlist);
}, (error) => {
console.error('Error loading stream playlist:', error);
document.getElementById('upNextQueue').innerHTML = '<p class="loading">Unable to load playlist. Please try again later.</p>';
});
}
// Update current video display with YouTube data
updateCurrentVideoDisplay(videoData, currentVideo) {
document.getElementById('currentTitle').textContent = videoData.title || 'Freedom Phoenix Live Stream';
document.getElementById('currentChannel').textContent = videoData.author_name || 'Freedom Phoenix Radio';
// Try to get description from title
const description = this.extractDescriptionFromTitle(videoData.title);
document.getElementById('currentDescription').textContent = description;
// Update stats with live stream info
document.getElementById('currentViews').innerHTML = '<i class="fas fa-users"></i> Live Listeners';
document.getElementById('currentDuration').innerHTML = '<i class="fas fa-infinity"></i> 24/7 Stream';
document.getElementById('streamStatus').innerHTML = '<i class="fas fa-signal"></i> Broadcasting';
// Set thumbnail with error handling
const thumbnailElement = document.getElementById('currentThumbnail');
if (thumbnailElement) {
if (videoData.thumbnail_url) {
thumbnailElement.src = videoData.thumbnail_url;
} else if (currentVideo.videoId) {
thumbnailElement.src = `https://img.youtube.com/vi/${currentVideo.videoId}/mqdefault.jpg`;
} else {
thumbnailElement.src = 'https://pbs.twimg.com/profile_images/1862246538698313730/nQT8JdPJ_400x400.jpg';
}
// Fallback to phoenix image if thumbnail fails to load
thumbnailElement.onerror = function() {
this.src = 'phoenix-new.jpg';
};
}
}
// Show fallback info when YouTube API fails but we have Firebase data
showFallbackCurrentVideo(currentVideo) {
const title = currentVideo.title && currentVideo.title !== currentVideo.videoId
? currentVideo.title
: 'Freedom Phoenix Live Stream';
document.getElementById('currentTitle').textContent = title;
document.getElementById('currentChannel').textContent = 'Freedom Phoenix Radio';
document.getElementById('currentDescription').textContent = '24/7 Music Stream - Rise from the Ashes';
document.getElementById('currentViews').innerHTML = '<i class="fas fa-broadcast-tower"></i> Live';
document.getElementById('currentDuration').innerHTML = '<i class="fas fa-infinity"></i> 24/7 Stream';
document.getElementById('streamStatus').innerHTML = '<i class="fas fa-signal"></i> Broadcasting';
// Set thumbnail with error handling
const thumbnailElement = document.getElementById('currentThumbnail');
if (thumbnailElement && currentVideo.videoId) {
thumbnailElement.src = `https://img.youtube.com/vi/${currentVideo.videoId}/mqdefault.jpg`;
thumbnailElement.onerror = function() {
this.src = 'phoenix-new.jpg';
};
}
}
// Show default info when no data is available
showDefaultCurrentVideo() {
document.getElementById('currentTitle').textContent = 'Freedom Phoenix Live Stream';
document.getElementById('currentChannel').textContent = 'Freedom Phoenix Radio';
document.getElementById('currentDescription').textContent = '24/7 Music Stream - Rise from the Ashes';
document.getElementById('currentViews').innerHTML = '<i class="fas fa-broadcast-tower"></i> Live';
document.getElementById('currentDuration').innerHTML = '<i class="fas fa-infinity"></i> 24/7 Stream';
document.getElementById('streamStatus').innerHTML = '<i class="fas fa-signal"></i> Broadcasting';
// Set default thumbnail
const thumbnailElement = document.getElementById('currentThumbnail');
if (thumbnailElement) {
thumbnailElement.src = 'phoenix-new.jpg';
}
}
// Display the stream playlist (what's actually up next in the stream)
async displayStreamPlaylist(playlist) {
const container = document.getElementById('upNextQueue');
console.log('Displaying stream playlist:', playlist);
if (!playlist || !playlist.videos || playlist.videos.length === 0) {
container.innerHTML = '<p class="loading">No videos in stream playlist.</p>';
return;
}
const videos = playlist.videos;
console.log('Processing', videos.length, 'videos');
// Show up to 5 upcoming videos
const upNext = videos.slice(0, 5);
let html = '';
// Fetch real titles for each video
for (let index = 0; index < upNext.length; index++) {
const video = upNext[index];
console.log('Processing video:', video);
let songTitle = video.title;
// If no title or just video ID, fetch from YouTube
if (!songTitle || songTitle === video.videoId || songTitle.length < 3 || songTitle.startsWith('Video ')) {
console.log('Need to fetch title for video ID:', video.videoId);
const videoUrl = `https://www.youtube.com/watch?v=${video.videoId}`;
console.log('Calling getVideoInfoOEmbed for:', videoUrl);
const videoData = await this.getVideoInfoOEmbed(videoUrl);
songTitle = videoData ? videoData.title : `Video ${video.videoId}`;
console.log('Fetched title:', songTitle);
}
const duration = video.duration || 'Unknown';
html += `
<div class="up-next-item" onclick="window.open('https://www.youtube.com/watch?v=${video.videoId}', '_blank')">
<div class="queue-position">Up Next #${index + 1}</div>
<div class="queue-song-title">${this.escapeHtml(songTitle)}</div>
<div class="queue-requester">Duration: ${this.escapeHtml(duration)}</div>
<div class="queue-timestamp">Stream Playlist</div>
</div>
`;
}
container.innerHTML = html;
}
// Extract meaningful description from video title
extractDescriptionFromTitle(title) {
if (!title) return '24/7 Music Stream - Rise from the Ashes';
// Common patterns in music stream titles
if (title.includes('24/7')) return 'Continuous 24/7 music streaming';
if (title.includes('lofi') || title.includes('Lo-Fi')) return 'Relaxing Lo-Fi beats for studying and focus';
if (title.includes('chill')) return 'Chill music for relaxation and productivity';
if (title.includes('study')) return 'Background music perfect for studying';
if (title.includes('sleep')) return 'Peaceful music for sleep and relaxation';
if (title.includes('hip hop')) return 'Hip hop beats and rhythms';
if (title.includes('jazz')) return 'Smooth jazz for relaxation';
if (title.includes('electronic')) return 'Electronic music and beats';
// Default description
return 'Live music stream from Freedom Phoenix Radio';
}
// Escape HTML to prevent XSS
escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
}
// Initialize StreamInfo when page loads
document.addEventListener('DOMContentLoaded', function() {
new StreamInfo();
});
</script>
</body>
</html>