Package org.faceless.pdf2
Class PDFSound
- java.lang.Object
-
- org.faceless.pdf2.PDFSound
-
-
Constructor Summary
Constructors Constructor Description PDFSound(InputStream in)
Create a new PDFSound from the specified InputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
clone()
void
close()
Close the sound object.AudioInputStream
getAudioInputStream()
Return anAudioInputStream
of this object.Reader
getMetaData()
Return any XML metadata associated with this object.int
getRate()
Return the number of samples/second this sound is played at.XMP
getXMP()
Return an XMP Metadata object representing any XML metadata associated with this objectvoid
putLiteral(String key, String tokens)
Put a literal token sequnce.void
setMetaData(String xmldata)
Set the XML metadata associated with this object.String
toString()
-
-
-
Constructor Detail
-
PDFSound
public PDFSound(InputStream in) throws IOException
Create a new PDFSound from the specified InputStream. The stream can be any type of Audio file that is supported by the
AudioSystem
, or if that system is not enabled for any reason, PCM WAV formats can be parsed directly.- 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
-
getAudioInputStream
public AudioInputStream getAudioInputStream()
Return anAudioInputStream
of this object.- Since:
- 2.11.7
-
setMetaData
public void setMetaData(String xmldata)
Set the XML metadata associated with this object. Since 2.26 this method callsgetXMP().read(new StringReader(xmldata == null ? "" : xmldata))
. We strongly recommend using thegetXMP()
method and modifying the XMP directly rather than using this method.- 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
- See Also:
getXMP()
-
getMetaData
public Reader getMetaData() throws IOException
Return any XML metadata associated with this object.
Since 2.26 this simply returns
getXMP().isEmpty() ? null : new StringReader(getXMP().toString())
. It is strongly recommended that any code migrates to using thegetXMP()
method.Since 2.24.3, the returned type is guaranteed to hava a
toString()
method that will return the Metadata as a String.- 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
- See Also:
getXMP()
-
getXMP
public XMP getXMP()
Return an XMP Metadata object representing any XML metadata associated with this object- Returns:
- the XMP, which may be empty or invalid but wil never be null
- Since:
- 2.26
-
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
-
putLiteral
public void putLiteral(String key, String tokens)
Put a literal token sequnce. For debugging- Parameters:
key
- the keytokens
- the token sequence, eg "true" or "/foo" or "[/Foo/Bar]". No refs, just direct objects.
-
-