Menu

#45 id3v1 version differences fix

open
nobody
None
5
2005-04-13
2005-04-13
Anonymous
No

When reading an id3v1 tag, the code should check if the
byte directly after the 28th comment byte is truly 0,
else it is probably an id3v1.0 tag. Here is a revised
constructor for the Id3v1Tag class:

public Id3v1Tag(ByteBuffer theBuffer) throws
InstantiationException {

byte[] header = new byte[3];
theBuffer.get(header);

System.out.println(new String(header));
System.out.println("bow" + header[0] + " " +
header[1] + " "
+ header[2]);
System.out.println(Arrays.equals(header, TAG));
if (theBuffer.limit() == 128 &&
Arrays.equals(header, TAG)) {
byte[] tempArray = new byte[FIELD_SIZE];
System.out.println(theBuffer);
theBuffer.get(tempArray);
this.title = new String(tempArray);
theBuffer.get(tempArray);
this.artist = new String(tempArray);
System.out.println(theBuffer);
theBuffer.get(tempArray);
this.album = new String(tempArray);
System.out.println(theBuffer);
tempArray = new byte[4];
theBuffer.get(tempArray);
this.year = new String(tempArray);
System.out.println(theBuffer);
tempArray = new byte[FIELD_SIZE - 2];
theBuffer.get(tempArray);
this.comment = new String(tempArray);

tempArray = new byte[2];
theBuffer.get(tempArray); //get next two bytes
if(tempArray[0]==0){ //if it is 0, we have
a 1.1 tag
this.track = tempArray[1];
tagVersion = "1.1";
} else { //else it is a 1.0 tag, and the
two bytes are part of the comment
this.comment += new String(tempArray);
}
this.genre = theBuffer.get();
System.out.println(theBuffer);

} else {
throw new InstantiationException(
"Cant creat new tag because Tag is
invalid");
}

}

Hope it helps
Cheers

roket.scyntist at gmail dot com

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.