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.MediaData
Media data to be played.
url: string
- URL of the media.repeatable: boolean
- Whether the media should repeat or not.
onError?: (error) => void
Callback to be invoked when there is an error playing media.
error: AudioPlayerManager.Error
- Audio Player error.void
Returns:
string
Unique 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: string
Id 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: boolean
Mutes the audio if true or unmutes if false.
Returns:
void
Example:
AudioPlayerManager.toggleSound(true); // mutes soundAudioPlayerManager.toggleSound(false); // unmutes sound