Is there a way to get the specific Tag implementation from the generic one?

Sander Jansen s.jansen at
Mon Sep 29 13:48:26 UTC 2014

Here's what I use in my music player:

Basically, dynamic_casts to get the specific tag container and then query
specific things from it.

On Sat, Sep 27, 2014 at 7:23 PM, Bill Fraser <bill.fraser at> wrote:

> Hello,
> I'm using TagLib in a program which, among other things, needs to get the
> "albumartist" field from a bunch of music in different formats.
> I see that the TagLib::Tag generic interface doesn't contain albumartist
> (presumably because not all tag types have this property), but a number of
> the specific Tag implementations do have it (ID3v2 and XiphComment, at
> least).
> To get at this property, the first thing I tried was to use the generic
> Tag's properties() method and look for an "albumartist" property, but this
> doesn't work (though it does work on ID3v2 and XiphComment).
> The next thing I tried was to take the Tag pointer returned by File and
> dynamic_cast it to ID3v2::Tag*, XiphComment::Tag*, etc., so I could use
> their properties() methods, but this doesn't work either.
> So it looks like the only way to get this is to figure out the file type
> myself (based on file extension or whatever) and instantiate the specific
> Tag implementation myself. This seems kind of round-about to me, since
> obviously the generic Tag implementation has to do this already to provide
> me the few fields that it's capable of.
> So my questions are:
> 1. Why doesn't generic Tag::properties() work with "albumartist"?
> 2. How can I get at the specific Tag implementation being used?
> Everything else I've done with TagLib has been freaking awesome. I love
> how I don't have to do file type detection -- everything else just works --
> so I'll be rather disappointed if I have to start doing that.
> Thanks!
> --
> Bill Fraser { }
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the taglib-devel mailing list