How to access Tags from Media Files?
-
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 -
AFAIK there is nothing inside Qt. TagLib works quite fine for me, what errors do you get?
-
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! -
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;
} -
@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