diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/video-player.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/video-player.js | 37 |
1 files changed, 9 insertions, 28 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 3bb9124..1522539 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/video-player.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/video-player.js @@ -113,7 +113,15 @@ function audioTrackLabel(track) { function subtitleTrackLabel(track) { const name = _languageName(track.lang) || t('video.subtitle_track_n', { n: track.i + 1 }); - return track.title ? `${name} — ${track.title}` : name; + // The disposition wins over the container's title, and is translated, so a + // forced track reads as one in the viewer's own language rather than as the + // English word a muxer happened to type — or as nothing at all, which is + // what a forced track with no title tag looked like. + const kind = track.forced ? t('video.subtitles_forced') + : track.sdh ? t('video.subtitles_sdh') + : null; + const detail = kind || track.title; + return detail ? `${name} — ${detail}` : name; } function _mseSupported(codec) { @@ -1159,33 +1167,6 @@ 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(() => { |