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

Bill Fraser bill.fraser at gmail.com
Sun Sep 28 00:23:15 UTC 2014


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 { http://www.codewise.org/wrf }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20140927/9d82ed1b/attachment.html>


More information about the taglib-devel mailing list