1
0
Fork 0
mirror of https://github.com/LaQuay/TDTChannels.git synced 2024-11-23 09:23:24 +01:00
TDTChannels/script/public/index.html

170 lines
6.6 KiB
HTML
Raw Normal View History

2018-09-22 19:28:28 +02:00
<html>
<head>
2018-12-09 17:29:49 +01:00
<meta charset="utf-8"/>
2018-12-09 17:46:04 +01:00
<title>TDT Channels - Marc Vila</title>
2018-09-22 19:28:28 +02:00
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
2018-12-13 16:11:47 +01:00
<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>
2018-12-09 09:00:47 +01:00
2018-12-13 16:11:47 +01:00
<script src="./index.js"></script>
2018-12-09 09:00:47 +01:00
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2018-09-22 19:28:28 +02:00
</head>
<body>
2018-12-09 09:00:47 +01:00
<div class="container" style="margin-top: 30px; margin-bottom: 30px">
2018-12-09 01:15:31 +01:00
<h1 class="display-3">TDTChannels</h1>
<p class="lead">
Bienvenido al reproductor del proyecto opensource TDTChannels
</p>
<br>
<a class="btn btn-outline-secondary" role="button" href="https://github.com/LaQuay/TDTChannels"
target="_blank">Repositorio TDT Channels</a>
<a class="btn btn-outline-success" role="button" href="http://www.marcvila.me/"
target="_blank">Sitio personal</a>
<a class="btn btn-outline-warning" role="button" href="https://github.com/LaQuay/"
target="_blank">GitHub</a>
<a class="btn btn-outline-primary" role="button" href="https://www.linkedin.com/in/marcvilagomez/"
target="_blank">LinkedIn</a>
2018-12-09 08:54:29 +01:00
<div style="margin-top: 25px">
2018-12-09 01:15:31 +01:00
<div id="video">
<p class="lead">
Reproductor de Televisión
</p>
2018-12-13 16:11:47 +01:00
2018-12-09 09:00:47 +01:00
<div class="input-group mb-3">
2018-12-09 01:15:31 +01:00
<input id="input-reproduccion-video" type="text" class="form-control" placeholder="URL de reproducción">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="button-reproduccion-video"
onclick="loadItem('video');">Cargar
</button>
</div>
</div>
2018-12-09 09:00:47 +01:00
<div id="video-player"></div>
2018-12-13 16:11:47 +01:00
<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>
2018-12-09 01:15:31 +01:00
</div>
2018-12-09 08:54:29 +01:00
<div id="audio" style="margin-top: 15px">
2018-12-09 01:15:31 +01:00
<p class="lead">
Reproductor de Radio
</p>
2018-12-09 09:00:47 +01:00
<div class="input-group mb-3">
2018-12-09 01:15:31 +01:00
<input id="input-reproduccion-audio" type="text" class="form-control" placeholder="URL de reproducción">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="button-reproduccion-audio"
onclick="loadItem('audio');">Cargar
</button>
</div>
</div>
<audio id="audio-controller" controls>
2018-12-09 09:00:47 +01:00
<source id="audio-player" src="" autoplay>
2018-12-09 01:15:31 +01:00
Your browser does not support the audio element.
</audio>
2018-12-13 16:11:47 +01:00
<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>
2018-12-09 01:15:31 +01:00
</div>
</div>
</div>
2018-09-22 19:28:28 +02:00
<script>
2018-12-09 08:54:29 +01:00
// Se espera en la URL este tipo de llamada
// .html?type={audio,video}&channel={url_a_reproducir}
2018-12-09 17:15:22 +01:00
var player;
2018-12-09 08:54:29 +01:00
var typeToReproduce = getUrlParameter("type");
var channelToReproduce;
if (typeToReproduce == "audio") {
channelToReproduce = getUrlParameter("channel");
reproduceAudio(channelToReproduce);
} else if (typeToReproduce == "video") {
channelToReproduce = getUrlParameter("channel");
reproduceVideo(channelToReproduce);
}
2018-12-09 01:15:31 +01:00
function loadItem(from) {
var value;
if (from == "audio") {
value = document.getElementById("input-reproduccion-audio").value;
reproduceAudio(value);
} else if (from == "video") {
value = document.getElementById("input-reproduccion-video").value;
reproduceVideo(value);
}
}
function reproduceVideo(channelToReproduce) {
console.log("Reproducing " + channelToReproduce);
if (channelToReproduce.includes("m3u8")) {
console.log("Reproducing video")
2018-12-09 17:15:22 +01:00
var divInfo = document.getElementById("video-player").childElementCount;
if (divInfo == 0) {
player = new Clappr.Player({
source: channelToReproduce,
parentId: '#video-player',
height: '400px',
width: '100%',
autoPlay: true,
});
} else {
// Assume player instance is already created
player.configure({
source: channelToReproduce,
});
}
2018-12-13 16:11:47 +01:00
getResolution(channelToReproduce);
2018-12-09 01:15:31 +01:00
}
}
function reproduceAudio(channelToReproduce) {
console.log("Reproducing " + channelToReproduce);
if (channelToReproduce.includes("nsv")) {
console.log("Reproducing audio")
var audioSource = document.getElementById('audio-controller');
var audioPlayer = document.getElementById('audio-player');
audioPlayer.src = channelToReproduce;
audioSource.load();
audioSource.pause();
var playPromise = audioSource.play();
if (playPromise !== undefined) {
playPromise.then(function() {
// Automatic playback started!
}).catch(function(error) {
// Automatic playback failed.
// Show a UI element to let the user manually start playback.
});
}
}
}
2018-09-22 19:28:28 +02:00
2018-12-13 16:11:47 +01:00
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;
}
}
2018-09-22 19:28:28 +02:00
</script>
</body>
</html>