com.samsung.util
Class AudioClip

java.lang.Object
  |
  +--com.samsung.util.AudioClip

public class AudioClip
extends java.lang.Object

An AudioClip plays, stops, resumes or pauses audio data received from the file or buffer.

Simple AudioClip Example

 if(AudioClip.isSupported()) {
    String path = new String("\resource\sample.mmf")
    AudioClip audioClip = new AudioClip(TYPE_MMF,path);
    
    audioClip.play(1, 5);
    audioClip.pause();
    audioClip.resume();
    audioClip.stop();
 }
 


Field Summary
static int TYPE_MIDI
          The "MIDI" audio type constant.
static int TYPE_MMF
          The "MMF" audio type constant.
static int TYPE_MP3
          The "MP3" audio type constant.
 
Constructor Summary
AudioClip(int type, byte[] audioData, int audioOffset, int audioLength)
          Constructs a new instance of AudioClip with type and data which stored in the specified byte array at the specified offset and length.
AudioClip(int type, java.lang.String filename)
          Constructs a new instance of AudioClip with type and data from the named resource.
 
Method Summary
static boolean isSupported()
          Gets an information whether audio clip is supported by the device.
 void pause()
          Pauses audio.
 void play(int loop, int volume)
          Plays audio with specified volume for specified loop.
 void resume()
          Resumes audio on a paused position.
 void stop()
          Stops the audio and releases its resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_MMF

public static final int TYPE_MMF
The "MMF" audio type constant.

Value 1 is assigned to TYPE_MMF.

See Also:
Constant Field Values

TYPE_MP3

public static final int TYPE_MP3
The "MP3" audio type constant. Current devices only support TYPE_MMF.

Value 2 is assigned to TYPE_MP3.

See Also:
Constant Field Values

TYPE_MIDI

public static final int TYPE_MIDI
The "MIDI" audio type constant. Current devices only support TYPE_MMF.

Value 3 is assigned to TYPE_MIDI.

See Also:
Constant Field Values
Constructor Detail

AudioClip

public AudioClip(int type,
                 byte[] audioData,
                 int audioOffset,
                 int audioLength)
Constructs a new instance of AudioClip with type and data which stored in the specified byte array at the specified offset and length.

Parameters:
type - one of TYPE_MMF, TYPE_MP3, or TYPE_MIDI, Current devices only support TYPE_MMF.
audioData - the array of audio data in a supported audio format
audioOffset - offset of audio data
audioLength - length of audio data
Throws:
java.lang.IllegalArgumentException - if type is not legal values
java.lang.NullPointerException - if audioData is null
java.lang.ArrayIndexOutOfBoundsException - if audioOffset or audioLength specify an invalid range

AudioClip

public AudioClip(int type,
                 java.lang.String filename)
          throws java.io.IOException
Constructs a new instance of AudioClip with type and data from the named resource.

Parameters:
type - one of TYPE_MMF, TYPE_MP3, or TYPE_MIDI, Current devices only support TYPE_MMF.
filename - the name of the resource containing the audio data in one of the supported audio formats
Throws:
java.lang.IllegalArgumentException - if type is not legal values
java.lang.NullPointerException - if filename is null
java.io.IOException - if the resource does not exist
Method Detail

play

public void play(int loop,
                 int volume)
Plays audio with specified volume for specified loop. Only one AudioClip can be heared at the same time. Active AudioClip will be replaced with latest called clip if more than one clip are played.

Parameters:
loop - range 0 to 255
volume - range from 0 to 5
Throws:
java.lang.IllegalArgumentException - Thrown if loop, or volume are invalid value.
java.lang.IllegalStateException - Thrown if the device does not support AudioClip

stop

public void stop()
Stops the audio and releases its resources.

If stop is called on a stopped AudioClip the request is ignored.

Throws:
java.lang.IllegalStateException - Thrown if the device does not support AudioClip

pause

public void pause()
Pauses audio. The current position is saved. Use the resume() to resume audio from the current position.

Throws:
java.lang.IllegalStateException - Thrown if the device does not support AudioClip
See Also:
resume

resume

public void resume()
Resumes audio on a paused position.

Throws:
java.lang.IllegalStateException - Thrown if the device does not support AudioClip
See Also:
pause

isSupported

public static boolean isSupported()
Gets an information whether audio clip is supported by the device.

Returns:
true if the AudioClip is supported.