-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlive.html
191 lines (168 loc) · 6.73 KB
/
live.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live Video Simulation</title>
<!-- Font Awesome for play icon -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
body {
margin: 0;
text-align: center;
background-color: #000;
color: white;
font-family: Arial, sans-serif;
overflow: hidden;
}
.live-container {
position: relative;
width: 100%;
height: 400px; /* Fixed height for video */
overflow: hidden;
border-bottom: 2px solid #fff; /* Subtle border at the bottom */
}
.live-status {
position: absolute;
right: 5px;
top: 5px;
display: flex;
align-items: center;
font-weight: bold;
font-family: Arial, sans-serif;
font-size: 14px; /* Small font size for time */
background-color: red;
color: white;
padding: 5px 10px;
border-radius: 5px;
}
.live-status span {
margin-left: 5px; /* Space between time and "LIVE" */
}
video {
width: 100%;
height: 100%;
object-fit: contain; /* Ensures full video is visible */
background: black; /* Prevents blank spaces */
display: block;
margin: 0 auto;
opacity: 0;
transition: opacity 1s ease-in-out;
}
.video-info {
margin-top: 20px;
font-size: 18px;
font-weight: bold;
}
.video-title {
font-size: 22px;
color: #f0f0f0;
background: rgba(0, 0, 0, 0.6);
padding: 10px;
text-align: center;
}
/* Play button style */
.play-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 50px;
color: white;
background: rgba(0, 0, 0, 0.6);
border: none;
padding: 20px;
border-radius: 50%;
cursor: pointer;
display: block;
}
</style>
</head>
<body>
<div class="live-container">
<div class="live-status">
<span id="liveTime">00:00:00</span>
<span>LIVE</span>
</div>
<video id="liveVideo" autoplay muted></video>
<!-- Play button initially visible -->
<button id="playButton" class="play-button"><i class="fas fa-play"></i></button>
</div>
<div class="video-title" id="videoTitle">Starting Live Video...</div>
<script>
const videos = [
{
src: "https://quran-online.pages.dev/podcast/alquran/SURAH%20AL%20LAYL%20_%20translation%20_%20english%20_%20copyright%20free%20Quran(720P_60FPS).mp4",
duration: 114, // 114 seconds video
title: "SURAH AL LAYL | translation | english |"
},
{
src: "https://quran-online.pages.dev/podcast/alquran/surah%20tin_quran%20tilawat_beautiful%20quran%20recitation%20_%20copyright%20free%20quran%20tilawat%20_%20creative%20common(720P_HD).mp4",
duration: 74, // 74 seconds video
title: "surah tin | quran tilawat"
},
{
src: "https://quran-online.pages.dev/podcast/alquran/Surah%20AL-Balad%20_%20Quran%20Recitation%20_%20Copy%20Right%20free%20Quran%20Tilawat(720P_HD).mp4",
duration: 101, // 1 minute 41 seconds
title: "Surah AL-Balad | Quran Recitation"
}
];
function getCurrentTimeInSeconds() {
const now = new Date();
return now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
}
function findCurrentVideo() {
let currentTime = getCurrentTimeInSeconds();
let totalDuration = videos.reduce((sum, vid) => sum + vid.duration, 0);
if (currentTime >= totalDuration) {
currentTime %= totalDuration; // Loop back to start
}
let accumulatedTime = 0;
for (let i = 0; i < videos.length; i++) {
accumulatedTime += videos[i].duration;
if (currentTime < accumulatedTime) {
return { index: i, startTime: currentTime - (accumulatedTime - videos[i].duration) };
}
}
return { index: 0, startTime: 0 }; // Fallback
}
function startVideo() {
const videoElement = document.getElementById("liveVideo");
const titleElement = document.getElementById("videoTitle");
const liveTimeElement = document.getElementById("liveTime");
const { index, startTime } = findCurrentVideo();
videoElement.src = videos[index].src;
videoElement.currentTime = startTime;
videoElement.play();
// Fade in the video with smooth transition
videoElement.style.opacity = 1;
// Hide video controls (no progress bar or buttons)
videoElement.controls = false;
// Update video title dynamically
titleElement.innerHTML = `🎬 Now Playing: <b>${videos[index].title}</b>`;
document.title = `LIVE: ${videos[index].title}`;
// Update live time every second
setInterval(() => {
const currentTime = getCurrentTimeInSeconds();
let hours = Math.floor(currentTime / 3600);
let minutes = Math.floor((currentTime % 3600) / 60);
let seconds = currentTime % 60;
liveTimeElement.textContent = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
}, 1000);
// When video ends, switch to next video
videoElement.onended = () => {
videoElement.style.opacity = 0; // Fade out the current video
setTimeout(startVideo, 1000); // Wait for 1 second before switching to next video
};
}
document.getElementById("playButton").onclick = () => {
const videoElement = document.getElementById("liveVideo");
// Hide the play button
document.getElementById("playButton").style.display = "none";
// Unmute and play the video
videoElement.muted = false;
startVideo();
};
</script>
</body>
</html>