]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#289] Eliminate empty subtitle processing
authorstevenaw <sweerdenburg@gmail.com>
Sat, 29 Jan 2011 02:58:26 +0000 (21:58 -0500)
committerstevenaw <sweerdenburg@gmail.com>
Sat, 29 Jan 2011 02:58:26 +0000 (21:58 -0500)
parsers/parserTTXT/popcorn.parseTTXT.html
parsers/parserTTXT/popcorn.parseTTXT.js
parsers/parserTTXT/popcorn.parseTTXT.unit.js

index f61f89a52b3d69d808a8af256ebea84b8afb6071..f9536f30e9c9481e1d570bc41a80bede4046c991 100644 (file)
 <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"
index 6b8193bf46a6cdfea257f465df6f04fc66faba27..d3c7341138c573dd51444606b5ea674ac713437a 100644 (file)
         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;
index eab63bf4aebf94f781f3328a4ae77bf89d04ae4b..681bf73663ab17f56141bebde0b6be76fdb4f1f8 100644 (file)
@@ -6,40 +6,20 @@ test("Popcorn 0.3 TTXT Parser Plugin", function () {
       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: ""
         }
       ];