1
0
Fork 0
mirror of https://github.com/LaQuay/TDTChannels.git synced 2025-04-23 01:20:01 +02:00

Add information to video

This commit is contained in:
Marc 2018-12-13 16:11:47 +01:00
parent 08694e67c9
commit 9c55d849e6
2 changed files with 69 additions and 29 deletions
script/public

View file

@ -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>

33
script/public/index.js Normal file
View file

@ -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];
}
}
};