Reputation: 23
I'm making an audioplayer for my course project in university. I'm a first-year student, so I'm not a professional programmer.
I'm using Qt 5.4 and QtCreator 3.3.1. I've included bass.dll and TagLib libraries to work with audiofiles. What am I trying to do is to get the song's cover art and pass it to QLabel (or any other widget if more convenient) on my player's GUI. I haven't really figured out how to do it. I've been searching for examples for a while but I always end up in having errors or wrong examples. Below is the last code I've tried to use.
TagLib::MPEG::File file(reinterpret_cast<const wchar_t*>(curSong->path.constData()));
TagLib::ID3v2::Tag *m_tag = file.ID3v2Tag(true);
TagLib::ID3v2::FrameList frameList = m_tag->frameList("APIC");
if(frameList.isEmpty()) {
return QImage();
}
TagLib::ID3v2::AttachedPictureFrame *coverImg = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(frameList.front());
QImage coverQImg;
coverQImg.loadFromData((const uchar *) coverImg->picture().data(), coverImg->picture().size());
return coverQImg;
This one doesn't work for me because it causes errors such as
C:\Qt\Projects\audioPlayer\mainwindow.cpp:553: error: undefined reference to `TagLib::List<TagLib::ID3v2::Frame*>::List(TagLib::List<TagLib::ID3v2::Frame*> const&)'
I suppose I've messed up with libraries, but I'm sure I've included id3v2frame.h and id3v2tag.h
Upvotes: 1
Views: 1727
Reputation: 11
You may explore a solution with ffmpeg
.
ffmpeg -i input.mp3 -an -vcodec copy cover.jpg
Upvotes: 0
Reputation: 10456
Not sure where you even found id3v3frame.h
(the latest version comes with id3v2frame.h
) but TagLib::ID3v2::FrameList
is declared in id3v2tag.h
.
Upvotes: 1