diff --git a/modules/player/popcorn.player.js b/modules/player/popcorn.player.js index 2f612de1..90f093e8 100644 --- a/modules/player/popcorn.player.js +++ b/modules/player/popcorn.player.js @@ -404,13 +404,13 @@ if ( !targetType ) { - targetType = ( target.charAt( 0 ) === "#" ? document.getElementById( target.substring( 1 ) ) : document.getElementById( target ) ).nodeName; + targetType = Popcorn.dom.find( target ).nodeName; } // If src is an array, add 's if ( typeof( src ) !== "string" && src.length ) { - + for ( var i = 0; i < src.length; ++i ) { sourceNode = document.createElement( "source" ); diff --git a/modules/player/popcorn.player.unit.js b/modules/player/popcorn.player.unit.js index 0f112881..6c1e3a34 100644 --- a/modules/player/popcorn.player.unit.js +++ b/modules/player/popcorn.player.unit.js @@ -333,7 +333,7 @@ asyncTest( "Popcorn.smart - audio and video elements", function() { }); asyncTest( "Popcorn.smart - multiple sources for HTML5 media", function() { - expect( 6 ); + expect( 19 ); var instanceDiv, count = 0, @@ -345,13 +345,28 @@ asyncTest( "Popcorn.smart - multiple sources for HTML5 media", function() { instanceDiv = document.getElementById( "multi-div" ); ok( instanceDiv.firstChild && instanceDiv.firstChild.childNodes.length === 3, "multi-div has 3 children" ); - ok( instanceDiv.firstChild.childNodes[ 0 ].nodeName === "SOURCE", "multi-div has children" ); + ok( instanceDiv.firstChild.childNodes[ 0 ].nodeName === "SOURCE", "multi-div has children [ 0 ]" ); + ok( instanceDiv.firstChild.childNodes[ 1 ].nodeName === "SOURCE", "multi-div has children [ 1 ]" ); + ok( instanceDiv.firstChild.childNodes[ 2 ].nodeName === "SOURCE", "multi-div has children [ 2 ]" ); + ok( instanceDiv.firstChild.childNodes[ 0 ].getAttribute( "type" ) === "video/ogv", "source[ 0 ] is correct type" ); + ok( instanceDiv.firstChild.childNodes[ 1 ].getAttribute( "type" ) === "video/webm", "source[ 1 ] is correct type" ); + ok( instanceDiv.firstChild.childNodes[ 2 ].getAttribute( "type" ) === "video/mp4", "source[ 2 ] is correct type" ); + instanceDiv = document.getElementById( "multi-video" ); ok( instanceDiv.childNodes.length === 3, "multi-video has 3 children" ); - ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-video has children" ); + ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-video has children [ 0 ]" ); + ok( instanceDiv.childNodes[ 1 ].nodeName === "SOURCE", "multi-video has children [ 1 ]" ); + ok( instanceDiv.childNodes[ 2 ].nodeName === "SOURCE", "multi-video has children [ 2 ]" ); + ok( instanceDiv.childNodes[ 0 ].getAttribute( "type" ) === "video/ogv", "source[ 0 ] is correct type" ); + ok( instanceDiv.childNodes[ 1 ].getAttribute( "type" ) === "video/webm", "source[ 1 ] is correct type" ); + ok( instanceDiv.childNodes[ 2 ].getAttribute( "type" ) === "video/mp4", "source[ 2 ] is correct type" ); + instanceDiv = document.getElementById( "multi-audio" ); ok( instanceDiv.childNodes.length === 2, "multi-audio has 2 children" ); - ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-audio has children" ); + ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-audio has children [ 0 ]" ); + ok( instanceDiv.childNodes[ 1 ].nodeName === "SOURCE", "multi-audio has children [ 1 ]" ); + ok( instanceDiv.childNodes[ 0 ].getAttribute( "type" ) === "audio/ogg", "source[ 0 ] is correct type" ); + ok( instanceDiv.childNodes[ 1 ].getAttribute( "type" ) === "audio/mp4", "source[ 1 ] is correct type" ); start();