Exemplo n.º 1
0
 public Id3v1Tag(byte[] data) {
   myTitle = CamelUtils.getString(data, 3, 30, CamelUtils.DEFAULT_CHARSET).trim();
   myArtist = CamelUtils.getString(data, 33, 30, CamelUtils.DEFAULT_CHARSET).trim();
   myAlbum = CamelUtils.getString(data, 63, 30, CamelUtils.DEFAULT_CHARSET).trim();
   myYear = CamelUtils.getString(data, 93, 4, CamelUtils.DEFAULT_CHARSET).trim();
   myGenre = CamelUtils.getIntValue(data, 127, 1, false, Endianness.Big);
   if (CamelUtils.getIntValue(data, 126, 1, false, Endianness.Big) == 0x00) {
     myVersion11 = true;
     myTrackNumber = CamelUtils.getIntValue(data, 126, 1, false, Endianness.Big);
     myComment = CamelUtils.getString(data, 97, 28, CamelUtils.DEFAULT_CHARSET).trim();
   } else {
     myComment = CamelUtils.getString(data, 97, 30, CamelUtils.DEFAULT_CHARSET).trim();
   }
 }
Exemplo n.º 2
0
 public static Id3v1Tag createTag(InputStream stream) {
   try {
     byte[] tagBuffer = new byte[128];
     byte[] readBuffer = new byte[128];
     for (int count = stream.read(readBuffer); count > -1; count = stream.read(readBuffer)) {
       if (count > 0) {
         System.arraycopy(tagBuffer, count, tagBuffer, 0, 128 - count);
         System.arraycopy(readBuffer, 0, tagBuffer, 128 - count, count);
       }
     }
     if (CamelUtils.getIntValue(tagBuffer, 0, 3, false, Endianness.Big)
         == ('T' << 16 | 'A' << 8 | 'G')) {
       return new Id3v1Tag(tagBuffer);
     }
   } catch (IOException e) {
     // intentionally left blank
   }
   return null;
 }