PURA ENERGÍA
Listo para reproducir
Shoutcast Hosting Stream Hosting Radio Server Hosting
script> (() => { const audio = document.getElementById("radioAudio"); const playBtn = document.getElementById("playBtn"); const playIcon = document.getElementById("playIcon"); const pauseIcon = document.getElementById("pauseIcon"); const volDownBtn = document.getElementById("volDownBtn"); const volUpBtn = document.getElementById("volUpBtn"); const volumeSlider = document.getElementById("volumeSlider"); const statusText = document.getElementById("statusText"); const playerUi = document.getElementById("playerUi"); const waveBox = document.getElementById("waveBox"); const bottomEq = document.getElementById("bottomEq"); const waveHeights = [ 10, 8, 16, 44, 18, 28, 52, 22, 38, 66, 26, 48, 74, 30, 56, 68, 34, 60, 46, 28, 50, 36, 22, 40, 24, 14, 26, 12, 8 ]; if (waveBox) { waveBox.innerHTML = ""; waveHeights.forEach((h, i) => { const bar = document.createElement("span"); bar.className = "wave-bar"; bar.style.setProperty("--h", h + "px"); bar.style.setProperty("--d", ((i * 0.07) % 0.8).toFixed(2) + "s"); waveBox.appendChild(bar); }); } const eqBars = []; if (bottomEq) { bottomEq.innerHTML = ""; for (let i = 0; i < 42; i++) { const b = document.createElement("span"); b.className = "eq-bar"; const basePct = 18 + Math.round(Math.sin(i * 0.45) * 28 + Math.random() * 25); b.style.height = Math.max(12, Math.min(82, basePct)) + "%"; bottomEq.appendChild(b); eqBars.push(b); } } function findCasterAudioElement() { const localAudio = document.querySelector(".cstrEmbed audio") || audio; if (localAudio) return localAudio; const iframes = document.querySelectorAll("iframe"); for (const frame of iframes) { try { const doc = frame.contentDocument || (frame.contentWindow && frame.contentWindow.document); const frameAudio = doc && doc.querySelector("audio"); if (frameAudio) return frameAudio; } catch (e) {} } return null; } function findCasterPlayControl() { const selectors = [ ".cstrEmbed button", ".cstrEmbed [role='button']", ".cstrEmbed .play", ".cstrEmbed [class*='play']", ".cstrEmbed [aria-label*='play' i]", ".cstrEmbed [title*='play' i]" ]; for (const sel of selectors) { const el = document.querySelector(sel); if (el) return el; } const iframes = document.querySelectorAll("iframe"); for (const frame of iframes) { try { const doc = frame.contentDocument || (frame.contentWindow && frame.contentWindow.document); if (!doc) continue; for (const sel of [ "button", "[role='button']", ".play", "[class*='play']", "[aria-label*='play' i]", "[title*='play' i]" ]) { const inner = doc.querySelector(sel); if (inner) return inner; } } catch (e) {} } return null; } function applyVolume() { if (!volumeSlider) return; const pct = Math.max(0, Math.min(100, Number(volumeSlider.value) || 0)); volumeSlider.style.setProperty("--pct", pct + "%"); const vol = pct / 100; if (audio) { try { audio.volume = vol; } catch (e) {} } const casterAudio = findCasterAudioElement(); if (casterAudio && casterAudio !== audio) { try { casterAudio.volume = vol; } catch (e) {} } } function setPlayingState(isPlaying) { if (playerUi) playerUi.classList.toggle("playing", Boolean(isPlaying)); if (playIcon) playIcon.style.display = isPlaying ? "none" : "block"; if (pauseIcon) pauseIcon.style.display = isPlaying ? "block" : "none"; } function refreshStatus() { applyVolume(); const activeAudio = findCasterAudioElement(); const isPlaying = Boolean(activeAudio && !activeAudio.paused); setPlayingState(isPlaying); if (!statusText) return; if (isPlaying) { statusText.textContent = "EN VIVO • ENERGY WEB"; } else if (!statusText.textContent || statusText.textContent === "Conectando señal en vivo...") { statusText.textContent = "Listo para reproducir"; } } async function togglePlayback() { applyVolume(); if (audio && audio.src) { try { if (audio.paused) { if (statusText) statusText.textContent = "Conectando señal en vivo..."; audio.load(); await audio.play(); setPlayingState(true); if (statusText) statusText.textContent = "EN VIVO • ENERGY WEB"; } else { audio.pause(); setPlayingState(false); if (statusText) statusText.textContent = "Pausado"; } return; } catch (err) { setPlayingState(false); if (statusText) statusText.textContent = "Revisa tu enlace de stream o señal"; return; } } const control = findCasterPlayControl(); if (control) { control.click(); setTimeout(refreshStatus, 350); setTimeout(refreshStatus, 1100); return; } if (statusText) { statusText.textContent = "Widget de Caster.fm no disponible en esta red"; } } applyVolume(); setPlayingState(false); if (playBtn) { playBtn.addEventListener("click", togglePlayback); } if (volumeSlider) { volumeSlider.addEventListener("input", () => { applyVolume(); if (statusText) statusText.textContent = "Volumen: " + volumeSlider.value + "%"; }); volumeSlider.addEventListener("change", applyVolume); } if (volDownBtn && volumeSlider) { volDownBtn.addEventListener("click", () => { volumeSlider.value = String(Math.max(0, (Number(volumeSlider.value) || 0) - 15)); applyVolume(); if (statusText) statusText.textContent = "Volumen: " + volumeSlider.value + "%"; }); } if (volUpBtn && volumeSlider) { volUpBtn.addEventListener("click", () => { volumeSlider.value = String(Math.min(100, (Number(volumeSlider.value) || 0) + 15)); applyVolume(); if (statusText) statusText.textContent = "Volumen: " + volumeSlider.value + "%"; }); } setInterval(() => { if (!playerUi || !playerUi.classList.contains("playing")) return; eqBars.forEach((bar, idx) => { const nextH = 14 + Math.round(Math.abs(Math.sin(Date.now() * 0.004 + idx * 0.5)) * 68); bar.style.height = nextH + "%"; }); }, 180); })();