<?php
// Players Windows/Linux/Android Link
$porta = query_string('1');

if(!is_numeric($porta)) {
die ("Error! Missing data.");
}

$verifica_stm = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM streamings where porta = '".$porta."'"));

if($verifica_stm == 0) {
die ("Error! Missing data.");
}

$dados_config = @mysqli_fetch_array(@mysqli_query($conexao,"SELECT * FROM configuracoes"));
$dados_stm = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM streamings where porta = '".$porta."'"));
$dados_servidor = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM servidores where codigo = '".$dados_stm["codigo_servidor"]."'"));

$total_pontos = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM multipoint where codigo_stm = '".$dados_stm["codigo"]."'"));

if($total_pontos > 0) {
$ponto = "/1";
} else {
$ponto = "/stream";
}

$url_streaming = "https://".strtolower($dados_servidor["nome"]).".".$dados_config["dominio_padrao"].":".$dados_stm["porta"]."";

if(!empty($_GET["url"])) {

$url = filter_input(INPUT_GET, "url", FILTER_SANITIZE_URL);
$nextSong = filter_input(INPUT_GET, "next", FILTER_VALIDATE_BOOLEAN);
$historic = filter_input(INPUT_GET, "historic", FILTER_VALIDATE_BOOLEAN);
$streamingType = filter_input(INPUT_GET, "streamtype", FILTER_SANITIZE_STRING);
if (!empty($url)) {
    if ($streamingType === "shoutcast") {
        if ($historic) {
            $urls[] = $url . "/7.html";
            $urls[] = $url . "/played";
            if ($nextSong) {
                $urls[] = $url . "/nextsong";
            }
            $curl = curl_multi_init();
            foreach ($urls as $key => $value) {
                $ch[$key] = curl_init($value);
                curl_setopt($ch[$key], CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch[$key], CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch[$key], CURLOPT_USERAGENT, "Mozilla/5.0");
                curl_multi_add_handle($curl, $ch[$key]);
            }
            do {
                curl_multi_exec($curl, $running);
                curl_multi_select($curl);
            } while ($running > 0);
            foreach (array_keys($ch) as $key) {
                curl_multi_remove_handle($curl, $ch[$key]);
                $content[] = curl_multi_getcontent($ch[$key]);
            }
            $data = $content[0];
            if ($nextSong) {
                $nextSongName = isset($content[2])
                    ? explode("-", $content[2], 2)
                    : "";
                if (isset($nextSongName[1])) {
                    $array["nextSong"] = [
                        "artist" => $nextSongName[0],
                        "song" => $nextSongName[1],
                    ];
                } else {
                    $array["nextSong"] = [
                        "artist" => "",
                        "song" => $nextSongName[0],
                    ];
                }
            }
            $pagina = str_replace("</td><td>", "<music>", $content[1], $count);
            $playedSongs = explode("<music>", $pagina);
            unset($playedSongs[0]);
            unset($playedSongs[1]);
            unset($playedSongs[2]);
            foreach ($playedSongs as $song) {
                $cutStr = strpos($song, "</td></tr>");
                $playedSong = substr($song, 0, $cutStr);
                $songData = explode("-", $playedSong, 2);
                $songNameHistoric = !empty($songData[1])
                    ? trim($songData[1])
                    : "";
                $array["songHistory"][] = [
                    "artist" => rtrim($songData[0]),
                    "song" => $songNameHistoric,
                ];
            }
            curl_multi_close($curl);
        } else {
            $curl = curl_init($url . "/7.html");
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0");
            $data = curl_exec($curl);
            curl_close($curl);
        }
        if (!empty($data)) {
            $streamingData = explode(",", $data);
            $array["streamingId"] = $streamingData[1];
            $array["listenersMax"] = $streamingData[2];
            $array["listenersPeak"] = $streamingData[3];
            $array["listeners"] = $streamingData[4];
            $array["transmissionFrequency"] = $streamingData[5];
            $playingNow = $streamingData[6];
            if (count($streamingData) > 7) {
                $playingNow = "";
                for ($i = 6; $i < count($streamingData); $i++) {
                    $playingNow .= "," . $streamingData[$i];
                }
            }
            $currentSong = explode("-", $playingNow, 2);
            $artist = trim($currentSong[0]);
            if (substr($currentSong[0], 0, 1) === ",") {
                $artist = substr($currentSong[0], 1, -1);
            }
            if (count($currentSong) === 2) {
                if (substr($currentSong[1], -14) === "</body></html>") {
                    $array["currentSong"] = !empty($currentSong[1])
                        ? trim(substr($currentSong[1], 0, -14))
                        : "...";
                } else {
                    $array["currentSong"] = !empty($currentSong[1])
                        ? $currentSong[1]
                        : "...";
                }
                $array["currentArtist"] = empty($currentSong[1])
                    ? trim(substr($playingNow, 0, -14))
                    : $artist;
            } elseif (count($currentSong) < 2) {
                $array["currentSong"] =
                    empty($playingNow) || $playingNow === "</body></html>"
                        ? "..."
                        : trim(substr($playingNow, 0, -14));
                $array["currentArtist"] = "...";
            } else {
                $array["currentSong"] = trim($currentSong[1]);
                $array["currentArtist"] = trim($artist);
            }
        } else {
            $array = ["error" => "Failed to fetch data"];
        }
    } elseif ($streamingType === "icecast") {
        $porta_admin_icecast = $dados_stm["porta"]+1;
        $url = "http://".$dados_servidor["ip"].":".$porta_admin_icecast."/status-json.xsl?mount=".$ponto;
        $data = file_get_contents($url);
        if (!empty($data)) {
            $ice_stats = json_decode($data, true);

            $array["listenersPeak"] = $ice_stats["icestats"]["source"]["listener_peak"];
            $array["listeners"] = $ice_stats["icestats"]["source"]["listeners"];
            $array["transmissionFrequency"] = $ice_stats["icestats"]["source"]["bitrate"];
            $currently_playing = $ice_stats["icestats"]["source"]["title"];
            $currently_playing = explode(" - ", $currently_playing, 2);
            $array["currentSong"] = ($currently_playing[1]) ? $currently_playing[1] : $ice_stats["icestats"]["source"]["title"];
            $array["currentArtist"] = explode(";", $currently_playing[0])[0];
            $track_history = file("player.log");
            $track_list = array_slice($track_history, 0, 20);
            if (
                stripos(
                    $track_history[0],
                    $currently_playing[0] . " - " . $currently_playing[1]
                ) === false
            ) {
                array_unshift(
                    $track_list,
                    $currently_playing[0] . " - " . $currently_playing[1] . "\n"
                );
                file_put_contents("player.log", $track_list);
            }
        } else {
            $array = ["error" => "Failed to fetch data"];
        }
        $track_history = file("player.log");
        array_shift($track_history);
        if ($historic) {
            $i = 0;
            foreach ($track_history as $line) {
                if ($i > 4) {
                    continue;
                }
                $track = explode(" - ", $line, 2);
                $last_artist = explode(";", $track[0])[0];
                $last_song = str_replace(["\n", "\r"], "", $track[1]);
                $array["songHistory"][] = [
                    "artist" => "$last_artist",
                    "song" => "$last_song",
                ];
                $i++;
            }
        }
    } else {
        $array = ["error" => "STREAM_TYPE parameter not found"];
    }
} else {
    $array = ["error" => "URL parameter not found"];
}
$urlHost = $_SERVER["HTTP_HOST"];
header("Access-Control-Allow-Origin: " . $urlHost);
header("Content-type: application/json", true);
echo json_encode($array);


exit();
}
?>
<!DOCTYPE html>
<html lang="pt-BR">

