<body>
<h1 id="qunit-header">Popcorn 0.3 TTXT parser Plug-in Demo</h1>
<p>Subtitles are processed from <a href="data/data.TTXT">here</a></p>
- <p>From 2.4 to 5.2 seconds, "[Background Music Playing]" is shown</p>
- <p>From 15.712 to 17.399 seconds, "Heay!!" is shown</p>
- <p>From 25.712 to 30.399 seconds, "[Bird noises]" is shown</p>
+
+ <p>From 2.4 to 5.2 seconds, "[Background Music Playing]" is shown
+ <br />From 15.712 to 17.399 seconds, "Heay!!" is shown
+ <br />From 25.712 to 30.399 seconds, "[Bird noises]" is shown</p>
<div>
<video id='video'
data-timeline-sources="data/data.TTXT"
var sub = {};
sub.start = toSeconds(node.getAttribute('sampleTime'));
sub.text = node.getAttribute('text');
-
- // Infer end time from prior element, ms accuracy
- sub.end = lastStart - 0.001;
-
- cmds.push( createTrack("subtitle", sub) );
+
+ if (sub.text) { // Only process if text to display
+ // Infer end time from prior element, ms accuracy
+ sub.end = lastStart - 0.001;
+ cmds.push( createTrack("subtitle", sub) );
+ }
lastStart = sub.start;
}
node = node.previousSibling;
numSubs = 0,
poppercorn = Popcorn( "#video" ),
subs = [ // Expected values
- {
- start: 0,
- end: 2.399,
- text: ""
- },
{
start: 2.4,
end: 5.199,
text: "[Background Music Playing]"
},
- {
- start: 5.2,
- end: 15.711,
- text: ""
- },
{
start: 15.712,
end: 17.398,
text: "Heay!!"
},
- {
- start: 17.399,
- end: 25.711,
- text: ""
- },
{
start: 25.712,
end: 30.398,
text: "[Bird noises]"
- },
- {
- start: 30.399,
- end: Number.MAX_VALUE,
- text: ""
}
];