mirror of
https://github.com/LaQuay/TDTChannels.git
synced 2024-11-22 17:03:24 +01:00
Audio with PLS player
This commit is contained in:
parent
6fb7e7bc78
commit
90024b3e20
2 changed files with 75 additions and 4 deletions
|
@ -51,9 +51,9 @@
|
|||
Resoluciones disponibles
|
||||
<br>
|
||||
<em id="video-resolution"></em>
|
||||
<p id="extra-video-info" style="display: block"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="audio" style="margin-top: 15px">
|
||||
<p class="lead">
|
||||
Reproductor de Radio
|
||||
|
@ -74,7 +74,20 @@
|
|||
<p class="lead">Información de la reproducción</p>
|
||||
Formatos soportados
|
||||
<br>
|
||||
<em>aac</em>, <em>mp3</em>, <em>nsv</em>, <em>audio/mpeg</em>
|
||||
<em>aac</em>, <em>mp3</em>, <em>nsv</em>, <em>audio/mpeg</em>, <em>pls</em>(Beta)
|
||||
|
||||
<div id="extra-audio-info-div" style="display: none; padding-top: 20px">
|
||||
<button class="btn btn-secondary" type="button" data-toggle="collapse"
|
||||
data-target="#collapseAlternativas"
|
||||
aria-expanded="false" aria-controls="collapseAlternativas">
|
||||
URLs alternativas
|
||||
</button>
|
||||
<div class="collapse" id="collapseAlternativas">
|
||||
<div class="card card-body">
|
||||
<p id="extra-audio-info"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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] + "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("extra-audio-info").innerHTML = textToAdd;
|
||||
document.getElementById("extra-audio-info-div").style.display = "block";
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// 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);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue