messageElement.textContent = `Stream will start in ${minutes}m ${seconds}s`;
}
}
function startPlayback() {
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(videoSrc);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
video.play().catch(e => {
console.error(“Autoplay failed:”, e);
messageElement.textContent = “Click play to start the stream.”;
});
});
} else if (video.canPlayType(‘application/vnd.apple.mpegurl’)) {
video.src = videoSrc;
video.addEventListener(‘loadedmetadata’, function() {
video.play().catch(e => {
console.error(“Autoplay failed:”, e);
messageElement.textContent = “Click play to start the stream.”;
});
});
} else {
messageElement.textContent = “HLS is not supported in this browser.”;
}
}
// Start the countdown timer
timerInterval = setInterval(updateTimer, 1000);
updateTimer(); // Initial call to display the message immediately
});