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.code: AudioErrorCode- Error codevoid
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 soundexports.AudioErrorCode: 0 | 1 | 2#
ErrorCode
Properties:
NotAllowed: 0Playing audio is not allowed by your system
InvalidMedia: 1You provided an invalid media or the url is invalid
Other: 2An unknown has occured
Rate this page