diff --git a/script/public/index.html b/script/public/index.html index 26b82d8a..bb14d42a 100644 --- a/script/public/index.html +++ b/script/public/index.html @@ -51,9 +51,9 @@ Resoluciones disponibles
+

-

Reproductor de Radio @@ -74,7 +74,20 @@

Información de la reproducción

Formatos soportados
- aac, mp3, nsv, audio/mpeg + aac, mp3, nsv, audio/mpeg, pls(Beta) + +
@@ -140,8 +153,15 @@ } function reproduceAudio(channelToReproduce) { - console.log("Reproducing audio: " + channelToReproduce); + if (channelToReproduce.includes("pls")) { + getURLsFromPLS(channelToReproduce, reproducePLSFromUrl); + } else { + reproduceAudioFromUrl(channelToReproduce); + } + } + function reproduceAudioFromUrl(channelToReproduce) { + console.log("Reproducing audio: " + channelToReproduce); var audioSource = document.getElementById('audio-controller'); var audioPlayer = document.getElementById('audio-player'); @@ -160,6 +180,11 @@ } } + function reproducePLSFromUrl(data) { + reproduceAudioFromUrl(data[0]); + updateExtraAudioInfo("pls_more_url_available", data); + } + function updateResolution(resolutions) { console.log("Resoluciones: " + resolutions); @@ -176,6 +201,21 @@ document.getElementById("video-resolution").innerHTML = ""; } + function updateExtraAudioInfo(type, data) { + console.log("Extra info type: " + type); + console.log("Extra info data: " + data); + + var textToAdd = ""; + if (type == "pls_more_url_available") { + for (i = 0; i < data.length; i++) { + textToAdd += data[i] + "
"; + } + } + + document.getElementById("extra-audio-info").innerHTML = textToAdd; + document.getElementById("extra-audio-info-div").style.display = "block"; + } + \ No newline at end of file diff --git a/script/public/index.js b/script/public/index.js index 48b31634..9ed2a861 100644 --- a/script/public/index.js +++ b/script/public/index.js @@ -1,3 +1,26 @@ +function getURLsFromPLS(sUrl, fn_callback) { + var from = "http://provisioning.streamtheworld.com/pls/CADENADIAL.pls"; + $.get(from, function(data) { + $response = data.split("\n"); + + $urls=[]; + $.each($response, function( index, value ) { + $line_separated_value = value.split("="); + if ($line_separated_value.length > 1 && $line_separated_value[1].indexOf("http") != -1) { + $urls.push($line_separated_value[1]); + } + }); + fn_callback($urls) + + //$.each($urls, function( index, value ) { + // if (checkIfWebsiteWorks(value)) { + // fn_callback(value); + // break; + // } + //}); + }); +}; + function getResolution(from, fn_callback) { $.get(from, function(data) { $response = data.split("\n"); @@ -29,4 +52,12 @@ function getUrlParameter(sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } -}; \ No newline at end of file +}; + +// Check an URL is valid or broken +// TODO: For streams if it works it keeps loading infinite time +function checkIfWebsiteWorks(sUrl){ + $.get(sUrl, function(data, status){ + alert("Data: " + data + "\nStatus: " + status); + }); +} \ No newline at end of file