<head>
    <meta charset="utf-8">
    <title><?php echo $dados_stm["streamtitle"]; ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
    <style>@charset 'utf-8';@import url(https://fonts.googleapis.com/css?family=Share:400i,700i);body,html{height:100%}body{display:flex;flex-flow:row;justify-content:center;overflow-x:hidden}.cover-site{ z-index:-1;min-width:100%;min-height:100%;position:fixed;background:url(/img/img-fundo-player12.jpg) no-repeat;background-position:center;background-size:cover;transition:background-image 1s;background-position:center;background-attachment:fixed}#bgCover{min-width:100%;min-height:100%;position:absolute;background-position:center;background-size:cover;transition:background-image 1s;background-position:center;background-attachment:fixed;z-index:1}.bg-mask{min-width:100%;min-height:100%;position:absolute;background:radial-gradient(rgba(0,0,0,.5) 20%,#000 85%);z-index:2}.web-player{height:100%;color:#fff;padding:5px;position:relative;z-index:3;margin-top:25px}.cover-album{max-width:80%;margin:auto;background:url(/img/img-capa-player12.jpg) no-repeat;background-size:cover;border:1px solid #383838;box-shadow:0 5px 10px 3px rgba(0,0,0,.4);transition:background-image 1s;margin-bottom:15px}.watermark{width:89px;height:35px;}#currentCoverArt{width:100%;height:100%;background-size:cover;background-position:center;background-repeat:no-repeat;transition:background-image 1s}.logo{display:none}.info-current-song{font-family:Share,sans-serif;text-align:center}.info-current-song h2{font-size:22px;font-weight:700}.info-current-song h3{font-size:18px;font-weight:400}.play-pause{font-size:65px}.play-pause i{cursor:pointer}.volume-icon{font-size:28px;margin-top:-5px}.volume-slide{line-height:35px}.volume-control{display:none}.vagalume a{color:#fff;text-decoration:underline}.lyrics{text-transform:uppercase;text-decoration:underline;color:#fff;font-size:1em;font-weight:400;outline:0;transition:.3s}.lyrics:active{text-decoration:none;color:#fff}.lyrics:visited{text-decoration:none;color:#fff}.modal-content{background-color:rgba(0,0,0,.8);color:#fff!important;border-radius:0}.modal-content .btn{border-radius:0}input[type=range]{-webkit-appearance:none;background:0 0;width:100%}input[type=range]:focus{outline:0}input[type=range]::-webkit-slider-runnable-track{width:100%;height:5px;cursor:pointer;animate:.2s;box-shadow:0 0 0 #000,0 0 0 #0d0d0d;background:#fff}input[type=range]::-webkit-slider-thumb{box-shadow:0 0 0 #000,0 0 0 #0d0d0d;height:20px;width:20px;border-radius:50%;background:#fff;cursor:pointer;-webkit-appearance:none;margin-top:-8px}input[type=range]::-moz-range-track{width:100%;height:5px;cursor:pointer;animate:.2s;box-shadow:0 0 0 #000,0 0 0 #0d0d0d;background:#fff}input[type=range]::-moz-range-thumb{box-shadow:0 0 0 #000,0 0 0 #0d0d0d;border:0 solid #000;height:20px;width:20px;border-radius:50%;background:#fff;cursor:pointer}input[type=range]::-ms-track{width:100%;height:5px;cursor:pointer;animate:.2s;background:0 0;border-color:transparent;border-width:10px 0;top:-10px;color:transparent}input[type=range]::-ms-fill-lower{background:#fff;border:0 solid #000101;box-shadow:0 0 0 #000,0 0 0 #0d0d0d}input[type=range]::-ms-fill-upper{background:#fff;border:0 solid #000101;box-shadow:0 0 0 #000,0 0 0 #0d0d0d}input[type=range]::-ms-thumb{box-shadow:0 0 0 #000,0 0 0 #0d0d0d;border:0 solid #000;height:20px;width:20px;border-radius:50%;background:#fff;cursor:pointer}.historic h2{color:#fff;border-bottom:2px solid #fff;font-size:16px;font-weight:700;text-transform:uppercase;margin:10px 0}.historic article{margin:5px 0}.historic .cover-historic{width:95px;height:95px;margin-right:15px;float:left;background:url(/img/img-capa-player12.jpg) no-repeat;background-size:cover;border:1px solid #383838;box-shadow:1px 2px 5px rgba(0,0,0,.3);transition:background-image 1s}.historic .music-info{color:#fff;font-family:Share,sans-serif}.historic .music-info .song{width:100%;font-weight:700;font-size:20px;text-transform:uppercase;margin-bottom:-5px}@media(max-width:370px){.cover-album{max-width:100%}}@media(min-width:576px){.volume-control{display:flex}.call-lyrics{margin-top:20px}}@media(min-width:768px){body{align-items:center}.h1-logo{text-align:center}.logo{display:block;z-index:2}.logo img{max-width:200px}.web-player{height:auto;margin-top:0}.cover-album{margin:10px auto;min-width:320px;height:320px}.logo img{max-width:300px;margin:65px 0}.info-current-song{margin-top:50px;text-align:left}.volume-control{margin-top:10%}}
</style>
</head>

<body>
    <div class="cover-site">
        <div id="bgCover"></div>
        <div class="bg-mask"></div>
    </div>
    <main>
        <section id="player">
            <div class="container">
                <div class="row web-player">
                    <div class="col-12 col-lg-10">
                        <div class="row">
                            <div class="col-12 col-md-5">
                                <div class="cover-album">
                                    <div id="currentCoverArt"></div>
                                    <div class="watermark"></div>
                                </div>
                            </div>
                            <div class="col-12 ml-md-auto col-md-6">
                                <div class="row">
                                    <div class="col-12">
                                        <div class="info-current-song">
                                            <h2 id="currentSong" class="current-song text-uppercase">...</h2>
                                            <h3 id="currentArtist" class="current-artist text-captalize">...</h3>
                                        </div>
                                    </div>
                                    <div class="col-12">
                                        <div class="row">
                                            <div class="play-pause col-12 col-md-2 text-center">
                                                <i id="playerButton" class="fa fa-play" onclick="togglePlay()"></i>
                                            </div>
                                            <div class="col-12 col-md-10 text-center">
                                                <div class="row volume-control">
                                                    <div class="volume-icon col-1"><i class="fa fa-volume-up"></i></div>
                                                    <div class="volume-slide col-10 text-center"><input type="range" id="volume"
                                                            step="1" min="0" max="100" value="80"></div>
                                                    <div class="percentual-volume col-12">Volume <span id="volIndicator">...</span>%</div>
                                                </div>
                                            </div>
                                            <div class="col-12 text-center call-lyrics">
                                                <a href="#" class="lyrics" style="" data-target="#modalLyrics">Lyrics</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row historic">
                    <div class="col-12">
                        <h2>Recently Played</h2>
                        <div class="row" id="historicSong">
                            <article class="col-12 col-md-6">
                                <div class="cover-historic"></div>
                                <div class="music-info">
                                    <div class="song">...</div>
                                    <div class="artist">...</div>
                                </div>
                            </article>
                            <article class="col-12 col-md-6">
                                <div class="cover-historic"></div>
                                <div class="music-info">
                                    <div class="song">...</div>
                                    <div class="artist">...</div>
                                </div>
                            </article>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>
    <div class="modal fade" id="modalLyrics" tabindex="-1" role="dialog" aria-labelledby="lyricsSong" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="lyricsSong">Lyric</h5>
                    <button type="button" style="color: #fff" class="close" data-dismiss="modal" aria-label="Fechar">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="vagalume text-center"><a href="https://www.vagalume.com.br/" target="_blank" rel="noopener"><img
                            src="/img/img-logo-vagalume.jpg" class="" /></a><br />Powered by <a href="https://www.vagalume.com.br/"
                        target="_blank" rel="noopener">Vagalume</a></div>
                <div class="modal-body" id="lyric"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
    <script>var settings={radio_name:'<?php echo $dados_stm["streamtitle"]; ?>',url_streaming:"<?php echo $url_streaming; ?>",streaming_type:"<?php echo $dados_stm["tipo_servidor"];?>",api_key:"18fe07917957c289983464588aabddfb",historic:true,next_song:false,default_cover_art:"/img/img-capa-player12.jpg"};
const RADIO_NAME=settings.radio_name,URL_STREAMING=settings.url_streaming,STREAMING_TYPE=settings.streaming_type,API_KEY=settings.api_key,HISTORIC=settings.historic,NEXT_SONG=settings.next_song,DEFAULT_COVER_ART=settings.default_cover_art;function Page(){this.changeTitlePage=function(e=RADIO_NAME){document.title=e},this.refreshCurrentSong=function(e,t){var a=document.getElementById("currentSong"),o=document.getElementById("currentArtist");e!==a.innerHTML&&(a.className="animated flipInY text-uppercase",a.innerHTML=e,o.className="animated flipInY text-capitalize",o.innerHTML=t,document.getElementById("lyricsSong").innerHTML=e+" - "+t,setTimeout(function(){a.className="text-uppercase",o.className="text-capitalize"},2e3))},this.refreshHistoric=function(e,t){var a=document.querySelectorAll("#historicSong article"),o=document.querySelectorAll("#historicSong article .music-info .song"),n=document.querySelectorAll("#historicSong article .music-info .artist"),i=DEFAULT_COVER_ART,r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===this.readyState&&200===this.status){var r=JSON.parse(this.responseText),s=r.resultCount?r.results[0].artworkUrl100:i;document.querySelectorAll("#historicSong article .cover-historic")[t].style.backgroundImage="url("+s+")"}var u=e.song.replace(/&apos;/g,"'").replace(/&amp;/g,"&"),l=e.artist.replace(/&apos;/g,"'").replace(/&amp;/g,"&");o[t].innerHTML=u,n[t].innerHTML=l,a[t].classList.add("animated"),a[t].classList.add("slideInRight")},r.open("GET","https://itunes.apple.com/search?term="+e.artist+"&media=music&limit=1",!0),r.send(),setTimeout(function(){for(var e=0;e<2;e++)a[e].classList.remove("animated"),a[e].classList.remove("slideInRight")},2e3)},this.refreshCover=function(e="",t){var a=DEFAULT_COVER_ART,o=new XMLHttpRequest;o.onreadystatechange=function(){var o=document.getElementById("currentCoverArt"),n=document.getElementById("bgCover");if(4===this.readyState&&200===this.status){var i=JSON.parse(this.responseText),r=i.resultCount?i.results[0].artworkUrl100:a;a=r!=a?r.replace("100x100bb","512x512bb"):a;var s=r!=a?a.replace("512x512bb","96x96bb"):a,u=r!=a?a.replace("512x512bb","128x128bb"):a,l=r!=a?a.replace("512x512bb","192x192bb"):a,c=r!=a?a.replace("512x512bb","256x256bb"):a,m=r!=a?a.replace("512x512bb","384x384bb"):a;o.style.backgroundImage="url("+a+")",o.className="animated bounceInLeft",n.style.backgroundImage="url("+a+")",setTimeout(function(){o.className=""},2e3),"mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata({title:e,artist:t,artwork:[{src:s,sizes:"96x96",type:"image/png"},{src:u,sizes:"128x128",type:"image/png"},{src:l,sizes:"192x192",type:"image/png"},{src:c,sizes:"256x256",type:"image/png"},{src:m,sizes:"384x384",type:"image/png"},{src:a,sizes:"512x512",type:"image/png"}]}))}},o.open("GET","https://itunes.apple.com/search?term="+t+"&media=music&limit=1",!0),o.send()},this.changeVolumeIndicator=function(e){document.getElementById("volIndicator").innerHTML=e,"undefined"!=typeof Storage&&localStorage.setItem("volume",e)},this.setVolume=function(){if("undefined"!=typeof Storage){var e=localStorage.getItem("volume")?localStorage.getItem("volume"):80;document.getElementById("volume").value=e,document.getElementById("volIndicator").innerHTML=e}},this.refreshLyric=function(e,t){var a=new XMLHttpRequest;a.onreadystatechange=function(){if(4===this.readyState&&200===this.status){var e=JSON.parse(this.responseText),t=document.getElementsByClassName("lyrics")[0];if("exact"===e.type||"aprox"===e.type){var a=e.mus[0].text;document.getElementById("lyric").innerHTML=a.replace(/\n/g,"<br />"),t.style.opacity="1",t.setAttribute("data-toggle","modal")}else{t.style.opacity="0.3",t.removeAttribute("data-toggle");var o=document.getElementById("modalLyrics");o.style.display="none",o.setAttribute("aria-hidden","true"),document.getElementsByClassName("modal-backdrop")[0]&&document.getElementsByClassName("modal-backdrop")[0].remove()}}else document.getElementsByClassName("lyrics")[0].style.opacity="0.3",document.getElementsByClassName("lyrics")[0].removeAttribute("data-toggle")},a.open("GET","https://api.vagalume.com.br/search.php?apikey="+API_KEY+"&art="+t+"&mus="+e.toLowerCase(),!0),a.send()}}window.onload=function(){var e=new Page;e.changeTitlePage(),e.setVolume(),(new Player).play(),getStreamingData(),setInterval(function(){getStreamingData()},4e3);var t=document.getElementsByClassName("cover-album")[0];t.style.height=t.offsetWidth+"px"};var audio=new Audio(URL_STREAMING+"<?php echo $ponto; ?>");function Player(){this.play=async function(){await audio.play();var e=document.getElementById("volume").value;"undefined"!=typeof Storage&&null!==localStorage.getItem("volume")?audio.volume=intToDecimal(localStorage.getItem("volume")):audio.volume=intToDecimal(e),document.getElementById("volIndicator").innerHTML=e},this.pause=function(){audio.pause()}}function togglePlay(){audio.paused?(audio.load(),audio.play()):audio.pause()}function volumeUp(){var e=audio.volume;audio&&audio.volume>=0&&audio.volume<1&&(audio.volume=(e+.01).toFixed(2))}function volumeDown(){var e=audio.volume;audio&&audio.volume>=.01&&audio.volume<=1&&(audio.volume=(e-.01).toFixed(2))}function mute(){if(audio.muted){var e=localStorage.getItem("volume");document.getElementById("volIndicator").innerHTML=e,document.getElementById("volume").value=e,audio.volume=intToDecimal(e),audio.muted=!1}else document.getElementById("volIndicator").innerHTML=0,document.getElementById("volume").value=0,audio.volume=0,audio.muted=!0}function getStreamingData(){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(4===this.readyState&&200===this.status){0===this.response.length&&console.log("%cdebug","font-size: 22px");var e=JSON.parse(this.responseText),t=new Page;let o=document.getElementById("currentSong").innerHTML.replace(/&apos;/g,"'").replace(/&amp;/g,"&"),n=e.currentSong.replace(/&apos;/g,"'").replace(/&amp;/g,"&"),i=e.currentArtist.replace(/&apos;/g,"'").replace(/&amp;/g,"&");if(i=i.replace("  "," "),document.title=n+" - "+i+" | "+RADIO_NAME,o.trim()!==n.trim()){t.refreshCover(n,i),t.refreshCurrentSong(n,i),t.refreshLyric(n,i);for(var a=0;a<2;a++)t.refreshHistoric(e.songHistory[a],a)}}};var t=new Date;e.open("GET","?url="+URL_STREAMING+"&streamtype="+STREAMING_TYPE+"&historic="+HISTORIC+"&next="+NEXT_SONG+"&t="+t.getTime(),!0),e.send()}function intToDecimal(e){return e/100}function decimalToInt(e){return 100*e}audio.onplay=function(){var e=document.getElementById("playerButton");"fa fa-play"===e.className&&(e.className="fa fa-pause")},audio.onpause=function(){var e=document.getElementById("playerButton");"fa fa-pause"===e.className&&(e.className="fa fa-play")},audio.onvolumechange=function(){audio.volume>0&&(audio.muted=!1)},audio.onerror=function(){alert("Radio Offline.\nRadio sin conexión.")},document.getElementById("volume").oninput=function(){audio.volume=intToDecimal(this.value),(new Page).changeVolumeIndicator(this.value)},document.addEventListener("keydown",function(e){var t=(e=e||window.event).keyCode||e.which,a=document.getElementById("volume"),o=new Page;switch(t){case 38:volumeUp(),a.value=decimalToInt(audio.volume),o.changeVolumeIndicator(decimalToInt(audio.volume));break;case 40:volumeDown(),a.value=decimalToInt(audio.volume),o.changeVolumeIndicator(decimalToInt(audio.volume));break;case 32:case 80:togglePlay();break;case 77:mute();break;case 48:case 96:audio.volume=0,a.value=0,o.changeVolumeIndicator(0);break;case 49:case 97:audio.volume=.1,a.value=10,o.changeVolumeIndicator(10);break;case 50:case 98:audio.volume=.2,a.value=20,o.changeVolumeIndicator(20);break;case 51:case 99:audio.volume=.3,a.value=30,o.changeVolumeIndicator(30);break;case 52:case 100:audio.volume=.4,a.value=40,o.changeVolumeIndicator(40);break;case 53:case 101:audio.volume=.5,a.value=50,o.changeVolumeIndicator(50);break;case 54:case 102:audio.volume=.6,a.value=60,o.changeVolumeIndicator(60);break;case 55:case 103:audio.volume=.7,a.value=70,o.changeVolumeIndicator(70);break;case 56:case 104:audio.volume=.8,a.value=80,o.changeVolumeIndicator(80);break;case 57:case 105:audio.volume=.9,a.value=90,o.changeVolumeIndicator(90)}});
    </script>
</body>

</html>