Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

3.4 Subtitles

Bernd Backhaus edited this page Sep 19, 2019 · 11 revisions

NOTE: THE FP6 subtitle parser expects caption titles/numbers (like the 1, 2 etc in https://flowplayer.org/docs/subtitles.html#vtt-file-format ) to be present. If you experience problems with captions not closing, please implement this custom parser (or add titles):

<script> flowplayer.conf.subtitleParser = function(txt) { var TIMECODE_RE = /^(([0-9]{2}:){1,2}[0-9]{2}[,.][0-9]{3}) --\> (([0-9]{2}:){1,2}[0-9]{2}[,.][0-9]{3})(.*)/; function seconds(timecode) { var els = timecode.split(':'); if (els.length == 2) els.unshift(0); return els[0] * 60 * 60 + els[1] * 60 + parseFloat(els[2].replace(',','.')); } var entries = []; for (var i = 0, lines = txt.split("\n"), len = lines.length, entry = {}, title, timecode, text, cue; i < len; i++) { timecode = TIMECODE_RE.exec(lines[i]); if (timecode) { // title title = lines[i - 1] || (entries.length + 1); // text text = "<p>" + lines[++i] + "</p><br/>"; while (typeof lines[++i] === 'string' && lines[i].trim() && i < lines.length) text += "<p>" + lines[i] + "</p><br/>"; // entry entry = { title: title, startTime: seconds(timecode[1]), endTime: seconds(timecode[3]), text: text }; entries.push(entry); } } return entries; }; </script>

Clone this wiki locally