VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Classes | Public Member Functions | Static Public Attributes | List of all members
com.google.fpl.utils.SoundManager Class Reference

Controls the background audio tracks that need gapless playback and looping on Android devices. More...

Inheritance diagram for com.google.fpl.utils.SoundManager:

Public Member Functions

void onStart (Context context)
 Notifies this SoundManager of the onStart activity lifecycle event. More...
 
void onStop ()
 Notifies this SoundManager of the onStop activity lifecycle event. More...
 
void clearBGMTrack (int priority)
 Clears the audio track of the specified background music priority level. More...
 
boolean isBGMMuted ()
 Returns whether or not the background music is muted. More...
 
void setBGMTrack (int priority, String track)
 Sets the audio track of the specified background priority level. More...
 
void setBGMMuted (boolean value)
 Sets whether or not the background music is muted. More...
 
void setPaused (boolean value)
 Sets SoundManager paused state. More...
 
void onCompletion (MediaPlayer mp)
 Called when the end of a media source is reached during playback. More...
 

Static Public Attributes

static final int INVALID_PRIORITY = -1
 Represents an invalid background music priority level and serves as a lower bound on priority. More...
 

Detailed Description

Controls the background audio tracks that need gapless playback and looping on Android devices.

This class implements a subset of the API defined in SoundManager.h related to background music. Specifically, it uses double buffering of Android MediaPlayers to achieve gapless looping.

Member Function Documentation

void com.google.fpl.utils.SoundManager.clearBGMTrack ( int  priority)
inline

Clears the audio track of the specified background music priority level.

If priority was currently the highest priority level with an audio track set, then the background music is transitioned to the next highest priority level for which an audio track is set, or faded out if none are available.

Parameters
priorityBackground music priority level to clear the audio track for
boolean com.google.fpl.utils.SoundManager.isBGMMuted ( )
inline

Returns whether or not the background music is muted.

void com.google.fpl.utils.SoundManager.onCompletion ( MediaPlayer  mp)
inline

Called when the end of a media source is reached during playback.

This callback swaps the internally double buffered MediaPlayers to achieve gapless playback.

Parameters
mpMediaPlayer that reached the end of the sample data
void com.google.fpl.utils.SoundManager.onStart ( Context  context)
inline

Notifies this SoundManager of the onStart activity lifecycle event.

This method should be called from the onStart method in the main activity.

Parameters
contextContext to be used for the MediaPlayers
void com.google.fpl.utils.SoundManager.onStop ( )
inline

Notifies this SoundManager of the onStop activity lifecycle event.

This method should be called from the onStop method in the main activity used to create this SoundManager.

void com.google.fpl.utils.SoundManager.setBGMMuted ( boolean  value)
inline

Sets whether or not the background music is muted.

Parameters
valuetrue to mute the background music
void com.google.fpl.utils.SoundManager.setBGMTrack ( int  priority,
String  track 
)
inline

Sets the audio track of the specified background priority level.

Parameters
priorityBackground music priority level to set the audio track for
trackAudio track asset path to load for the sound effect
void com.google.fpl.utils.SoundManager.setPaused ( boolean  value)
inline

Sets SoundManager paused state.

This method will either stop background music from playing or resume it.

Parameters
valuetrue to pause the background music

Member Data Documentation

final int com.google.fpl.utils.SoundManager.INVALID_PRIORITY = -1
static

Represents an invalid background music priority level and serves as a lower bound on priority.