diff options
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/video-player.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/video-player.js b/packages/meshbay-hub/src/meshbay_hub/static/video-player.js index 596a848..3bb9124 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/video-player.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/video-player.js @@ -1159,6 +1159,33 @@ function VideoPlayer({ entry, transportRef, gekRef, onClose, onDownload }) { 'mode =', v.textTracks[0] && v.textTracks[0].mode, 'cues =', v.textTracks[0] && v.textTracks[0].cues ? v.textTracks[0].cues.length : 'none'); + if (!subtitleUrl) return; + // The state above is a single instant, and every part of it can be right + // there and wrong a second later: a re-render can replace the <track>, + // which resets the mode nothing would set again. What decides whether a + // subtitle is on screen is `activeCues`, and that is the one number no + // log has ever carried. Sampled for ten seconds, with the cue that ought + // to be showing at this instant, so "none active" and "active but not + // painted" stop being the same observation. + let n = 0; + const probe = setInterval(() => { + const tt = v.textTracks[0]; + if (!tt) { console.log('[MeshBay] subtitle probe: the track is gone'); return; } + const cues = tt.cues ? Array.from(tt.cues) : []; + const now = v.currentTime; + const should = cues.find((c) => c.startTime <= now && c.endTime >= now); + console.log('[MeshBay] subtitle probe', ++n, + 't =', now.toFixed(1), 'mode =', tt.mode, + 'cues =', cues.length, + 'active =', tt.activeCues ? tt.activeCues.length : 'null', + 'due here =', should ? `[${should.startTime.toFixed(1)}-` + + `${should.endTime.toFixed(1)}] ${should.text.slice(0, 40)}` : 'none', + 'first/last =', cues.length + ? `${cues[0].startTime.toFixed(1)}..${cues[cues.length - 1].endTime.toFixed(1)}` + : '-'); + if (n >= 5) clearInterval(probe); + }, 2000); + return () => clearInterval(probe); }, [subtitleUrl]); useEffect(() => { |