52 lines
3.6 KiB
HTML
52 lines
3.6 KiB
HTML
<!doctype html>
|
|
<html lang="es"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>OrbiSubs prueba</title>
|
|
<style>body{background:#111;color:#ddd;font-family:sans-serif;margin:16px}video{width:100%;max-width:960px}
|
|
#info{font-size:13px;color:#999;margin-top:8px}select,input{font-size:14px}</style></head>
|
|
<body>
|
|
<h3>OrbiSubs — subtítulos en vivo (prueba)</h3>
|
|
<input id="u" size="50" value="/hls/t13/master.m3u8"> <button onclick="cargar()">Cargar</button>
|
|
<label> Subtítulos <select id="s"><option value="-1">Apagados</option></select></label>
|
|
<div><video id="v" controls muted autoplay playsinline></video></div>
|
|
<div id="info"></div>
|
|
<div id="diag" style="font-size:12px;color:#777"></div>
|
|
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.20/dist/hls.min.js"></script>
|
|
<script>
|
|
let hls;
|
|
// ?u=/hls/<canal>/master.m3u8 elige el canal (lo usan los enlaces del panel, tarea 079).
|
|
const qu=new URLSearchParams(location.search).get('u'); if(qu&&/^\/hls\/[a-z0-9-]+\/master\.m3u8$/.test(qu)) document.getElementById('u').value=qu;
|
|
function cargar(){
|
|
const v=document.getElementById('v'), s=document.getElementById('s');
|
|
if(hls) hls.destroy();
|
|
// Colchón al borde: el HOLD-BACK que publica OrbiSubs en video.m3u8 (panel, tarea 081);
|
|
// sin él, los 3 segmentos de hls.js. ?sync=S lo fija a mano (pruebas).
|
|
const sync=+new URLSearchParams(location.search).get('sync');
|
|
// hls.js toma el HOLD-BACK como objetivo pero arranca más atrás y no se acerca solo
|
|
// (medido en la 081: objetivo 12 s, quedaba en 18): con hasta 1,1x de velocidad converge.
|
|
// Tras un corte largo de la fuente (CDN de T13, 65 s el 2026-11-17 17:37) el player quedaba
|
|
// un minuto atrás y a 1,1x tardaba ~10 min en volver: con más de 6 segmentos de atraso salta al vivo.
|
|
hls=new Hls(sync>0?{liveSyncDuration:sync,liveMaxLatencyDuration:sync+12,maxLiveSyncPlaybackRate:1.1}:{maxLiveSyncPlaybackRate:1.1,liveMaxLatencyDurationCount:6});
|
|
// Recuperación estándar de hls.js: el CDN de origen mete cortes de PTS en las tandas
|
|
// y el decoder del navegador a veces se cae ahí (visto con Chromium, 2026-11-16).
|
|
hls.on(Hls.Events.ERROR,(e,d)=>{ if(!d.fatal) return;
|
|
if(d.type===Hls.ErrorTypes.MEDIA_ERROR) hls.recoverMediaError(); else hls.startLoad(); });
|
|
hls.loadSource(document.getElementById('u').value); hls.attachMedia(v);
|
|
hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED,()=>{
|
|
s.innerHTML='<option value="-1">Apagados</option>'+hls.subtitleTracks.map((t,i)=>`<option value="${i}">${t.name}</option>`).join('');
|
|
// Arranca en la pista pedida por ?lang=en (o en español).
|
|
const q=new URLSearchParams(location.search).get('lang')||'es';
|
|
const i=Math.max(0,hls.subtitleTracks.findIndex(t=>t.lang===q));
|
|
s.value=i; hls.subtitleTrack=i; hls.subtitleDisplay=true;
|
|
});
|
|
s.onchange=()=>{hls.subtitleTrack=+s.value; hls.subtitleDisplay=+s.value>=0;};
|
|
// Diagnóstico: cuántos cues cargó la pista y cuál está en pantalla (sirve para
|
|
// probar con un navegador headless que el texto llega y en qué tiempo del video).
|
|
setInterval(()=>{const t=[...v.textTracks].find(x=>x.mode==='showing');
|
|
const act=t&&t.activeCues&&t.activeCues.length?[...t.activeCues].map(c=>c.text.replace(/\n/g,' ')).join(' / '):'';
|
|
document.getElementById('diag').textContent=`t=${v.currentTime.toFixed(1)} pistas=${v.textTracks.length} cues=${t&&t.cues?t.cues.length:0} activo=[${act}]`;},500);
|
|
setInterval(()=>{const l=hls.latency; document.getElementById('info').textContent=
|
|
'Retraso al borde de la lista publicada: '+(l?l.toFixed(1):'?')+' s';},1000);
|
|
}
|
|
cargar();
|
|
</script></body></html>
|