const fileUrl = "https://lb2-e2-19.pluscdn.pl/ch/1502600/308/dash/20a18c30/live.mpd"; const musicUrl = "https://awanturaokase.pages.dev/music/output.m3u8"; const startHour = 17, startMinute = 30; const stopHour = 18, stopMinute = 45; const videoContainer = document.getElementById('video'); let playerInstance = null; function initializePlayer(url, type = "dash") { videoContainer.innerHTML = ""; playerInstance = jwplayer("video").setup({ file: url, type: type, autostart: true, width: "100%", height: "100%", stretching: "fill" }); } function stopPlayer() { if (playerInstance) { playerInstance.remove(); playerInstance = null; } videoContainer.innerHTML = `
Stream zakończony. Odcinek wkrótce będzie w VOD.
`; } function showAudioPlayer() { videoContainer.innerHTML = `
Stream rozpocznie się wkrótce. Posłuchaj muzyki!
`; } function updateCountdown() { const now = new Date(); const day = now.getDay(); const currentTime = now.getTime(); const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), startHour, startMinute).getTime(); const todayStop = new Date(now.getFullYear(), now.getMonth(), now.getDate(), stopHour, stopMinute).getTime(); if (day === 0 || day === 6) { // Stream tylko w weekendy if (currentTime >= todayStop) { stopPlayer(); clearInterval(countdownInterval); } else if (currentTime >= todayStart) { if (!playerInstance || playerInstance.getConfig().file !== fileUrl) { initializePlayer(fileUrl); } } else { showAudioPlayer(); } } else { videoContainer.innerHTML = `
Awantura o kasę tylko w soboty i niedziele o 17:30.
`; } } const countdownInterval = setInterval(updateCountdown, 1000); updateCountdown();