From: rwldrn Date: Mon, 17 Jan 2011 20:17:20 +0000 (-0500) Subject: [#226] Support for multiple data timeline sources X-Git-Tag: v0.3~29^2~4 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=c1f78bb1bed9c6c9f4c95100ba05fc36bdeddb63;p=popcorn-js.git [#226] Support for multiple data timeline sources --- diff --git a/popcorn.js b/popcorn.js index 48123cf..1efc99c 100644 --- a/popcorn.js +++ b/popcorn.js @@ -861,25 +861,41 @@ 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 );