本文整理汇总了C++中MediaInfo::metadataValue方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaInfo::metadataValue方法的具体用法?C++ MediaInfo::metadataValue怎么用?C++ MediaInfo::metadataValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaInfo
的用法示例。
在下文中一共展示了MediaInfo::metadataValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeTrack
void XSPFParser::writeTrack(QXmlStreamWriter & xml, const MediaInfo & mediaInfo) {
xml.writeStartElement(XSPF_TRACK);
//Filename
QUrl url(mediaInfo.fileName());
writeTextElement(xml, XSPF_LOCATION, url.toEncoded());
//Unique ID
//FIXME not implemented yet
//writeTextElement(xml, XSPF_IDENTIFIER, QString());
//Artist
writeTextElement(xml, XSPF_CREATOR, mediaInfo.metadataValue(MediaInfo::Artist));
//Album
writeTextElement(xml, XSPF_ALBUM, mediaInfo.metadataValue(MediaInfo::Album));
//Track number
writeTextElement(xml, XSPF_TRACKNUM, mediaInfo.metadataValue(MediaInfo::TrackNumber));
//Title
writeTextElement(xml, XSPF_TITLE, mediaInfo.metadataValue(MediaInfo::Title));
//Comment
writeTextElement(xml, XSPF_ANNOTATION, mediaInfo.metadataValue(MediaInfo::Comment));
//Length
writeIntElement(xml, XSPF_DURATION, mediaInfo.lengthMilliseconds());
//Album art URL
//FIXME not implemented yet
//writeTextElement(xml, XSPF_IMAGE, mediaInfo.metadataValue(MediaInfo::AlbumArt));
//URL of the original web page
writeTextElement(xml, XSPF_INFO, mediaInfo.metadataValue(MediaInfo::URL));
xml.writeStartElement(XSPF_EXTENSION);
xml.writeAttribute(XSPF_APPLICATION, XSPF_QUARKPLAYER_NAMESPACE);
writeTextElementWithNamespace(xml, XSPF_QUARKPLAYER_NAMESPACE, XSPF_QUARKPLAYER_CUE_START_INDEX, mediaInfo.cueStartIndexFormatted());
writeTextElementWithNamespace(xml, XSPF_QUARKPLAYER_NAMESPACE, XSPF_QUARKPLAYER_CUE_END_INDEX, mediaInfo.cueEndIndexFormatted());
writeTextElementWithNamespace(xml, XSPF_QUARKPLAYER_NAMESPACE, XSPF_QUARKPLAYER_YEAR, mediaInfo.metadataValue(MediaInfo::Year));
writeTextElementWithNamespace(xml, XSPF_QUARKPLAYER_NAMESPACE, XSPF_QUARKPLAYER_GENRE, mediaInfo.metadataValue(MediaInfo::Genre));
xml.writeEndElement(); //extension
xml.writeEndElement(); //track
}
示例2: readTrack
void XSPFParser::readTrack(QXmlStreamReader & xml, MediaInfo & mediaInfo) const {
while (!xml.atEnd() && !_stop) {
xml.readNext();
QString element(xml.name().toString());
if (xml.isStartElement()) {
//Filename
if (element == XSPF_LOCATION) {
QUrl url = QUrl::fromEncoded(xml.readElementText().toUtf8());
QString location(url.toString());
bool isUrl = MediaInfo::isUrl(location);
mediaInfo.setUrl(isUrl);
if (isUrl) {
mediaInfo.setFileName(location);
} else {
QString path(QFileInfo(_filename).path());
mediaInfo.setFileName(Util::canonicalFilePath(path, location));
}
}
//Unique ID
else if (element == XSPF_IDENTIFIER) {
QString identifier(xml.readElementText());
//FIXME not implemented yet
}
//Artist
else if (element == XSPF_CREATOR) {
QString creator(xml.readElementText());
mediaInfo.insertMetadata(MediaInfo::Artist, creator);
}
//Album
else if (element == XSPF_ALBUM) {
QString album(xml.readElementText());
mediaInfo.insertMetadata(MediaInfo::Album, album);
}
//Track number
else if (element == XSPF_TRACKNUM) {
QString trackNum(xml.readElementText());
mediaInfo.insertMetadata(MediaInfo::TrackNumber, trackNum);
}
//Title
else if (element == XSPF_TITLE) {
QString title(xml.readElementText());
mediaInfo.insertMetadata(MediaInfo::Title, title);
}
//Comment
else if (element == XSPF_ANNOTATION) {
QString annotation(xml.readElementText());
if (mediaInfo.metadataValue(MediaInfo::Title).isEmpty()) {
//Some people didn't understand how XSPF works
//and confused annotation with title
mediaInfo.insertMetadata(MediaInfo::Title, annotation);
}
mediaInfo.insertMetadata(MediaInfo::Comment, annotation);
}
//Length
else if (element == XSPF_DURATION) {
int duration = xml.readElementText().toInt();
//XSPF gives us the duration in milliseconds
//Let's convert it to seconds
mediaInfo.setLength(duration / 1000);
}
//Album art URL
else if (element == XSPF_IMAGE) {
QString image(xml.readElementText());
//FIXME not implemented yet
//mediaInfo.insertMetadata(MediaInfo::AlbumArt, image);
}
//URL of the original web page
else if (element == XSPF_INFO) {
QString info(xml.readElementText());
mediaInfo.insertMetadata(MediaInfo::URL, info);
}
//Meta
else if (element == XSPF_META) {
//These tags are specific to foobar2000 XSPF plugin
QXmlStreamAttributes attributes = xml.attributes();
//Date
if (attributes.hasAttribute(XSPF_FOOBAR2000_DATE)) {
QString date(attributes.value(XSPF_FOOBAR2000_DATE).toString());
mediaInfo.insertMetadata(MediaInfo::Year, date);
}
//Genre
else if (attributes.hasAttribute(XSPF_FOOBAR2000_GENRE)) {
QString genre(attributes.value(XSPF_FOOBAR2000_GENRE).toString());
//.........这里部分代码省略.........