Load attached picture

Daniel Önnerby doep at onnerby.se
Wed May 21 11:23:22 CEST 2008


There is probably a smarter way to do this, but here's basically what I do:

TagLib::MPEG::File file("mytrack.mp3");
TagLib::ID3v2::Tag *tagv2      = file.ID3v2Tag();
if(tagv2){
    TagLib::ID3v2::FrameListMap tags    = tagv2->frameListMap();
   
    TagLib::ID3v2::FrameList pictures       = tags["APIC"];
    if(!pictures.isEmpty()){
        // Thumbnail exists
        // Just get the front() picture
        TagLib::ID3v2::AttachedPictureFrame *picture = 
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(pictures.front());
        TagLib::ByteVector pictureData  = picture->picture();
       
        int size      = pictureData.size();
        char *data      = pictureData.data();

        // Do something with the data
   
    }
}


Best regards
Daniel

Jordi Hernández wrote:
> Hi!
>
> I'm developing a quicklook for linux using opengl and I want to add 
> preview for many file types, one of them MP3, I found that your 
> library can extract the front cover but I get lost in how to do this
>
> Do you have any tutorial or a little piece of code where I can find 
> this simple function?
>
> From now I can show up any kind of images, PDFs and text files, but I 
> won't pots the source nor the bin till I have mp3 preview working!.
>
> So I would appreciate your help!
>
> You can see my projecte here:
>
> http://www.youtube.com/watch?v=fo09GRwbokU
> http://sourceforge.net/projects/gloobus
>
>
> Thanks a lot!
> -- 
> <font color=#666666> ___________________________________________________
> Jordi Hernández Puigdellívol | </font> <font 
> color=#33ccff>Jordi.HernandezP at gmail .com</font>
> ------------------------------------------------------------------------
>
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20080521/0b09e9cd/attachment.html 


More information about the taglib-devel mailing list