diff --git a/script/public/index.html b/script/public/index.html index 1695b85e..77e7d38c 100644 --- a/script/public/index.html +++ b/script/public/index.html @@ -3,18 +3,12 @@ <meta charset="utf-8"/> <title>TDT Channels - Marc Vila</title> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script> - <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" - integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> - <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" - integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" - crossorigin="anonymous"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" - integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" - crossorigin="anonymous"></script> - <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" - integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" - crossorigin="anonymous"></script> + <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> + <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> + <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> + <script src="./index.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> @@ -37,7 +31,7 @@ <p class="lead"> Reproductor de Televisión </p> - <p>Formatos soportados: <em>m3u8</em></p> + <div class="input-group mb-3"> <input id="input-reproduccion-video" type="text" class="form-control" placeholder="URL de reproducción"> <div class="input-group-append"> @@ -47,13 +41,22 @@ </div> </div> <div id="video-player"></div> + <div id="video-information" class="shadow-sm p-3 mb-5 bg-white rounded" style="margin-top: 15px"> + <p class="lead">Información de la reproducción</p> + Formatos soportados + <br> + <em>m3u8</em> + <br><br> + Resoluciones disponibles + <br> + <em id="video-resolution"></em> + </div> </div> <div id="audio" style="margin-top: 15px"> <p class="lead"> Reproductor de Radio </p> - <p>Formatos soportados: <em>nsv</em></p> <div class="input-group mb-3"> <input id="input-reproduccion-audio" type="text" class="form-control" placeholder="URL de reproducción"> <div class="input-group-append"> @@ -66,28 +69,18 @@ <source id="audio-player" src="" autoplay> Your browser does not support the audio element. </audio> + <div id="audio-information" class="shadow-sm p-3 mb-5 bg-white rounded" style="margin-top: 15px"> + <p class="lead">Información de la reproducción</p> + Formatos soportados + <br> + <em>nsv</em> + </div> </div> </div> </div> <script> // Se espera en la URL este tipo de llamada // .html?type={audio,video}&channel={url_a_reproducir} - - var getUrlParameter = function getUrlParameter(sParam) { - var sPageURL = decodeURIComponent(window.location.search.substring(1)), - sURLVariables = sPageURL.split('&'), - sParameterName, - i; - - for (i = 0; i < sURLVariables.length; i++) { - sParameterName = sURLVariables[i].split('='); - - if (sParameterName[0] === sParam) { - return sParameterName[1] === undefined ? true : sParameterName[1]; - } - } - }; - var player; var typeToReproduce = getUrlParameter("type"); @@ -130,6 +123,8 @@ source: channelToReproduce, }); } + + getResolution(channelToReproduce); } } @@ -158,6 +153,18 @@ } } + function updateResolution(resolutions) { + console.log("Resoluciones: " + resolutions); + document.getElementById("video-resolution").innerHTML = ""; + for (i = 0; i < resolutions.length; i++) { + var resolutionToAdd = resolutions[i]; + if (i < resolutions.length - 1){ + resolutionToAdd += ", "; + } + document.getElementById("video-resolution").innerHTML += resolutionToAdd; + } + } + </script> </body> </html> \ No newline at end of file diff --git a/script/public/index.js b/script/public/index.js new file mode 100644 index 00000000..e1e2dd13 --- /dev/null +++ b/script/public/index.js @@ -0,0 +1,33 @@ +function getResolution(from) { + $.get(from, function(data) { + $response = data.split("\n"); + + $resolutions=[]; + $.each($response, function( index, value ) { + $line_separated_value = value.split(","); + for (i = 0; i < $line_separated_value.length; i++) { + if ($line_separated_value[i].indexOf("RESOLUTION=") != -1) { + $resolutions.push($line_separated_value[i].split('=')[1]); + } + } + }); + + // TODO: This should be a Callback + updateResolution($resolutions); + }); +} + +function getUrlParameter(sParam) { + var sPageURL = decodeURIComponent(window.location.search.substring(1)), + sURLVariables = sPageURL.split('&'), + sParameterName, + i; + + for (i = 0; i < sURLVariables.length; i++) { + sParameterName = sURLVariables[i].split('='); + + if (sParameterName[0] === sParam) { + return sParameterName[1] === undefined ? true : sParameterName[1]; + } + } +}; \ No newline at end of file