QString extractMBIDFromFile(TagLib::ASF::File *file)
{
	const char *key = "MusicBrainz/Track Id";
	TagLib::ASF::Tag *tag = file->tag();
	if (tag->attributeListMap().contains(key)) {
		return QString::fromUtf8(tag->attributeListMap()[key].front().toString().toCString(true));
	}
	return QString();
}
示例#2
0
string ExtractMBIDFromFile(TagLib::ASF::File *file)
{
	string key = "MusicBrainz/Track Id";
	TagLib::ASF::Tag *tag = file->tag();
	if (tag && tag->attributeListMap().contains(key)) {
		return tag->attributeListMap()[key].front().toString().to8Bit(true);
	}
	return string();
}
示例#3
0
bool TagReader::SaveSongRatingToFile(
    const QString& filename, const pb::tagreader::SongMetadata& song) const {
  if (filename.isNull()) return false;

  qLog(Debug) << "Saving song rating tags to" << filename;
  if (song.rating() < 0) {
    // The FMPS spec says unrated == "tag not present". For us, no rating
    // results in rating being -1, so don't write anything in that case.
    // Actually, we should also remove tag set in this case, but in
    // Clementine it is not possible to unset rating i.e. make a song "unrated".
    qLog(Debug) << "Unrated: do nothing";
    return true;
  }

  std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));

  if (!fileref || fileref->isNull())  // The file probably doesn't exist
    return false;

  if (TagLib::MPEG::File* file =
          dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
    TagLib::ID3v2::Tag* tag = file->ID3v2Tag(true);

    // Save as FMPS
    SetUserTextFrame("FMPS_Rating", QString::number(song.rating()), tag);

    // Also save as POPM
    TagLib::ID3v2::PopularimeterFrame* frame = GetPOPMFrameFromTag(tag);
    frame->setRating(ConvertToPOPMRating(song.rating()));

  } else if (TagLib::FLAC::File* file =
                 dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
    TagLib::Ogg::XiphComment* vorbis_comments = file->xiphComment(true);
    SetFMPSRatingVorbisComments(vorbis_comments, song);
  } else if (TagLib::Ogg::XiphComment* tag =
                 dynamic_cast<TagLib::Ogg::XiphComment*>(
                     fileref->file()->tag())) {
    SetFMPSRatingVorbisComments(tag, song);
  }
#ifdef TAGLIB_WITH_ASF
  else if (TagLib::ASF::File* file =
               dynamic_cast<TagLib::ASF::File*>(fileref->file())) {
    TagLib::ASF::Tag* tag = file->tag();
    tag->addAttribute("FMPS/Rating", NumberToASFAttribute(song.rating()));
  }
#endif
  else if (TagLib::MP4::File* file =
               dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
    TagLib::MP4::Tag* tag = file->tag();
    tag->itemListMap()[kMP4_FMPS_Rating_ID] = TagLib::StringList(
        QStringToTaglibString(QString::number(song.rating())));
  } else {
    // Nothing to save: stop now
    return true;
  }

  bool ret = fileref->save();
#ifdef Q_OS_LINUX
  if (ret) {
    // Linux: inotify doesn't seem to notice the change to the file unless we
    // change the timestamps as well. (this is what touch does)
    utimensat(0, QFile::encodeName(filename).constData(), nullptr, 0);
  }
#endif  // Q_OS_LINUX
  return ret;
}
示例#4
0
bool TagReader::SaveSongStatisticsToFile(
    const QString& filename, const pb::tagreader::SongMetadata& song) const {
  if (filename.isNull()) return false;

  qLog(Debug) << "Saving song statistics tags to" << filename;

  std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));

  if (!fileref || fileref->isNull())  // The file probably doesn't exist
    return false;

  if (TagLib::MPEG::File* file =
          dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
    TagLib::ID3v2::Tag* tag = file->ID3v2Tag(true);

    // Save as FMPS
    SetUserTextFrame("FMPS_PlayCount", QString::number(song.playcount()), tag);
    SetUserTextFrame("FMPS_Rating_Amarok_Score",
                     QString::number(song.score() / 100.0), tag);

    // Also save as POPM
    TagLib::ID3v2::PopularimeterFrame* frame = GetPOPMFrameFromTag(tag);
    frame->setCounter(song.playcount());

  } else if (TagLib::FLAC::File* file =
                 dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
    TagLib::Ogg::XiphComment* vorbis_comments = file->xiphComment(true);
    SetFMPSStatisticsVorbisComments(vorbis_comments, song);
  } else if (TagLib::Ogg::XiphComment* tag =
                 dynamic_cast<TagLib::Ogg::XiphComment*>(
                     fileref->file()->tag())) {
    SetFMPSStatisticsVorbisComments(tag, song);
  }
