Description of icon
Flex UI
API Reference

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 sound
AudioPlayerManager.toggleSound(false); // unmutes sound
Rate this page

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.