本文整理汇总了C++中PlaylistItem::filename方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistItem::filename方法的具体用法?C++ PlaylistItem::filename怎么用?C++ PlaylistItem::filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaylistItem
的用法示例。
在下文中一共展示了PlaylistItem::filename方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toPLS
QByteArray Playlist::toPLS(const QString& playlistPath, const bool utf8) const
{
QStringList playlist;
playlist.append("[Playlist]");
int j = 0;
for (int i = 0; i < p_playlist.count(); ++i)
{
PlaylistItem pi = p_playlist[i];
if (pi.filename().isEmpty()) continue;
++j;
if (!playlistPath.isEmpty())
{
QDir dir(playlistPath);
playlist.append(QString("File%1=%2").arg(i+1).arg(dir.relativeFilePath(pi.filename())));
}
else
{
playlist.append(QString("File%1=%2").arg(i+1).arg(pi.filename()));
}
if (!pi.artist().isEmpty())
{
playlist.append(QString("Title%1=%2 - %3").arg(i+1).arg(pi.artist()).arg(pi.title()));
}
else
{
playlist.append(QString("Title%1=%2").arg(i+1).arg(pi.title()));
}
playlist.append(QString("Length%1=%2").arg(i+1).arg(pi.length()));
}
playlist.append(QString("NumberOfEntries=%1").arg(j));
playlist.append(QString("Version=2"));
if (utf8)
return playlist.join("\n").append("\n").toUtf8();
else
return playlist.join("\n").append("\n").toLatin1();
}
示例2: dir
QByteArray Playlist::toM3U(const QString& playlistPath, const bool utf8) const {
QStringList playlist;
playlist.append("#EXTM3U");
for (int i = 0; i < p_playlist.count(); ++i)
{
PlaylistItem pi = p_playlist[i];
if (pi.filename().isEmpty()) continue;
if (!pi.artist().isEmpty())
{
playlist.append(QString("#EXTINF:%1,%2 - %3").arg(pi.length()).arg(pi.artist()).arg(pi.title()));
}
else
{
playlist.append(QString("#EXTINF:%1,%2").arg(pi.length()).arg(pi.title()));
}
if (!playlistPath.isEmpty())
{
QDir dir(playlistPath);
playlist.append(dir.relativeFilePath(pi.filename()));
}
else
{
playlist.append(pi.filename());
}
}
if (utf8)
return playlist.join("\n").append("\n").toUtf8();
else
return playlist.join("\n").append("\n").toLatin1();
}
示例3: stream
void Playlist::p_add_M3U(const QByteArray& playlist)
{
QTextStream stream(playlist, QIODevice::ReadOnly);
QString line = stream.readLine().trimmed();
bool extended = false;
if (line.startsWith("#EXTM3U"))
{
extended = true;
line = stream.readLine().trimmed();
}
PlaylistItem pi;
while (!line.isNull())
{
if (line.startsWith('#'))
{
if (extended && line.startsWith("#EXT"))
{
pi = p_parse_m3u_metadata_line(line);
}
}
else if (!line.isEmpty())
{
pi.setFilename(line);
if (!pi.filename().isEmpty())
{
p_playlist.append(pi);
pi.clear();
}
}
line = stream.readLine().trimmed();
}
}
示例4: toXSPF
QByteArray Playlist::toXSPF() const
{
QDomDocument doc;
QDomElement root = doc.createElement("playlist");
root.setAttribute("version", "1");
root.setAttribute("xmlns", "http://xspf.org/ns/0");
QDomElement creator = doc.createElement("creator");
QDomText text = doc.createTextNode("audex");
creator.appendChild(text);
root.appendChild(creator);
QDomElement tracklist = doc.createElement("trackList");
int j = 0;
for (int i = 0; i < p_playlist.count(); ++i)
{
PlaylistItem pi = p_playlist[i];
if (pi.filename().isEmpty()) continue;
++j;
QDomElement track = doc.createElement("track");
QDomElement ch = doc.createElement("location");
QDomText text = doc.createTextNode(pi.filename());
ch.appendChild(text);
track.appendChild(ch);
if (!pi.artist().isEmpty())
{
ch = doc.createElement("creator");
text = doc.createTextNode(pi.artist());
ch.appendChild(text);
track.appendChild(ch);
}
ch = doc.createElement("title");
text = doc.createTextNode(pi.title());
ch.appendChild(text);
track.appendChild(ch);
ch = doc.createElement("trackNum");
text = doc.createTextNode(QString::number(j));
ch.appendChild(text);
track.appendChild(ch);
if (pi.length() > 0)
{
ch = doc.createElement("duration");
text = doc.createTextNode(QString::number(pi.length()*1000));
ch.appendChild(text);
track.appendChild(ch);
}
tracklist.appendChild(track);
}
root.appendChild(tracklist);
doc.appendChild(root);
QByteArray xml_header("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
return doc.toByteArray().prepend(xml_header);
}