|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.vodafone.v10.sound.SoundTrack
SoundTrack is a class providing functions for sound data playback. The following explains the functionality available in this class:
SoundTrack objects are used to play individual sound data. The SoundPlayer object getTrack(int track)
or getTrack()
is used to get a SoundTrack object. The SoundTrack methods are classified broadly as indicated below in the following sub-sets.
The Java application must set sound data for playback in the SoundTrack object by calling the setSound()
method. A Sound object can be removed by calling removeSound()
. A Sound object that has been deleted can be set again by calling the setSound()
method. From the time sound starts playing until it is stopped, setSound()
and removeSound()
cannot be called. If they are called, an exception is thrown.
Prior to playback, a listener implementing the SoundTrackListener
interface is set using the SoundTrack object setEventListener()
method, in order to wait for receipt of sound playing-related events. These events are notified in parameters of the SoundTrackListener interface eventOccurred()
method. Event notification is made in the following cases.
The relation between user event values and sound data format depends on how the sound player is implemented in the native system.
When a Java application runs as a resident program and events for incoming voice calls, mail arrival or a scheduled alarm are notified, the sound player is stopped. In this case SoundTrackListener's eventOccurred()
method is not called.
After the sound player is stopped, the handset notifies the user of the incoming call, mail or alarm. Attempting to control the sound player at this time throws an exception. For details see the explanation of the ResidentMIDlet class.
1.3. Get Track State/Set Volume
Volume can be set before starting sound playback or during play. This is done using the setVolume() method. Sound can be muted with the mute() method. The isMute() method is used to find out whether sound is muted or not. The current track state is acquired using the getState() method. The following state information is provided.
When a SoundTrack object is acquired without designating the track number in the Java application, the SoundPlayer object automatically assigns a track number. The assigned track number can be found out by means of the SoundTrack object getID() method.
Once a Sound object is set in a SoundTrack object, playback can begin. The play, stop, pause and resume methods are described below.
When endless looping is designated with the play() method, eventually the stop() method must be called to stop playback. Methods for sound setting and removal (setSound()
and removeSound()
) cannot be called after playback starts until it is stopped. An exception is thrown if they are called.
A sound player can perform synchronous playback of different sound data.
This is possible only with sound data; synchronous play of audio data is not possible.
The setSubjectTo()
method is used to set synchronicity between tracks. The setSubjectTo()
method is called to designate SoundTrack objects as slave tracks of a master track. For example, if track0 is to be made the master track and track1 and track2 are to be slave tracks, the setSubjectTo()
method is called as follows for each slave track.
try{ .... track1.setSubjectTo(track0); track2.setSubjectTo(track0); } catch(...){ ...
In order to set synchronicity by the setSubjectTo()
method, the following conditions must be met.
The setSubjectTo()
method throws an exception if any of these conditions is not met.
To get the master track of a SoundTrack object defined as a slave track, call the getSyncMaster()
method of the SoundTrack object that is a slave track. If no synchronous relation is set, null is returned.
2.2. Cancel Synchronization
Synchronization of a slave track to a master track is canceled by calling the setSubjectTo()
method of the SoundTrack object set as slave track and setting null as its master track object. To clear all synchronous relations of a master track, the setSubjectTo()
method must be called for all its slave tracks. If track0 is master track with track1 and track2 as slave tracks, clearing all their synchronous relations is done as follows.
track1.setSubjectTo(null); track2.setSubjectTo(null);
When the removeSound()
method is called to remove sound data from a SoundTrack object for which a synchronous relation is set, that relation will be canceled.
Canceling a synchronous relation can be done only while a track is stopped. Attempting to cancel a synchronization setting while a track is playing will throw an exception.
Synchronous play is started and stopped by calling the play()
method and stop()
method of the SoundTrack object set as master track. If the slave track SoundTrack object play()
method or stop()
method is called, the request is completed normally but no operation is performed. (The request is ignored without starting or stopping play.)
When tracks set as synchronous are playing, event notification relating to individual track playback is made separately for each track.
Field Summary | |
static int |
NO_DATA
No data |
static int |
PAUSED
Paused |
static int |
PLAYING
Playing |
static int |
READY
Ready |
Method Summary | |
int |
getID()
Gets the track number. |
int |
getPanpot()
Gets the panpot setting (left-right position in soundfield). |
Sound |
getSound()
Gets the sound data set in a track. |
int |
getState()
Gets the track state. |
SoundTrack |
getSyncMaster()
Gets the master track for synchronous play. |
int |
getVolume()
Gets the playback volume. |
boolean |
isMute()
Gets the mute status. |
void |
mute(boolean mute)
Mutes playback. |
void |
pause()
Pauses playback |
void |
play()
Plays sound data. |
void |
play(int loop)
Repeats sound data playback. |
void |
removeSound()
Deletes the sound data setting in a track. |
void |
resume()
Resumes playback. |
void |
setEventListener(SoundTrackListener l)
Registers an event listener. |
void |
setPanpot(int value)
Sets the panpot (left-right position in soundfield). |
void |
setSound(Sound p)
Sets sound data in a track. |
void |
setSubjectTo(SoundTrack master)
Sets the association of slave tracks to a master track for synchronous play. |
void |
setVolume(int value)
Sets the playback volume. |
void |
stop()
Stops playback. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NO_DATA
public static final int READY
public static final int PLAYING
public static final int PAUSED
Method Detail |
public void setSound(Sound p)
p
- sound dataNullPointerException
- if parameter p is null.IllegalArgumentException
- if the number of tracks needed to play the sound data
differs from the number of allocated tracks.RuntimeException
- if the sound data could not be set in the native sound player.public Sound getSound()
public void removeSound()
IllegalStateException
- if SoundPlayer was not created.RuntimeException
- if sound data setting could not be deleted from the native sound player.public void play()
public void play(int loop)
The number of repetitions designated in the loop parameter can be any number from 1 to 255 for limited repetition. A setting of 1 means the data is played only once. Endless looping is set by designating 0.
No operation is performed when this method is called during playback.
loop:
- Number of repetitionsRuntimeException
- if the native sound player could not play.public void stop()
public void pause()
RuntimeException
- if the native sound player could not be paused.public void resume()
RuntimeException
- if the native sound player could not be resumed.public void mute(boolean mute)
mute
- Mute or not (true: mute, false: cancel mute)public int getState()
public void setVolume(int value)
value
- - Playback volume (0: silent, 127: maximum)IllegalArgumentException
- if the value parameter is not in the valid range.RuntimeException
- if the value could not be set in the native sound player.public int getVolume()
public void setPanpot(int value)
value
- - Position (0: left, 64: center, 127: right)IllegalArgumentException
- if the value parameter is not in the valid range.RuntimeException
- if the value could not be set in the native sound player.public int getPanpot()
public void setSubjectTo(SoundTrack master)
master
- Master trackRuntimeException
- if no native sound player was set.public SoundTrack getSyncMaster()
public int getID()
public void setEventListener(SoundTrackListener l)
l
- Event listenerpublic boolean isMute()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |