1
0
Fork 0
mirror of https://github.com/LaQuay/TDTChannels.git synced 2024-11-26 18:54:57 +01:00

Fix multiple instance of video

This commit is contained in:
Marc 2018-12-09 17:15:22 +01:00
parent f69c5b6b99
commit 5aa3d6da56

View file

@ -35,7 +35,7 @@
<p class="lead"> <p class="lead">
Reproductor de Televisión Reproductor de Televisión
</p> </p>
<p>Formatos soportado: <em>m3u8</em></p> <p>Formatos soportados: <em>m3u8</em></p>
<div class="input-group mb-3"> <div class="input-group mb-3">
<input id="input-reproduccion-video" type="text" class="form-control" placeholder="URL de reproducción"> <input id="input-reproduccion-video" type="text" class="form-control" placeholder="URL de reproducción">
<div class="input-group-append"> <div class="input-group-append">
@ -51,7 +51,7 @@
<p class="lead"> <p class="lead">
Reproductor de Radio Reproductor de Radio
</p> </p>
<p>Formatos soportado: <em>nsv</em></p> <p>Formatos soportados: <em>nsv</em></p>
<div class="input-group mb-3"> <div class="input-group mb-3">
<input id="input-reproduccion-audio" type="text" class="form-control" placeholder="URL de reproducción"> <input id="input-reproduccion-audio" type="text" class="form-control" placeholder="URL de reproducción">
<div class="input-group-append"> <div class="input-group-append">
@ -70,6 +70,7 @@
<script> <script>
// Se espera en la URL este tipo de llamada // Se espera en la URL este tipo de llamada
// .html?type={audio,video}&channel={url_a_reproducir} // .html?type={audio,video}&channel={url_a_reproducir}
var getUrlParameter = function getUrlParameter(sParam) { var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)), var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'), sURLVariables = sPageURL.split('&'),
@ -84,6 +85,9 @@
} }
} }
}; };
var player;
var typeToReproduce = getUrlParameter("type"); var typeToReproduce = getUrlParameter("type");
var channelToReproduce; var channelToReproduce;
if (typeToReproduce == "audio") { if (typeToReproduce == "audio") {
@ -109,13 +113,21 @@
console.log("Reproducing " + channelToReproduce); console.log("Reproducing " + channelToReproduce);
if (channelToReproduce.includes("m3u8")) { if (channelToReproduce.includes("m3u8")) {
console.log("Reproducing video") console.log("Reproducing video")
var player = new Clappr.Player({ var divInfo = document.getElementById("video-player").childElementCount;
source: channelToReproduce, if (divInfo == 0) {
parentId: '#video-player', player = new Clappr.Player({
height: '400px', source: channelToReproduce,
width: '100%', parentId: '#video-player',
autoPlay: true, height: '400px',
}); width: '100%',
autoPlay: true,
});
} else {
// Assume player instance is already created
player.configure({
source: channelToReproduce,
});
}
} }
} }