#ifdef TAGLIB_WITH_ASF
  else if (TagLib::ASF::File* file =
               dynamic_cast<TagLib::ASF::File*>(fileref->file())) {
    TagLib::ASF::Tag* tag = file->tag();
    tag->addAttribute("FMPS/Playcount", NumberToASFAttribute(song.playcount()));
    tag->addAttribute("FMPS/Rating_Amarok_Score",
                      NumberToASFAttribute(song.score() / 100.0));
  }
#endif
  else if (TagLib::MP4::File* file =
               dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
    TagLib::MP4::Tag* tag = file->tag();
    tag->itemListMap()[kMP4_FMPS_Score_ID] = TagLib::StringList(
        QStringToTaglibString(QString::number(song.score() / 100.0)));
    tag->itemListMap()[kMP4_FMPS_Playcount_ID] =
        TagLib::StringList(TagLib::String::number(song.playcount()));
  } else {
    // Nothing to save: stop now
    return true;
  }

  bool ret = fileref->save();
#ifdef Q_OS_LINUX
  if (ret) {
    // Linux: inotify doesn't seem to notice the change to the file unless we
    // change the timestamps as well. (this is what touch does)
    utimensat(0, QFile::encodeName(filename).constData(), nullptr, 0);
  }
#endif  // Q_OS_LINUX
  return ret;
}
示例#5
0
int TagLibMetadata::setKey(const QString& key){

  if(f == NULL || !f->isValid()){
    qDebug("Cannot set grouping tag on invalid file object");
    return 1;
  }

  TagLib::MPEG::File* fileTestMpeg = dynamic_cast<TagLib::MPEG::File*>(f);
  if(fileTestMpeg != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestMpeg->ID3v2Tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::Frame* frm = new TagLib::ID3v2::TextIdentificationFrame("TKEY");
      frm->setText(TagLib::String(key.toUtf8().data()));
      tagTestId3v2->removeFrames("TKEY");
      tagTestId3v2->addFrame(frm);
      f->save();
      return 0;
    }else{
      TagLib::ID3v1::Tag* tagTestId3v1 = fileTestMpeg->ID3v1Tag();
      if(tagTestId3v1 != NULL){
        #ifdef Q_OS_WIN
          qDebug("ID3v1 does not support the Key tag");
        #else
          qDebug("ID3v1 does not support the Key tag (%s)",f->name());
        #endif
        return 1;
      }
    }
  }

  TagLib::RIFF::AIFF::File* fileTestAiff = dynamic_cast<TagLib::RIFF::AIFF::File*>(f);
  if(fileTestAiff != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestAiff->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::Frame* frm = new TagLib::ID3v2::TextIdentificationFrame("TKEY");
      frm->setText(TagLib::String(key.toUtf8().data()));
      tagTestId3v2->removeFrames("TKEY");
      tagTestId3v2->addFrame(frm);
      f->save();
      return 0;
    }
  }

  TagLib::RIFF::WAV::File* fileTestWav = dynamic_cast<TagLib::RIFF::WAV::File*>(f);
  if(fileTestWav != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestWav->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::Frame* frm = new TagLib::ID3v2::TextIdentificationFrame("TKEY");
      frm->setText(TagLib::String(key.toUtf8().data()));
      tagTestId3v2->removeFrames("TKEY");
      tagTestId3v2->addFrame(frm);
      f->save();
      return 0;
    }
  }

  TagLib::MP4::Tag* tagTestMp4 = dynamic_cast<TagLib::MP4::Tag*>(f->tag());
  if(tagTestMp4 != NULL){
    #ifdef Q_OS_WIN
      qDebug("iTunes metadata does not support the Key tag");
    #else
      qDebug("iTunes metadata does not support the Key tag (%s)",f->name());
    #endif
    return 1;
  }

  TagLib::ASF::Tag* tagTestAsf = dynamic_cast<TagLib::ASF::Tag*>(f->tag());
  if(tagTestAsf != NULL){
    tagTestAsf->setAttribute("WM/InitialKey",TagLib::String(key.toUtf8().data()));
    f->save();
    return 0;
  }

  TagLib::APE::Tag* tagTestApe = dynamic_cast<TagLib::APE::Tag*>(f->tag());
  if(tagTestApe != NULL){
    #ifdef Q_OS_WIN
      qDebug("APE metadata does not support the Key tag");
    #else
      qDebug("APE metadata does not support the Key tag (%s)",f->name());
    #endif
    return 1;
  }

  #ifdef Q_OS_WIN
    qDebug("Key tag write failed all tests");
  #else
    qDebug("Key tag write failed all tests on %s",f->name());
  #endif
  return 1;
}
示例#6
0
int TagLibMetadata::setGrouping(const QString& grp){

  if(f == NULL || !f->isValid()){
    qDebug("Cannot set grouping tag on invalid file object");
    return 1;
  }

  TagLib::MPEG::File* fileTestMpeg = dynamic_cast<TagLib::MPEG::File*>(f);
  if(fileTestMpeg != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestMpeg->ID3v2Tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::Frame* frm = new TagLib::ID3v2::TextIdentificationFrame("TIT1");
      frm->setText(TagLib::String(grp.toUtf8().data()));
      tagTestId3v2->removeFrames("TIT1");
      tagTestId3v2->addFrame(frm);
      f->save();
      return 0;
    }else{
      TagLib::ID3v1::Tag* tagTestId3v1 = fileTestMpeg->ID3v1Tag();
      if(tagTestId3v1 != NULL){
        #ifdef Q_OS_WIN
          qDebug("ID3v1 does not support the Grouping tag");
        #else
          qDebug("ID3v1 does not support the Grouping tag (%s)",f->name());
        #endif
        return 1;
      }
    }
  }

  TagLib::RIFF::AIFF::File* fileTestAiff = dynamic_cast<TagLib::RIFF::AIFF::File*>(f);
  if(fileTestAiff != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestAiff->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::Frame* frm = new TagLib::ID3v2::TextIdentificationFrame("TIT1");
      frm->setText(TagLib::String(grp.toUtf8().data()));
      tagTestId3v2->removeFrames("TIT1");
      tagTestId3v2->addFrame(frm);
      f->save();
      return 0;
    }
  }

  TagLib::RIFF::WAV::File* fileTestWav = dynamic_cast<TagLib::RIFF::WAV::File*>(f);
  if(fileTestWav != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestWav->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::Frame* frm = new TagLib::ID3v2::TextIdentificationFrame("TIT1");
      frm->setText(TagLib::String(grp.toUtf8().data()));
      tagTestId3v2->removeFrames("TIT1");
      tagTestId3v2->addFrame(frm);
      f->save();
      return 0;
    }
  }

  TagLib::MP4::Tag* tagTestMp4 = dynamic_cast<TagLib::MP4::Tag*>(f->tag());
  if(tagTestMp4 != NULL){
    TagLib::StringList sl(TagLib::String(grp.toUtf8().data()));
    tagTestMp4->itemListMap()["\251grp"] = sl;
    tagTestMp4->save();
    f->save();
    return 0;
  }

  TagLib::ASF::Tag* tagTestAsf = dynamic_cast<TagLib::ASF::Tag*>(f->tag());
  if(tagTestAsf != NULL){
    tagTestAsf->setAttribute("WM/ContentGroupDescription",TagLib::String(grp.toUtf8().data()));
    f->save();
    return 0;
  }

  TagLib::APE::Tag* tagTestApe = dynamic_cast<TagLib::APE::Tag*>(f->tag());
  if(tagTestApe != NULL){
    tagTestApe->addValue("GROUPING",TagLib::String(grp.toUtf8().data()));
    f->save();
    return 0;
  }

  #ifdef Q_OS_WIN
    qDebug("Grouping tag write failed all tests");
  #else
    qDebug("Grouping tag write failed all tests on %s",f->name());
  #endif
  return 1;
}
示例#7
0
QString TagLibMetadata::getKey() const{

  if(f == NULL || !f->isValid())
    return "";

  TagLib::MPEG::File* fileTestMpeg = dynamic_cast<TagLib::MPEG::File*>(f);
  if(fileTestMpeg != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestMpeg->ID3v2Tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::FrameList l = tagTestId3v2->frameListMap()["TKEY"];
      if(!l.isEmpty()){
        TagLib::String out = l.front()->toString();
        return QString::fromUtf8((out.toCString()));
      }
      return "";
    }
    TagLib::ID3v1::Tag* tagTestId3v1 = fileTestMpeg->ID3v1Tag();
    if(tagTestId3v1 != NULL){
      #ifdef Q_OS_WIN
        qDebug("ID3v1 does not support the Key tag");
      #else
        qDebug("ID3v1 does not support the Key tag (%s)",f->name());
      #endif
      return "N/A";
    }
  }

  TagLib::RIFF::AIFF::File* fileTestAiff = dynamic_cast<TagLib::RIFF::AIFF::File*>(f);
  if(fileTestAiff != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestAiff->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::FrameList l = tagTestId3v2->frameListMap()["TKEY"];
      if(!l.isEmpty()){
        TagLib::String out = l.front()->toString();
        return QString::fromUtf8((out.toCString()));
      }
      return "";
    }
  }

  TagLib::RIFF::WAV::File* fileTestWav = dynamic_cast<TagLib::RIFF::WAV::File*>(f);
  if(fileTestWav != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestWav->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::FrameList l = tagTestId3v2->frameListMap()["TKEY"];
      if(!l.isEmpty()){
        TagLib::String out = l.front()->toString();
        return QString::fromUtf8((out.toCString()));
      }
      return "";
    }
  }

  TagLib::MP4::Tag* tagTestMp4 = dynamic_cast<TagLib::MP4::Tag*>(f->tag());
  if(tagTestMp4 != NULL){
    #ifdef Q_OS_WIN
      qDebug("iTunes metadata does not support the Key tag");
    #else
      qDebug("iTunes metadata does not support the Key tag (%s)",f->name());
    #endif
    return "N/A";
  }

  TagLib::ASF::Tag* tagTestAsf = dynamic_cast<TagLib::ASF::Tag*>(f->tag());
  if(tagTestAsf != NULL){
    TagLib::ASF::AttributeList l = tagTestAsf->attributeListMap()["WM/InitialKey"];
    if(!l.isEmpty()){
      TagLib::String out = l.front().toString();
      return QString::fromUtf8((out.toCString()));
    }
    return "";
  }

  TagLib::APE::Tag* tagTestApe = dynamic_cast<TagLib::APE::Tag*>(f->tag());
  if(tagTestApe != NULL){
    #ifdef Q_OS_WIN
      qDebug("APE metadata does not support the Key tag");
    #else
      qDebug("APE metadata does not support the Key tag (%s)",f->name());
    #endif
    return "N/A";
  }

  #ifdef Q_OS_WIN
    qDebug("Key tag read failed all tests");
  #else
    qDebug("Key tag read failed all tests on %s",f->name());
  #endif

  return "N/A";
}
示例#8
0
QString TagLibMetadata::getGrouping() const{

  if(f == NULL || !f->isValid())
    return "";

  TagLib::MPEG::File* fileTestMpeg = dynamic_cast<TagLib::MPEG::File*>(f);
  if(fileTestMpeg != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestMpeg->ID3v2Tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::FrameList l = tagTestId3v2->frameListMap()["TIT1"];
      if(!l.isEmpty()){
        TagLib::String out = l.front()->toString();
        return QString::fromUtf8((out.toCString()));
      }
      return "";
    }
    TagLib::ID3v1::Tag* tagTestId3v1 = fileTestMpeg->ID3v1Tag();
    if(tagTestId3v1 != NULL){
      #ifdef Q_OS_WIN
        qDebug("ID3v1 does not support the Grouping tag");
      #else
        qDebug("ID3v1 does not support the Grouping tag (%s)",f->name());
      #endif
      return "N/A";
    }
  }

  TagLib::RIFF::AIFF::File* fileTestAiff = dynamic_cast<TagLib::RIFF::AIFF::File*>(f);
  if(fileTestAiff != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestAiff->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::FrameList l = tagTestId3v2->frameListMap()["TIT1"];
      if(!l.isEmpty()){
        TagLib::String out = l.front()->toString();
        return QString::fromUtf8((out.toCString()));
      }
      return "";
    }
  }

  TagLib::RIFF::WAV::File* fileTestWav = dynamic_cast<TagLib::RIFF::WAV::File*>(f);
  if(fileTestWav != NULL){
    TagLib::ID3v2::Tag* tagTestId3v2 = fileTestWav->tag();
    if(tagTestId3v2 != NULL){
      TagLib::ID3v2::FrameList l = tagTestId3v2->frameListMap()["TIT1"];
      if(!l.isEmpty()){
        TagLib::String out = l.front()->toString();
        return QString::fromUtf8((out.toCString()));
      }
      return "";
    }
  }

  TagLib::MP4::Tag* tagTestMp4 = dynamic_cast<TagLib::MP4::Tag*>(f->tag());
  if(tagTestMp4 != NULL){
    TagLib::MP4::Item m = tagTestMp4->itemListMap()["\251grp"];
    if(m.isValid()){
      TagLib::String out = m.toStringList().front();
      return QString::fromUtf8((out.toCString()));
    }
    return "";
  }

  TagLib::ASF::Tag* tagTestAsf = dynamic_cast<TagLib::ASF::Tag*>(f->tag());
  if(tagTestAsf != NULL){
    TagLib::ASF::AttributeList l = tagTestAsf->attributeListMap()["WM/ContentGroupDescription"];
    if(!l.isEmpty()){
      TagLib::String out = l.front().toString();
      return QString::fromUtf8((out.toCString()));
    }
    return "";
  }

  TagLib::APE::Tag* tagTestApe = dynamic_cast<TagLib::APE::Tag*>(f->tag());
  if(tagTestApe != NULL){
    TagLib::APE::Item m = tagTestApe->itemListMap()["Grouping"];
    if(!m.isEmpty()){
      TagLib::String out = m.toStringList().front();
      return QString::fromUtf8((out.toCString()));
    }
    return "";
  }

  #ifdef Q_OS_WIN
    qDebug("Grouping tag read failed all tests");
  #else
    qDebug("Grouping tag read failed all tests on %s",f->name());
  #endif
  return "N/A";
}
示例#9
0
bool cMediaInfo::readFromFile(const QString& szFileName)
{
	clear();

	QFileInfo	fileInfo(szFileName);
	if(!fileInfo.exists())
		return(false);

	if(!fileInfo.suffix().compare("APE", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_APE;
	else if(!fileInfo.suffix().compare("WMA", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_ASF;
	else if(!fileInfo.suffix().compare("FLAC", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_FLAC;
	else if(!fileInfo.suffix().compare("AAC", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MP4;
	else if(!fileInfo.suffix().compare("MP4", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MP4;
	else if(!fileInfo.suffix().compare("M4A", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MP4;
	else if(!fileInfo.suffix().compare("MPC", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPC;
	else if(!fileInfo.suffix().compare("MP1", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPEG;
	else if(!fileInfo.suffix().compare("MP2", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPEG;
	else if(!fileInfo.suffix().compare("MP3", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPEG;
	else if(!fileInfo.suffix().compare("TTA", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_TRUEAUDIO;
	else if(!fileInfo.suffix().compare("WV", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_WAVPACK;
	else if(!fileInfo.suffix().compare("WAV", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_WAV;

	if(m_fileType	== MEDIA_TYPE_UNKNOWN)
		return(false);

	m_szFileName					= szFileName;

	ID3v1::Tag*			lpTagV1		= 0;
	ID3v2::Tag*			lpTagV2		= 0;
	APE::Tag*			lpTagAPE	= 0;
	APE::File*			lpApe		= 0;
	ASF::File*			lpASF		= 0;
	FLAC::File*			lpFlac		= 0;
	MP4::File*			lpMP4		= 0;
	MPC::File*			lpMPC		= 0;
	MPEG::File*			lpMPEG		= 0;
	TrueAudio::File*	lpTrueAudio	= 0;
	WavPack::File*		lpWavPack	= 0;
	RIFF::WAV::File*	lpWav		= 0;

	TagLib::PropertyMap	tags;

	QString				szTmp;

	switch(m_fileType)
	{
	case MEDIA_TYPE_APE:
	{
		lpApe	= new APE::File(m_szFileName.toLocal8Bit().data());

		lpTagV1										= lpApe->ID3v1Tag();
		lpTagAPE									= lpApe->APETag();
		tags										= lpApe->properties();

		APE::Properties* lpAudioProperties			= lpApe->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_iVersion								= lpAudioProperties->version();
		}
		break;
	}
	case MEDIA_TYPE_ASF:
	{
		lpASF	= new ASF::File(m_szFileName.toLocal8Bit().data());
		TagLib::ASF::Tag*	lpTag					= lpASF->tag();
		m_szTitle									= QString::fromStdWString(lpTag->title().toWString());
		szTmp										= QString::fromStdWString(lpTag->artist().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szArtistList							= szTmp.split("\n");
		m_szAlbum									= QString::fromStdWString(lpTag->album().toWString());
		m_szComment									= QString::fromStdWString(lpTag->comment().toWString());
		szTmp										= QString::fromStdWString(lpTag->genre().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szGenreList							= szTmp.split("\n");
		m_szRating									= QString::fromStdWString(lpTag->genre().toWString());
		m_szCopyright								= QString::fromStdWString(lpTag->copyright().toWString());
		m_iYear										= lpTag->year();
		m_szTrackNumber								= QString("%1").arg(lpTag->track());

		tags										= lpASF->properties();

		ASF::Properties* lpAudioProperties			= lpASF->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_bIsEncrypted							= lpAudioProperties->isEncrypted();
		}
		break;
	}
	case MEDIA_TYPE_FLAC:
	{
		lpFlac	= new FLAC::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpFlac->ID3v1Tag();
		lpTagV2										= lpFlac->ID3v2Tag();
		tags										= lpFlac->properties();

		FLAC::Properties* lpAudioProperties			= lpFlac->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iSampleWidth							= lpAudioProperties->sampleWidth();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
		}
		break;
	}
	case MEDIA_TYPE_MP4:
	{
		lpMP4	= new MP4::File(m_szFileName.toLocal8Bit().data());
		TagLib::MP4::Tag*	lpTag					= lpMP4->tag();
		m_szTitle									= QString::fromStdWString(lpTag->title().toWString());
		szTmp										= QString::fromStdWString(lpTag->artist().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szArtistList							= szTmp.split("\n");
		m_szAlbum									= QString::fromStdWString(lpTag->album().toWString());
		m_szComment									= QString::fromStdWString(lpTag->comment().toWString());
		szTmp										= QString::fromStdWString(lpTag->genre().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szGenreList							= szTmp.split("\n");
		m_iYear										= lpTag->year();
		m_szTrackNumber								= QString("%1").arg(lpTag->track());

		tags										= lpMP4->properties();

		MP4::Properties* lpAudioProperties			= lpMP4->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_bIsEncrypted							= lpAudioProperties->isEncrypted();
		}
		break;
	}
	case MEDIA_TYPE_MPC:
	{
		lpMPC	= new MPC::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpMPC->ID3v1Tag();
		lpTagAPE									= lpMPC->APETag();
		tags										= lpMPC->properties();

		MPC::Properties* lpAudioProperties			= lpMPC->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iVersion								= lpAudioProperties->mpcVersion();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
			m_iTrackGain							= lpAudioProperties->trackGain();
			m_iAlbumGain							= lpAudioProperties->albumGain();
			m_iTrackPeak							= lpAudioProperties->trackPeak();
			m_iAlbumPeak							= lpAudioProperties->albumPeak();
		}
		break;
	}
	case MEDIA_TYPE_MPEG:
	{
		lpMPEG	= new MPEG::File(m_szFileName.toLocal8Bit().data());

		lpTagV1										= lpMPEG->ID3v1Tag();
		lpTagV2										= lpMPEG->ID3v2Tag();
		lpTagAPE									= lpMPEG->APETag();
		tags										= lpMPEG->properties();

		MPEG::Properties*	lpAudioProperties		= lpMPEG->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iLayer								= lpAudioProperties->layer();
			switch(lpAudioProperties->version())
			{
			case MPEG::Header::Version1:
				m_iVersion	= 10;
				break;
			case MPEG::Header::Version2:
				m_iVersion	= 20;
				break;
			case MPEG::Header::Version2_5:
				m_iVersion	= 25;
				break;
			}
			m_bProtectionEnabled					= lpAudioProperties->protectionEnabled();
			switch(lpAudioProperties->channelMode())
			{
			case MPEG::Header::Stereo:
				m_channelMode						= CHANNEL_MODE_STEREO;
				break;
			case MPEG::Header::JointStereo:
				m_channelMode						= CHANNEL_MODE_JOINTSTEREO;
				break;
			case MPEG::Header::DualChannel:
				m_channelMode						= CHANNEL_MODE_DUALMONO;
				break;
			case MPEG::Header::SingleChannel:
				m_channelMode						= CHANNEL_MODE_MONO;
				break;
			}
			m_bIsCopyrighted						= lpAudioProperties->isCopyrighted();
			m_bIsOriginal							= lpAudioProperties->isOriginal();
		}
		break;
	}
	case MEDIA_TYPE_TRUEAUDIO:
	{
		lpTrueAudio	= new TrueAudio::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpTrueAudio->ID3v1Tag();
		lpTagV2										= lpTrueAudio->ID3v2Tag();
		tags										= lpTrueAudio->properties();

		TrueAudio::Properties* lpAudioProperties	= lpTrueAudio->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_iVersion								= lpAudioProperties->ttaVersion();
		}
		break;
	}
	case MEDIA_TYPE_WAVPACK:
	{
		lpWavPack	= new WavPack::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpWavPack->ID3v1Tag();
		lpTagAPE									= lpWavPack->APETag();
		tags										= lpWavPack->properties();

		WavPack::Properties* lpAudioProperties		= lpWavPack->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
			m_iVersion								= lpAudioProperties->version();
		}
		break;
	}
	case MEDIA_TYPE_WAV:
	{
		lpWav	= new RIFF::WAV::File(m_szFileName.toLocal8Bit().data());
		lpTagV2										= lpWav->tag();
		tags										= lpWav->properties();

		RIFF::WAV::Properties* lpAudioProperties	= lpWav->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iSampleWidth							= lpAudioProperties->sampleWidth();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
		}
		break;
	}
	default:
		break;
	}

	if(lpTagV2 && m_bID3V2)
		readTagV2(lpTagV2);
	if(lpTagV1 && m_bID3V1)
		readTagV1(lpTagV1);
	if(lpTagAPE && m_bAPE)
		readTagAPE(lpTagAPE);
	if(m_bProperties)
		readTagProperties(tags);

	if(lpApe)
		delete lpApe;
	if(lpASF)
		delete lpASF;
	if(lpFlac)
		delete lpFlac;
	if(lpMP4)
		delete lpMP4;
	if(lpMPC)
		delete lpMPC;
	if(lpMPEG)
		delete lpMPEG;
	if(lpTrueAudio)
		delete lpTrueAudio;
	if(lpWavPack)
		delete lpWavPack;
	if(lpWav)
		delete lpWav;

	m_bIsValid	= true;
	return(true);
}