public static ID3Tag read(final File file) throws IOException { long offset = file.length() - ID3_TAG_BYTES; if (offset < 0) return null; file.seek(offset); try { final ID3Tag tag = new ID3Tag(); final ByteArrayReader reader = new ByteArrayReader(file, ID3_TAG_BYTES); tag.Header = reader.readString(3, defaultEncoding); tag.Title = reader.readString(30, defaultEncoding); tag.Artist = reader.readString(30, defaultEncoding); tag.Album = reader.readString(30, defaultEncoding); tag.Year = reader.readString(4, defaultEncoding); tag.Comment = reader.readString(29, defaultEncoding); tag.Track = reader.readUnsignedByte(); tag.Genre = reader.readUnsignedByte(); return tag.Header.equals("TAG") ? tag : null; } catch (EOFException e) { return null; } }
public void Start( String pOutputFilename, WaveFormat pwfeInput, int nMaxAudioBytes, int nCompressionLevel, byte[] pHeaderData, int nHeaderBytes) throws IOException { m_pioOutput = File.createFile(pOutputFilename, "rw"); m_bOwnsOutputIO = true; m_spAPECompressCreate.Start( m_pioOutput, pwfeInput, nMaxAudioBytes, nCompressionLevel, pHeaderData, nHeaderBytes); m_nBufferSize = m_spAPECompressCreate.GetFullFrameBytes(); m_pBuffer = new byte[m_nBufferSize]; m_wfeInput = pwfeInput; }