|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.sound.AAudio
public class AAudio
Represents an audio. Unlike javax.sound.AudioClip, this class is used only to hold the raw data as opaque rather than manipulate the sound.
In other words, it is used to retrieve and store the opaque data
as polymorphic thru the Media interface.
AAudio is serializable, but, if you are using InputStream,
you have to extend this class, and provide the implementation to
serialize and deserialize _isdata. (Since 5.0.11)
| Field Summary | |
|---|---|
protected InputStream |
_isdata
The raw data in stream (or DYNAMIC_STREAM). |
protected static InputStream |
DYNAMIC_STREAM
Used if you want to implement a media whose input stream is created dynamically each time getStreamData() is called. |
| Constructor Summary | |
|---|---|
AAudio(File file)
Constructs an audio with a file. |
|
AAudio(InputStream is)
Creates an instance of an audio with an input stream. |
|
AAudio(String filename)
Constructs an audio with a file name. |
|
AAudio(String name,
byte[] data)
|
|
AAudio(String name,
InputStream isdata)
Creates an instance of an audio with an input stream. |
|
AAudio(URL url)
Constructs an audio with an URL. |
|
| Method Summary | |
|---|---|
byte[] |
getByteData()
Returns the raw data in byte array. |
String |
getContentType()
Returns the content type, e.g., "image/jpeg", or null if not available. |
String |
getFormat()
Returns the format name, e.g., "jpeg", or null if not available. |
String |
getName()
Returns the name (usually filename) of this media, or null if not available. |
Reader |
getReaderData()
Not supported. |
InputStream |
getStreamData()
Returns the data in the input stream. |
String |
getStringData()
Always throws IllegalStateException. |
boolean |
inMemory()
Returns whether the data is cached in memory (in form of byte[] or String). |
boolean |
isBinary()
Returns whether the format of this content is binary or text-based. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final InputStream DYNAMIC_STREAM
getStreamData() is called.
AAudio(String,,InputStream)protected final transient InputStream _isdata
DYNAMIC_STREAM).
Exactly one of _data and _isdata is not null.
| Constructor Detail |
|---|
public AAudio(String name,
byte[] data)
throws IOException
IOException
public AAudio(String name,
InputStream isdata)
throws IOException
getStreamData() is called,
you can pass DYNAMIC_STREAM to the data argument, and then
override getStreamData().
Note: the caller of getStreamData() has to close
the returned input stream.
IOExceptionpublic AAudio(URL url)
public AAudio(File file)
public AAudio(String filename)
throws IOException
IOException
public AAudio(InputStream is)
throws IOException
getStreamData() is called,
you can pass DYNAMIC_STREAM to the data argument, and then
override getStreamData().
Note: the caller of getStreamData() has to close
the returned input stream.
IOException| Method Detail |
|---|
public final boolean isBinary()
MediaMedia.getByteData() or Media.getStreamData()
to retrieve its content.
If false, use Media.getStringData() or Media.getReaderData()
to retrieve its content.
isBinary in interface MediaMedia.getStringData(),
Media.getByteData(),
Media.getReaderData(),
Media.getStreamData()public final boolean inMemory()
Media
inMemory in interface MediaMedia.getStringData(),
Media.getByteData(),
Media.getReaderData(),
Media.getStreamData()public byte[] getByteData()
MediaIt might not be a copy, so don't modify it directly unless you know what you are doing.
If the data is not cached in memory (Media.inMemory() return false),
the data will be read from Media.getStreamData(). Furthermore, it
also implies you can not invoke this method again.
getByteData in interface MediaMedia.getStringData()public final String getStringData()
getStringData in interface MediaMedia.getByteData()public InputStream getStreamData()
Note: the caller has to invoke InputStream.close()
after using the input stream returned by getStreamData().
getStreamData in interface MediaMedia.getReaderData()public final Reader getReaderData()
getReaderData in interface MediaMedia.getStreamData()public final String getName()
Media
getName in interface Mediapublic String getFormat()
Media
getFormat in interface MediaMedia.getContentType()public String getContentType()
Media
getContentType in interface MediaMedia.getFormat()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||