Media.contentFromXml constructor
Media.contentFromXml(
- UniversalFeed uf,
- XmlElement node
Creates a new Media object from an XmlElement
Implementation
factory Media.contentFromXml(UniversalFeed uf, XmlElement node) {
final nsUrl = uf.meta.extensions.nsUrl(nsMediaNs);
final media = Media._();
getElements<XmlElement>(
node,
'content',
ns: nsUrl,
cb: (xml) => media.content.add(MediaContent.fromXml(uf, xml)),
);
getElements<XmlElement>(
node,
'group',
ns: nsUrl,
cb: (group) {
media.group.add(Media.contentFromXml(uf, group));
},
);
getElement<XmlElement>(node, 'title', ns: nsUrl, cb: (value) => media.title = textDecoder('plain', value));
getElement<XmlElement>(
node,
'description',
ns: nsUrl,
cb: (value) => media.description = textDecoder('plain', value),
);
getElements<XmlElement>(
node,
'rating',
ns: nsUrl,
cb: (xml) {
media.rating.add(Rating.fromXml(xml));
},
);
getElements<XmlElement>(
node,
'keywords',
ns: nsUrl,
cb: (xml) {
final keywords = Category.loadTags(xml, defaultScheme: 'keyword');
if (keywords != null) media.categories.addAll(keywords);
},
);
getElements<XmlElement>(
node,
'category',
ns: nsUrl,
cb: (xml) {
final category = Category.fromXml(xml);
if (category != null) media.categories.add(category);
},
);
getElements<XmlElement>(
node,
'thumbnail',
ns: nsUrl,
cb: (xml) => media.thumbnails.add(Image.fromXmlAttributes(xml)),
);
getElement<XmlElement>(node, 'player', ns: nsUrl, cb: (value) => media.player = Player.fromXml(value));
getElements<XmlElement>(
node,
'credit',
ns: nsUrl,
cb: (xml) => media.credits.add(Credit.fromXml(xml)),
);
return media;
}