const albumCover = document.getElementById('albumCover'); const songTitle = document.getElementById('songTitle'); const artistName = document.getElementById('artistName'); const pedidoBtn = document.getElementById('pedidoBtn'); const pedidoModal = new bootstrap.Modal(document.getElementById('pedidoModal')); const pedidoContent = document.getElementById('pedidoContent'); const historicoBtn = document.getElementById('historicoBtn'); const historicoModal = new bootstrap.Modal(document.getElementById('historicoModal')); const historicoContent = document.getElementById('historicoContent'); const progBtn = document.getElementById('progBtn'); const progModal = new bootstrap.Modal(document.getElementById('progModal')); const progContent = document.getElementById('progContent'); const parceiroBtn = document.getElementById('parceiroBtn'); const parceiroModal = new bootstrap.Modal(document.getElementById('parceiroModal')); const parceiroContent = document.getElementById('parceiroContent'); const emailBtn = document.getElementById('emailBtn'); const emailModal = new bootstrap.Modal(document.getElementById('emailModal')); const emailContent = document.getElementById('emailContent'); const sobreBtn = document.getElementById('sobreBtn'); const sobreModal = new bootstrap.Modal(document.getElementById('sobreModal')); const sobreContent = document.getElementById('sobreContent'); let currentSong = ''; let isFirstLoad = true; let lastAlbumCoverUrl = ''; pedidoBtn.addEventListener('click', showPedido); historicoBtn.addEventListener('click', showHistorico); progBtn.addEventListener('click', showProg); parceiroBtn.addEventListener('click', showParceiro); emailBtn.addEventListener('click', showEmail); sobreBtn.addEventListener('click', showSobre); function showPedido() { pedidoModal.show(); } function showHistorico() { historicoModal.show(); } function showProg() { progModal.show(); } function showParceiro() { parceiroModal.show(); } function showEmail() { emailModal.show(); } function showSobre() { sobreModal.show(); } const URL_STREAMING = "https://azura.servercast.com.br/listen/radio_podcast_catolica/radio.mp3"; const playerStream = new Audio(URL_STREAMING); var isPlaying = false; var mouseclicked = true; var btnPlayer; playerStream.onloadeddata = async (event) => { if (isPlaying) { playerStream.play().then(async () => { await atualizaButton("stop") }).catch(async (e) => { await atualizaButton("start") }) } }; playerStream.onerror = async (event) => { setTimeout(() => { playerStream.load() }, 1000) }; playerStream.onended = async (event) => { const timer = setInterval(() => { playerStream.load(); if (!playerStream.ended) { clearInterval(timer) } }, 1000) }; $(document).ready(function() { btnPlayer = document.getElementById("playerButton"); btnPlayer.addEventListener("click", togglePlay); window.addEventListener("click", (event) => { if (!mouseclicked) { mouseclicked = true; if (!(event.target.className == "bi bi-play-circle" || event.target.className == "bi bi-play-circle" || event.target.id == "playerButton" || event.target.id == "3icone1" || event.target.id == "icone1")) { btnPlayer.click() } } }) }); function setVolume() { if (playerStream) { playerStream.volume = document.getElementById("volume").value } } function setMute(e) { if (playerStream) { playerStream.muted = !playerStream.muted; e.target.className = (playerStream.muted) ? "bi bi-volume-mute" : "bi bi-volume-up" } } async function stop() { if (playerStream) { playerStream.pause(); playerStream.src = playerStream.src; isPlaying = false } await atualizaButton("start") } async function play() { await atualizaButton("load"); isPlaying = true; if (playerStream && playerStream.readyState != 0) { playerStream.load(); playerStream.play().then(async () => { await atualizaButton("stop") }).catch(async (e) => { await atualizaButton("start") }) } } function togglePlay() { if (isPlaying) { stop() } else { play() } }; async function atualizaButton(status) { switch (status) { case "start": document.getElementById("playerButton").className = "bi bi-play-circle play"; break; case "stop": document.getElementById("playerButton").className = "bi bi-pause-circle play"; break; default: document.getElementById("playerButton").className = "bi bi-play-circle play"; break } } jQuery(document).ready(function() { jQuery(".modern-ticker").modernTicker({ effect: "scroll", scrollType: "continuous", scrollStart: "inside", scrollInterval: 20, transitionTime: 500, randomOrder: true, linksEnabled: true, pauseOnHover: true, autoplay: true, feedType: "rss", loadType: "process", feedUrl: "https://g1.globo.com/rss/g1/", loadProcess: "rss2json", forceNoCache: false, feedCount: 15, linkTarget: "_blank", refresh: "30:00" }); }); $(document).ready(function() { $("body").bind("cut copy paste", function(e) { e.preventDefault() }); $("body").on("contextmenu", function(e) { return false }) }); function updateMetadata() { $.ajax({ url: 'https://azura.servercast.com.br/api/nowplaying/76', dataType: 'json', success: function(data) { if (data && data.now_playing && data.now_playing.song) { const newArtist = data.now_playing.song.artist; const newTitle = data.now_playing.song.title; if (currentSong !== `${newArtist} - ${newTitle}` || isFirstLoad) { currentSong = `${newArtist} - ${newTitle}`; artistName.textContent = newArtist; songTitle.textContent = newTitle; fetchAlbumCover(newArtist, newTitle); isFirstLoad = false; } } else { songTitle.textContent = 'Transmissão Online'; artistName.textContent = data.station.name || 'Rádio Desconhecida'; } }, error: function(xhr, status, error) { console.error('Error fetching metadata:', error); songTitle.textContent = 'Não foi possível obter os dados'; artistName.textContent = 'Tente novamente'; } }); } function fetchAlbumCover(artist, track) { const searchTerm = encodeURIComponent(`${artist} - ${track}`); const url = `https://itunes.apple.com/search?term=${searchTerm}&media=music&limit=1`; $.ajax({ url: url, dataType: 'jsonp', success: function(data) { if (data.results && data.results.length > 0) { const artworkUrl = data.results[0].artworkUrl100.replace('100x100', '600x600'); if (artworkUrl !== lastAlbumCoverUrl) { lastAlbumCoverUrl = artworkUrl; fadeImage(artworkUrl); } } else { setDefaultCover(); } }, error: function(xhr, status, error) { console.error('Error fetching iTunes data:', error); setDefaultCover(); } }); } function setDefaultCover() { if (lastAlbumCoverUrl !== './img/logo.png?v=1741956362') { lastAlbumCoverUrl = './img/logo.png?v=1741956362'; fadeImage(lastAlbumCoverUrl); } } function fadeImage(newSrc) { albumCover.style.opacity = 0; setTimeout(() => { albumCover.src = newSrc; albumCover.style.opacity = 1; }, 300); } updateMetadata(); setInterval(updateMetadata, 25000); // Inicializa os tooltips do Bootstrap var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) var tooltipList = tooltipTriggerList.map(function(tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl) })