|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Remote interface for starting, stopping, or modifying an audio track on a client.
Some definitions:
Music is generally not time-sequenced: players in the same map may not be hearing the same music, or may be hearing it playing at completely different points in the soundtrack.
Alerts are very simple: once one is started, it can't be stopped or modified, and the client will play it until it's finished. The client does not send a notification back to the server when it has finished playing an Alert.
You can specify optional parameters to an Alert when you play it, but once it's sent to the client, you can no longer modify them for that alert sound. Multiple alerts can be playing at the same time on the client, and alerts are usually only heard by one player.
Unlike Music and Alerts, Sounds each have a unique ID sent to the client so that they can be stopped or modified (e.g. changing the volume). This is because if a player leaves a room where a sound is playing, the server needs to shut it off immediately for that player. The client must send a notification back when it has finished playing a Sound, because the server needs to be able to stop listening for the player to move towards or away from the sound.
When you issue a request to play an audio track of any kind, the client will check if it's missing the file, or has an outdated version. If so, it sends a request to the server to begin downloading the file. Each client implementation can decide what it wants to do at that point. Usually it will skip the track if it doesn't have it at all, and play the outdated version if it has one. If it skips the track, it will still send a notification back to the server if it was a Music or Sound track.
Field Summary | |
static double |
DEFAULT_ALERT_GAIN
Volume level for Alerts. |
static int |
DEFAULT_ALERT_REPEAT_DELAY
Alerts have no repeat delay by default, since they don't repeat. |
static int |
DEFAULT_ALERT_REPEATS
Alerts just play once, by default. |
static double |
DEFAULT_GAIN
Default gain of 0.5 means "not louder or softer than the file would normally play on the user's computer." 0.0 is silent, 1.0 is max volume. |
static int |
DEFAULT_REPEAT_DELAY
Default amount of time to wait between repeats on soundtracks, if not specified by the owner. |
static int |
DEFAULT_REPEATS
Default number of repeats to perform, if not otherwise specified, for map background music |
Method Summary | |
void |
pauseSound(java.lang.String id)
Pauses a particular sound. |
void |
playAlert(java.lang.String path)
Plays the specified sound file on the client, one repeat, no delay, and the default gain. |
void |
playAlert(java.lang.String path,
int repeats,
int repeatDelay,
double gain)
Plays the specified alert with custom parameters. |
void |
playDefaultMusic()
The player has switched maps, so figure out the default background music to be playing, and plays it. |
void |
playPriorityMusic(java.lang.String path)
Sets the background music track to the specified file, with the default gain/volume. |
void |
playPriorityMusic(java.lang.String path,
int repeats,
int repeatDelay,
double gain)
Plays the specified music with custom parameters. |
void |
playSound(java.lang.String path,
java.lang.String id)
Plays a sound effect on the client with the default gain. |
void |
playSound(java.lang.String path,
java.lang.String id,
int repeats,
int repeatDelay,
double gain)
Plays the specified sound effect with custom parameters. |
void |
resumeSound(java.lang.String id)
Resumes a particular sound. |
void |
setMusicGain(double gain)
Sets the volume of the background music. |
void |
setSoundGain(java.lang.String id,
double gain)
Sets the volume of a particular sound playing on the client. |
void |
stopAllSounds()
Stops all of the currently playing sounds on the client. |
void |
stopMusic()
Stops the background music completely. |
void |
stopSound(java.lang.String id)
Stops the specified sound effect. |
Field Detail |
public static final int DEFAULT_REPEAT_DELAY
public static final int DEFAULT_REPEATS
public static final double DEFAULT_GAIN
public static final int DEFAULT_ALERT_REPEATS
public static final int DEFAULT_ALERT_REPEAT_DELAY
public static final double DEFAULT_ALERT_GAIN
Method Detail |
public void playAlert(java.lang.String path)
Can't be stopped, so use with care.
path
- the relative path to the sound filepublic void playAlert(java.lang.String path, int repeats, int repeatDelay, double gain)
Parameters are file path, number of repeats, delay between repeats, and gain (volume). The alert won't play if the path is null or not found on the server. All other params are adjusted to be within the valid range for the parameter, if necessary.
path
- the relative path to the sound file.repeats
- number of times the client should repeat
the piece before stopping (and for music and sound,
sending the notification back to the server). 0 means
don't repeat; just play and stop.repeatDelay
- number of milliseconds to pause
between repeats, if we're repeating.gain
- the volume for this track, from 0.0 to 1.0public void playDefaultMusic()
public void playPriorityMusic(java.lang.String path)
Client sends an "#endmusic" directive back to the server when it's finished playing all the repeats.
When this playMusic() is called, the specified music overrides the current background music. The player is considered to be playing the soundtrack in "priority" mode, meaning that switching maps or combat states won't revert it back to the normal map or combat music.
path
- the relative path to the sound file, including
extension. Can be any supported sound format (midi, ogg,
others.) Nothing will be played if the path is null, or
the file isn't found on the server. public void playPriorityMusic(java.lang.String path, int repeats, int repeatDelay, double gain)
path
- the relative path to the sound file. Can
be any supported sound format.repeats
- number of times the client should repeat
the piece before stopping and sending a notification
back to the server. A value of 0 means don't repeat;
just play the track once. A value of -1 means repeat
indefinitely.repeatDelay
- number of milliseconds to pause
between repeats, if we're repeating. Negative values
are interpreted as zero (no delay).gain
- the volume for this track, from 0.0 to 1.0.
Values outside the range are clipped to 0.0 or 1.0.public void stopMusic()
public void setMusicGain(double gain)
gain
- the new background music gain, from 0.0 to 1.0public void playSound(java.lang.String path, java.lang.String id)
Client sends a "#endsound id" directive back to the server when the sound finishes playing, unless it was interrupted with stopSound() or stopAllSounds().
path
- relative path to the sound file, in any
supported format, including midi.id
- the unique ID of this sound. It has to
be unique, so you can't use (for example) the hashcode
of the path to the file, since more than one of the
same sound may be playing at once. Usually you pass
the hashcode of the object that emitted the sound.public void playSound(java.lang.String path, java.lang.String id, int repeats, int repeatDelay, double gain)
path
- the relative path to the sound file, in
any supported format, including midi.id
- the unique ID of this sound. It has to
be unique, so you can't use (for example) the hashcode
of the path to the file, since more than one of the
same sound may be playing at once. Usually you pass
the hashcode of the object that emitted the sound.repeats
- number of times the client should repeat
the piece before stopping and sending a notification
back to the server. A value of 0 means don't repeat;
just play the track once. A value of -1 means repeat
indefinitely, until explicitly stopped.repeatDelay
- number of milliseconds to pause
between repeats, if we're repeating. Negative values
are interpreted as zero (no delay).gain
- the volume for this track, from 0.0 to 1.0.
Values outside the range are clipped to 0.0 or 1.0.public void stopSound(java.lang.String id)
id
- the unique ID of the sound effect. The client
will not send an "#endsound" back to the server.public void stopAllSounds()
public void setSoundGain(java.lang.String id, double gain)
gain
- the new background music gain, from 0.0 to 1.0id
- the unique track ID for the sound to modifypublic void pauseSound(java.lang.String id)
id
- the unique track id of the sound to resumepublic void resumeSound(java.lang.String id)
id
- the unique track id of the sound to resume
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |