Cover of flac file

Гриша Ваника grish.vanika at gmail.com
Tue Oct 16 17:26:16 UTC 2012


Hi,

I'm not sure the correct address I asked.

I need to extract album cover from audio file. But i have some problems
with flac.
As i understand, the best way to do it is (file is TagLib::FLAC::File*):

        founded = extractFlac(file);


        if(!founded)

        {

            TagLib::ID3v2::Tag* tag = file->ID3v2Tag();

            if(tag)

                founded = extractId3(tag);

        }


*extractFlac *and *extractId3 *functions:

bool extractFlac(TagLib::FLAC::File* file)

{

    const TagLib::List<TagLib::FLAC::Picture*> picList = file->pictureList();

    if(!picList.isEmpty())

    {

        TagLib::FLAC::Picture* pic = picList.front();

        return saveData(pic->data());

    }


    return false;

}


 bool extractId3(TagLib::ID3v2::Tag* tag)

{

    const TagLib::ID3v2::FrameList& frameList = tag->frameList("APIC");

    if(!frameList.isEmpty())

    {

        TagLib::ID3v2::AttachedPictureFrame* frame =

            static_cast<TagLib::ID3v2::AttachedPictureFrame*>(frameList.front());

        return saveData(frame->picture());

    }


    return false;

}


But it doesn't work. Function *pictureList()* of
*TagLib::FLAC::File*always return empty list (file is valid and has
cover) and file does not
have ID3v2 tag.

I test it on Windows 32 bit and Ubuntu 12.04 32 bit ( *TagLib 1.8* ). Can
you help me?

And one another question. What about initializing *TagLib::FileRef* with
wchar_t* string on not Windows OS?
I mean *TagLib::**FileName *type

#ifdef _WIN32

  class TAGLIB_EXPORT FileName

  {

  public:

    FileName(const wchar_t *name) : m_wname(name) {}

    FileName(const char *name) : m_name(name) {}

    operator const wchar_t *() const { return m_wname.c_str(); }

    operator const char *() const { return m_name.c_str(); }

  private:

    std::string m_name;

    std::wstring m_wname;

  };

#else

  typedef const char *FileName;

#endif


I can't work with *TagLib::FileRef* and wide characters string?

According to the implementation of FileName class it will work fine on not
Windows OS too...

-- 
Best regards,
Grigoriy Vanika        mailto : grish.vanika at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20121016/d6900bdf/attachment.html>


More information about the taglib-devel mailing list