XML: <PlayAudio>

The PlayAudio verb is used to play an audio file in the call. The URL of an audio file should be included in the body of the <PlayAudio> tag. If a relative URL is given, it is resolved relative to the endpoint that returned the BXML.

Audio is cached according to RFC 7234. Our system may cache your media up to the value of the response's Cache-Control header's max-age directive, or, if none is present, until the time given in an Expires header. In either case, our system may always cache for a shorter amount of time or not cache at all. If no Cache-Control or Expires header is set on the response, media will not be cached.

The audio format is determined by the HTTP Content-Type header in the response. Our system supports:

  • audio/wav and audio/x-wav for .wav files encoded as PCM or G711
  • audio/mpeg, audio/mpeg3 and audio/mp3 for .mp3 files

If the Content-Type is something other than the ones above or no Content-Type is found, we still try to determine the format by looking at the file extension. If the file extension is missing or it is something other than .mp3 or .wav, we assume the media is .wav and it will be tried as such.


ATTRIBUTE Description
username (optional) The username to send in the HTTP request to audioUri.
password (optional) The password to send in the HTTP request to audioUri.

Text Content

Name Description
audioUri The URL of the audio file to play. May be a relative URL.
⚠️ ONLY .wav files encoded as PCM or G711 and .mp3 files are supported.

Callbacks Received


Example 1 of 1: PlayAudio Verb

This shows how to use Bandwidth XML to play two audio clips into a phone call.

⚠️ ONLY .wav files encoded as PCM or G711 and .mp3 files are supported.

<?xml version="1.0" encoding="UTF-8"?>
PlayAudio playAudio1 = PlayAudio.builder()

PlayAudio playAudio2 = PlayAudio.builder()

Response response = Response.builder().build()

Response response = new Response();

PlayAudio playAudio1 = new PlayAudio();
playAudio1.Url = "https://audio.url/audio1.wav";

PlayAudio playAudio2 = new PlayAudio();
playAudio2.Url = "https://audio.url/audio2.mp3";


response = Bandwidth::Voice::Response.new()
play_audio_1 = Bandwidth::Voice::PlayAudio.new({
    :url => "https://audio.url/audio1.wav"
play_audio_2 = Bandwidth::Voice::PlayAudio.new({
    :url => "https://audio.url/audio2.mp3"

puts response.to_bxml()
response = Response()
play_audio_1 = PlayAudio(
play_audio_2 = PlayAudio(

var playAudio1 = new BandwidthBxml.Verbs.PlayAudio();
var playAudio2 = new BandwidthBxml.Verbs.PlayAudio();

var response = new BandwidthBxml.Response();

$playAudio1 = new BandwidthLib\Voice\Bxml\PlayAudio("https://audio.url/audio1.wav");
$playAudio2 = new BandwidthLib\Voice\Bxml\PlayAudio("https://audio.url/audio2.mp3");

$response = new BandwidthLib\Voice\Bxml\Response();

echo $response->toBxml();
echo "\n";

results matching ""

    No results matching ""