org.faceless.pdf2
Class PDFSound

java.lang.Object
  extended byorg.faceless.pdf2.PDFObject
      extended byorg.faceless.pdf2.PDFStream
          extended byorg.faceless.pdf2.PDFSound
All Implemented Interfaces:
Cloneable

public final class PDFSound
extends org.faceless.pdf2.PDFStream

A PDFSound represents an audio sample in a PDF document. Valid types of audio sample include:

Note that although in theory all these sound formats are allowed in PDF documents, our own tests have found incomplete support in Acrobat reader for anything other than WAV audio files.

Sound is unlikely to work in anything other than Adobes own Acrobat products on Windows and Macintosh platforms. Your mileage may vary.

Since:
1.1

Constructor Summary
PDFSound(InputStream in)
          Create a new PDFSound from the specified input file.
 
Method Summary
 void close()
          Close the sound object.
 Reader getMetaData()
          Return any XML metadata associated with this object.
 int getRate()
          Return the number of samples/second this sound is played at.
 InputStream getStream()
          Return the sampled sound file encapsulated by this PDFSound object.
 String getType()
          Return the type of sound file this sound represents.
 void setMetaData(String xmldata)
          Set the XML metadata associated with this object.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PDFSound

public PDFSound(InputStream in)
         throws IOException
Create a new PDFSound from the specified input file. The file may be a RIFF (.wav), AIFF, AIFF-C or Sun .au audio file (although see our note in the class header). Note the InputStream is not closed by this constructor - it should be closed by the user

Throws:
IOException - if the file format is invalid
Method Detail

getRate

public int getRate()
Return the number of samples/second this sound is played at. Common values are 8000, 11025 or 22050

Since:
1.1.12

getType

public String getType()
Return the type of sound file this sound represents. Values are either "RIFF" for Microsoft WAV files, "AU" for Sun Audio files, "AIFF" or "AIFC" for Apple AIFF or AIFF (compressed) files respectively. If the type of file cannot be recognised, returns null

Since:
1.1.12

getStream

public InputStream getStream()
Return the sampled sound file encapsulated by this PDFSound object. Remember to close or reset the stream once it's been used, as the next call to this method will return the same stream - presumably with the cursor at the end of the stream.

Since:
2.2 - this method has existed since 1.1.12 but returned a byte array instead.

setMetaData

public void setMetaData(String xmldata)
Set the XML metadata associated with this object. See PDF.setMetaData(java.lang.String) for more information.

Parameters:
xmldata - the XML data to embed into the document, or null to clear any existing metadata. No validation is performed on this input.
Since:
1.1.12

getMetaData

public Reader getMetaData()
                   throws IOException
Return any XML metadata associated with this object. See the PDF.getMetaData() for more information

Returns:
a Reader containing the source of the XML or null if no metadata is available.
Throws:
IOException - if the metadata can't be extracted
Since:
1.1.12

toString

public String toString()

close

public void close()
Close the sound object. This will prevent any further changes from being made to the object, but will potentially free up some resources as well.

Since:
2.2


Copyright © 2001-2004 Big Faceless Organization