use of org.jaudiotagger.tag.id3.AbstractID3v2Tag in project MusicDNA by harjot-oberai.
the class ID3Chunk method readChunk.
@Override
public boolean readChunk() throws IOException {
// TODO Auto-generated method stub
if (!isId3v2Tag()) {
// Bad ID3V2 tag
return false;
}
int version = raf.read();
AbstractID3v2Tag id3Tag;
switch(version) {
case 2:
id3Tag = new ID3v22Tag();
AudioFile.logger.finest("Reading ID3V2.2 tag");
break;
case 3:
id3Tag = new ID3v23Tag();
AudioFile.logger.finest("Reading ID3V2.3 tag");
break;
case 4:
id3Tag = new ID3v24Tag();
AudioFile.logger.finest("Reading ID3V2.4 tag");
break;
default:
// bad or unknown version
return false;
}
aiffTag.setID3Tag(id3Tag);
// back up to start of tag
raf.seek(raf.getFilePointer() - 4);
byte[] buf = new byte[(int) bytesLeft];
raf.read(buf);
ByteBuffer bb = ByteBuffer.allocate((int) bytesLeft);
bb.put(buf);
try {
id3Tag.read(bb);
} catch (TagException e) {
AudioFile.logger.info("Exception reading ID3 tag: " + e.getClass().getName() + ": " + e.getMessage());
return false;
}
return true;
}
Aggregations