Tablib and the composer tag

Stephen F. Booth me at sbooth.org
Sat Jan 12 06:39:02 CET 2008


> I am writing an application in which it would be useful to be able  
> to read MP3 tags.  I'm looking at using taglib, but if I am  
> understanding the class methods right, I can't get some fields.   
> Composer, specifically, is one I use a lot personally, I don't know  
> about other people.  It looks like I can get:
>
> virtual String  title () const =0
<snip>
>
> Am I misunderstanding this?  Is there a way to get other tags than  
> those?  It doesn't look like there is something like a "get tag by  
> name" kind of function (except for OGG tags).

You can access any ID3 frame present in the file, but to do so you  
need to use the TagLib::MPEG::File and TagLib::ID3v2::Tag classes.   
For example (typed in Mail):

	TagLib::MPEG::File f(filename, false);
	if(f.isValid()) {
		TagLib::ID3v2::Tag *id3v2tag = f.ID3v2Tag();
		if(tag) {
			TagLib::ID3v2::FrameList frameList = id3v2tag->frameListMap() 
["TCOM"];
			if(!frameList.isEmpty())
				std::cout << "Composer: " << frameList.front()- 
 >toString().toCString(true) << std::endl;
		}
	}

HTH,
Stephen


More information about the taglib-devel mailing list