当前位置: 首页>>代码示例>>C++>>正文


C++ PlaylistItem::length方法代码示例

本文整理汇总了C++中PlaylistItem::length方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistItem::length方法的具体用法?C++ PlaylistItem::length怎么用?C++ PlaylistItem::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlaylistItem的用法示例。


在下文中一共展示了PlaylistItem::length方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();

}
开发者ID:KDE,项目名称:audex,代码行数:37,代码来源:playlist.cpp

示例2: 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();

}
开发者ID:KDE,项目名称:audex,代码行数:46,代码来源:playlist.cpp

示例3: 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);

}
开发者ID:KDE,项目名称:audex,代码行数:68,代码来源:playlist.cpp


注:本文中的PlaylistItem::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。