]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#226] Support for multiple data timeline sources
authorrwldrn <waldron.rick@gmail.com>
Mon, 17 Jan 2011 20:17:20 +0000 (15:17 -0500)
committerrwldrn <waldron.rick@gmail.com>
Mon, 17 Jan 2011 20:17:20 +0000 (15:17 -0500)
popcorn.js

index 48123cf92be926390025be1b840fb1553bf28445..1efc99cd2839305f4a9269af07fea3ca2c04a0a5 100644 (file)
     Popcorn.forEach( videos, function ( iter, key ) {
 
       var video = videos[ key ],
-          dataSources, popcornVideo;
+          dataSources, dataTemp, dataType, parserFn, popcornVideo;
 
       //  Ensure we're looking at a dom node and that it has an id
       //  otherwise Popcorn won't be able to find the video element
       if ( video.nodeType && video.nodeType === 1 && video.id ) {
 
-        dataSources = video.getAttribute( "data-timeline-sources" );
-      
-        //  If the video has data sources, continue to load
-        if ( dataSources ) {
-        
-          //  Set up the video and load in the datasources
-          popcornVideo = Popcorn( "#" + video.id ).parseXML( dataSources );
+        dataSources = video.getAttribute( "data-timeline-sources" ).split(",");
+
+        if ( dataSources.length )  {
+
+          Popcorn.forEach( dataSources, function ( source ) {
+
+            dataTemp = source.split( "." );
+
+            dataType = ( dataTemp[ dataTemp.length - 1 ] ).toUpperCase(); 
+
+            parserFn = "parse" + ( dataTemp[ dataTemp.length - 1 ] ).toUpperCase();
+
+            //  If the video has data sources and the correct parser is registered, continue to load
+            if ( dataSources && Popcorn.parsers[ dataType ] ) {
+
+              //  Set up the video and load in the datasources
+              popcornVideo = Popcorn( "#" + video.id )[ parserFn ]( source );
+
+
+            }
+          });
+
+        }          
+
+        //  Only play the video if it was specified to do so
+        if ( !!popcornVideo.autoplay ) {
+          popcornVideo.play();
+        }           
 
-          //  Only play the video if it was specified to do so
-          if ( !!popcornVideo.autoplay ) {
-            popcornVideo.play();
-          }
-        }
       }
     });
   }, false );