AudioPlayerManager
The Flex AudioPlayerManager API supports playing, stopping and muting sounds. To learn more go to Flex Sounds
play(mediaData, onError?) => string#
Plays the media provided.
Parameters:
mediaData: AudioPlayerManager.MediaDataMedia data to be played.
url: string- URL of the media.repeatable: boolean- Whether the media should repeat or not.
onError?: (error) => voidCallback to be invoked when there is an error playing media.
error: AudioPlayerManager.Error- Audio Player error.void
Returns:
stringUnique identifier of the media.
Example:
const mediaId = AudioPlayerManager.play( { url: "sound-url", repeatable: true }, (error: AudioPlayerError) => { // handle error });stop(mediaId) => void#
Stop media given the unique identifier of the media.
Parameters:
mediaId: stringId of the media to be stopped.
Returns:
void
Example:
AudioPlayerManager.stop(mediaId);toggleSound(mute) => void#
Mutes/unmutes sound based on the given parameter.
Parameters:
mute: booleanMutes the audio if true or unmutes if false.
Returns:
void
Example:
AudioPlayerManager.toggleSound(true); // mutes soundAudioPlayerManager.toggleSound(false); // unmutes soundisPlaying(undefined) => boolean#
Checks if any media is currently playing.
Returns:
booleanTrue if any media is currently playing, otherwise false.
Example:
const isCurrentlyPlaying = AudioPlayerManager.isPlaying(); // true if any media is playing, false otherwise