Methods Summary |
---|
public void | findStream()Reads the stream block to ensure it is a flac file
//Begins tag parsing
if (raf.length() == 0)
{
//Empty File
throw new CannotReadException("Error: File empty");
}
raf.seek(0);
//FLAC Stream at start
if (isFlacHeader())
{
startOfFlacInFile = 0;
return;
}
//Ok maybe there is an ID3v24tag first
if (isId3v2Tag())
{
startOfFlacInFile = (int) (raf.getFilePointer() - FLAC_STREAM_IDENTIFIER_LENGTH);
return;
}
throw new CannotReadException(ErrorMessage.FLAC_NO_FLAC_HEADER_FOUND.getMsg());
|
public int | getStartOfFlacInFile()Usually flac header is at start of file, but unofficially and ID3 tag is allowed at the start of the file.
return startOfFlacInFile;
|
private boolean | isFlacHeader()
//FLAC Stream at start
byte[] b = new byte[FLAC_STREAM_IDENTIFIER_LENGTH];
raf.read(b);
String flac = new String(b);
return flac.equals(FLAC_STREAM_IDENTIFIER);
|
private boolean | isId3v2Tag()
raf.seek(0);
if(AbstractID3v2Tag.isId3Tag(raf))
{
logger.warning(ErrorMessage.FLAC_CONTAINS_ID3TAG.getMsg(raf.getFilePointer()));
//FLAC Stream immediately after end of id3 tag
if (isFlacHeader())
{
return true;
}
}
return false;
|