FileDocCategorySizeDatePackage
OggFileReader.javaAPI DocJaudiotagger 2.0.45158Wed Mar 30 16:11:54 BST 2011org.jaudiotagger.audio.ogg

OggFileReader

public class OggFileReader extends org.jaudiotagger.audio.generic.AudioFileReader
Read Ogg File Tag and Encoding information

Only implemented for ogg files containing a vorbis stream with vorbis comments

Fields Summary
public static Logger
logger
private org.jaudiotagger.audio.ogg.util.OggInfoReader
ir
private OggVorbisTagReader
vtr
Constructors Summary
public OggFileReader()


     
    
        ir = new OggInfoReader();
        vtr = new OggVorbisTagReader();
    
Methods Summary
protected org.jaudiotagger.audio.generic.GenericAudioHeadergetEncodingInfo(java.io.RandomAccessFile raf)

        return ir.read(raf);
    
protected org.jaudiotagger.tag.TaggetTag(java.io.RandomAccessFile raf)

        return vtr.read(raf);
    
public org.jaudiotagger.audio.ogg.util.OggPageHeaderreadOggPageHeader(java.io.RandomAccessFile raf, int count)
Return count Ogg Page header, count starts from zero

count=0; should return PageHeader that contains Vorbis Identification Header count=1; should return Pageheader that contains VorbisComment and possibly SetupHeader count>=2; should return PageHeader containing remaining VorbisComment,SetupHeader and/or Audio

param
raf
param
count
return
throws
CannotReadException
throws
IOException

        OggPageHeader pageHeader = OggPageHeader.read(raf);
        while (count > 0)
        {
            raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
            pageHeader = OggPageHeader.read(raf);
            count--;
        }
        return pageHeader;
    
public voidshortSummarizeOggPageHeaders(java.io.File oggFile)
Summarizes the first five pages, normally all we are interested in

param
oggFile
throws
CannotReadException
throws
IOException

        RandomAccessFile raf = new RandomAccessFile(oggFile, "r");

        int i = 0;
        while (raf.getFilePointer() < raf.length())
        {
            System.out.println("pageHeader starts at absolute file position:" + raf.getFilePointer());
            OggPageHeader pageHeader = OggPageHeader.read(raf);
            System.out.println("pageHeader finishes at absolute file position:" + raf.getFilePointer());
            System.out.println(pageHeader + "\n");
            raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
            i++;
            if(i>=5)
            {
                break;
            }
        }
        System.out.println("Raf File Pointer at:" + raf.getFilePointer() + "File Size is:" + raf.length());
        raf.close();
    
public voidsummarizeOggPageHeaders(java.io.File oggFile)
Summarize all the ogg headers in a file

A useful utility function

param
oggFile
throws
CannotReadException
throws
IOException

        RandomAccessFile raf = new RandomAccessFile(oggFile, "r");

        while (raf.getFilePointer() < raf.length())
        {
            System.out.println("pageHeader starts at absolute file position:" + raf.getFilePointer());
            OggPageHeader pageHeader = OggPageHeader.read(raf);
            System.out.println("pageHeader finishes at absolute file position:" + raf.getFilePointer());
            System.out.println(pageHeader + "\n");
            raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
        }
        System.out.println("Raf File Pointer at:" + raf.getFilePointer() + "File Size is:" + raf.length());
        raf.close();