public class HSound extends Object
HSound
class is used to represent an
audio clip.
Parameter | Description | Default value | Set method | Get method |
---|---|---|---|---|
None. |
Description | Default value | Set method | Get method |
---|---|---|---|
The starting position of any audio clip to be played. | At the beginning of the audio clip. | --- | --- |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
If the
HSound object is playing /
looping then it will be stopped. |
void |
load(String location)
Loads data synchronously into an
HSound object from an audio sample in the specified file. |
void |
load(URL contents)
Loads data synchronously into an
HSound object from an audio sample indicated by a URL. |
void |
loop()
Starts the
HSound class looping from
the beginning of its associated audio data. |
void |
play()
Starts the
HSound class playing from
the beginning of its associated audio data. |
void |
set(byte[] data)
Constructs an
HSound object from an
array of bytes encoded in the same encoding format as when
reading this type of audio sample data from a file. |
void |
stop()
Stops the
HSound class playing its
associated audio data. |
public HSound()
HSound
object. See the
class description for details of constructor parameters and
default values.public void load(String location) throws IOException, SecurityException
HSound
object from an audio sample in the specified file. If
the object already contains data, this method shall perform the
following sequence:
dispose
method had been
called.
location
- the name of a file containing audio data in a
recognized file format.IOException
- if the sample cannot
be loaded due to an IO problem.SecurityException
- if the caller does
not have sufficient rights to access the specified audio sample.public void load(URL contents) throws IOException, SecurityException
HSound
object from an audio sample indicated by a URL. If
the object already contains data, this method shall perform the
following sequence:
dispose
method had been
called.
contents
- a URL referring to the data to load.IOException
- if the audio sample cannot be
loaded due to an IO problem.SecurityException
- if the caller does not have
sufficient rights to access the specified audio sample.public void set(byte[] data)
HSound
object from an
array of bytes encoded in the same encoding format as when
reading this type of audio sample data from a file. If
the object already contains data, this method shall perform the
following sequence:
dispose
method had been
called.
If the byte array does not contain a valid audio sample then this
method shall throw a
java.lang.IllegalArgumentException
.
data
- the data for the HSound
object encoded in the specified format for audio sample
files of this type.public void play()
HSound
class playing from
the beginning of its associated audio data. If the sample data
has not been completely loaded, this method has no effect.
When the audio data has been played in its entirety then no further audible output should be made until the next play or loop method is invoked. Note that the audio data is played back asynchronously. There is no mechanism for synchronization with other classes presenting sounds, images, or video.
This method may fail "silently" if (local) audio facilities are unavailable on the platform.
public void stop()
HSound
class playing its
associated audio data.
Note that, if a play or loop method is invoked, after a stop, then presentation of the audio data will restart from the beginning of the audio data, rather than from the position where the audio data was stopped.
public void loop()
HSound
class looping from
the beginning of its associated audio data. If the sample data
has not been completely loaded, this method has no effect.
When the audio data has been played in its entirety, then it should be played again from the beginning of its associated data, so as to cause a "seamless" continuous (infinite) audio playback - until the next stop, or play method is invoked. Note that the audio data is played back asynchronously, there is no mechanism for synchronization with other classes presenting sounds, images, or video.
This method may fail "silently" if (local) audio facilities are unavailable on the platform.
public void dispose()
Copyright © 2013 CableLabs. All rights reserved.