зеркало из https://github.com/mozilla/popcorn-js.git
[#1222] Updated XML parser so it doesn't copy ids from its manifests
This commit is contained in:
Родитель
3c2fcfbbd9
Коммит
8f44ce1993
|
@ -41,7 +41,8 @@
|
|||
for ( var i = 0, nal = nodeAttributes.length; i < nal; i++ ) {
|
||||
|
||||
var key = nodeAttributes.item(i).nodeName,
|
||||
data = nodeAttributes.item(i).nodeValue;
|
||||
data = nodeAttributes.item(i).nodeValue,
|
||||
manifestItem = manifestData[ data ];
|
||||
|
||||
// converts in into start
|
||||
if (key === "in") {
|
||||
|
@ -51,7 +52,13 @@
|
|||
returnObject.end = toSeconds( data );
|
||||
// this is where ids in the manifest are linked
|
||||
} else if ( key === "resourceid" ) {
|
||||
Popcorn.extend( returnObject, manifestData[data] );
|
||||
for ( var item in manifestItem ) {
|
||||
if ( manifestItem.hasOwnProperty( item ) ) {
|
||||
if ( !returnObject[ item ] && item !== "id" ) {
|
||||
returnObject[ item ] = manifestItem[ item ];
|
||||
}
|
||||
}
|
||||
}
|
||||
// everything else
|
||||
} else {
|
||||
returnObject[key] = data;
|
||||
|
|
|
@ -1,54 +1,32 @@
|
|||
asyncTest( "Popcorn 0.1 XML Parser Plugin", function () {
|
||||
|
||||
var expects = 7,
|
||||
count = 0,
|
||||
interval,
|
||||
poppercorn = Popcorn( "#video" );
|
||||
|
||||
function plus() {
|
||||
if ( ++count === expects ) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
expect(expects);
|
||||
asyncTest( "Popcorn 0.1 XML Parser Plugin", 7, function () {
|
||||
|
||||
var poppercorn = Popcorn( "#video" );
|
||||
|
||||
Popcorn.plugin( "parserTest1", {
|
||||
|
||||
start: function ( event, options ) {
|
||||
ok( options.item2 === "item2", "parserTest1 has data directly from manifest" );
|
||||
plus();
|
||||
ok( options.item3 === "item3", "parserTest1 has cascading data from manifest" );
|
||||
plus();
|
||||
},
|
||||
end: function ( event, options ) {}
|
||||
}
|
||||
});
|
||||
|
||||
Popcorn.plugin( "parserTest2", {
|
||||
|
||||
start: function ( event, options ) {
|
||||
ok( options.text === "item4", "parserTest2 has text data" );
|
||||
plus();
|
||||
ok( options.item1 === "item1", "parserTest2 has cascading data from parent" );
|
||||
plus();
|
||||
},
|
||||
end: function ( event, options ) {}
|
||||
}
|
||||
});
|
||||
|
||||
Popcorn.plugin( "parserTest3", {
|
||||
|
||||
start: function ( event, options ) {
|
||||
ok( options.item1 === "item1", "parserTest3 has cascading data from parent" );
|
||||
plus();
|
||||
ok( options.item2 === "item2", "parserTest3 has data directly from manifest" );
|
||||
plus();
|
||||
ok( options.item3 === "item3", "parserTest3 has cascading data from manifest" );
|
||||
plus();
|
||||
},
|
||||
end: function ( event, options ) {}
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
||||
poppercorn.parseXML( "data/unit.XML", function() {
|
||||
poppercorn.currentTime(5).play();
|
||||
});
|
||||
poppercorn.play( 5 );
|
||||
poppercorn.mute();
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче