com.pelzer.util.mp3
Class MP3Util

java.lang.Object
  extended by com.pelzer.util.mp3.MP3Util

public final class MP3Util
extends Object

Currently almost-exclusively ID3-related tools relating to MP3. IF YOU USE THIS CLASS, you must add JID3 to your classpath, as its scope is listed as 'provided'.


Nested Class Summary
static class MP3Util.Metadata
          A POJO that stores the info to be encoded into an MP3 file's ID3.
 
Method Summary
static long bytesToLength(byte[] bytes)
          Takes an array of 4 bytes and converts it to a long, the way the ID3 tag expects it to be converted, which is to say that only 7 bits of each byte is used, giving a max value of 2^28.
static byte[] createID3Tag(MP3Util.Metadata metadata)
           
static long getID3v2Length(File file)
          Takes the given file, opens the header and reads the ID3v2 header size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bytesToLength

public static long bytesToLength(byte[] bytes)
Takes an array of 4 bytes and converts it to a long, the way the ID3 tag expects it to be converted, which is to say that only 7 bits of each byte is used, giving a max value of 2^28.


getID3v2Length

public static long getID3v2Length(File file)
                           throws IOException
Takes the given file, opens the header and reads the ID3v2 header size. The returned value is inclusive of the header preamble, so taking the returned value and skipping exactly that number of bytes will place the read cursor at the correct beginning of the actual MP3 data. If the ID3v2 header is missing or the file is shorter than 10 bytes, returns 0.

Throws:
IOException - in the case of error reading the file.

createID3Tag

public static byte[] createID3Tag(MP3Util.Metadata metadata)
                           throws org.blinkenlights.jid3.ID3Exception,
                                  IOException
Throws:
org.blinkenlights.jid3.ID3Exception
IOException


Copyright © 2012. All Rights Reserved.