本文整理汇总了C++中PlaylistItem::trackId方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistItem::trackId方法的具体用法?C++ PlaylistItem::trackId怎么用?C++ PlaylistItem::trackId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaylistItem
的用法示例。
在下文中一共展示了PlaylistItem::trackId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: idFromPlaylistItem
QVariantMap MediaPlayer2Player::Metadata() const
{
QVariantMap metaData;
// The track ID is annoying since it must result in a valid DBus object
// path, and the regex for that is, and I quote: [a-zA-Z0-9_]*, along with
// the normal / delimiters for paths.
PlaylistItem *item = Playlist::playingItem();
if (!item)
return metaData;
FileHandle playingFile = item->file();
QByteArray playingTrackFileId = idFromPlaylistItem(item);
metaData["mpris:trackid"] =
QVariant::fromValue<QDBusObjectPath>(
QDBusObjectPath(playingTrackFileId.constData()));
metaData["xesam:album"] = playingFile.tag()->album();
metaData["xesam:title"] = playingFile.tag()->title();
metaData["xesam:artist"] = QStringList(playingFile.tag()->artist());
metaData["xesam:genre"] = QStringList(playingFile.tag()->genre());
metaData["mpris:length"] = qint64(playingFile.tag()->seconds() * 1000000);
metaData["xesam:url"] = QString::fromLatin1(
KUrl::fromLocalFile(playingFile.absFilePath()).toEncoded());
if(playingFile.coverInfo()->hasCover()) {
QString fallbackFileName = KStandardDirs::locateLocal("tmp",
QString("juk-cover-%1.png").arg(item->trackId()));
QString path = fallbackFileName;
if(!QFile::exists(path)) {
path = playingFile.coverInfo()->localPathToCover(fallbackFileName);
}
metaData["mpris:artUrl"] = QString::fromLatin1(QUrl::fromLocalFile(
path).toEncoded());
}
return metaData;
}