Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to access Tags from Media Files?

How to access Tags from Media Files?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    inblueswithu
    wrote on last edited by
    #1

    Hi,

    Anyone can help me If Qt has any extensions for accessing tags (Artist, Album, Song, cover image etc info) from media (mp3) files. I saw ID3v2, It seems very tough to use that. I tried using TagLib but I'm getting one or other error :(
    Can someone help me if there is any good library?

    Thanks in Advance,
    inblueswithu

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hardcodes.de
      wrote on last edited by
      #2

      AFAIK there is nothing inside Qt. TagLib works quite fine for me, what errors do you get?

      while(!sleep){++sheep;}

      1 Reply Last reply
      0
      • I Offline
        I Offline
        inblueswithu
        wrote on last edited by
        #3

        For now I'm thinking of using QMediaMetaData (just found a day ago) to get the current song data from media player.
        But for full fledged tags usage I need some library (like TagLib) as Qt does not have a in-built.
        I'll try again to compile it & will comeback for help.
        Thanks!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mehrdadsilver
          wrote on last edited by
          #4

          try this class:

          class Mp3Metadata
          {
          public:
          Mp3Metadata();
          virtual ~Mp3Metadata();
          QMap<QString, QString> getMp3Metadata(QString arquivo);
          private:

          };

          It works, but after the

          QMap<QString, QString> Mp3Metadata::getMp3Metadata(QString caminhoArquivo)
          {
          QMap<QString, QString> m;
          if(!caminhoArquivo.contains(".mp3"))
          return m;

          ifstream arquivo(caminhoArquivo.toLatin1().data(), ios::in | ios::binary);
          if(!arquivo)
          {
          return m;
          }
          char *tag = new char[3];
          arquivo.seekg(-128, ios::end);
          arquivo.read(tag, 3);
          QString QStag(tag);
          if(QStag != "TAG")
          {
          delete[] tag;
          return m;
          }
          char *titulo = new char[30];
          arquivo.read(titulo, 30);

          char *artista = new char[30];
          arquivo.read(artista, 30);

          char *album = new char[30];
          arquivo.read(album, 30);

          char *ano = new char[4];
          arquivo.read(ano, 4);

          char *comentario = new char[30];
          arquivo.read(comentario, 30);

          char *genero = new char[1];
          arquivo.read(genero, 1);

          QMessageBox *mb = new QMessageBox();
          QString s;
          s.append(tag);
          s.append("\n");
          s.append(titulo);
          s.append("\n");
          s.append(artista);
          s.append("\n");
          s.append(album);
          s.append("\n");
          s.append(ano);
          s.append("\n");
          s.append(comentario);
          s.append("\n");
          s.append(genero);
          mb->setText(s);
          mb->show();

          delete[] tag;
          delete[] titulo;
          delete[] artista;
          delete[] album;
          delete[] ano;
          delete[] comentario;
          delete[] genero;
          return m;
          }

          Mehrdad Abdolghafari, Be silver

          1 Reply Last reply
          0
          • I Offline
            I Offline
            inblueswithu
            wrote on last edited by
            #5

            @mehrdadsilver: Thank you for reply.

            But can you please specify the include files for this working & I'm not sure if this code is Spanish specific.!? Can you please clarity.
            By the way, can you please paste the code in between @ @ so that there wont be any special chars like those char power of 30 etc

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved