Call Connections - Play Audio

Play audio in the call.

POST {endpoint}/calling/callConnections/{callConnectionId}/:playAudio?api-version=2021-08-30-preview

URI Parameters

Name In Required Type Description
callConnectionId
path True
  • string

The call connection id.

endpoint
path True
  • string

The endpoint of the Azure Communication resource.

api-version
query True
  • string

Version of API to invoke.

Request Body

Name Type Description
audioFileId
  • string

An id for the media in the AudioFileUri, using which we cache the media resource.

audioFileUri
  • string

The media resource uri of the play audio request. Currently only Wave file (.wav) format audio prompts are supported. More specifically, the audio content in the wave file must be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.

callbackUri
  • string

The callback Uri to receive PlayAudio status notifications.

loop
  • boolean

The flag indicating whether audio file needs to be played in loop or not.

operationContext
  • string

The value to identify context of the operation.

Responses

Name Type Description
202 Accepted

Returns the play audio response.

400 Bad Request
  • CommunicationErrorResponse

BadRequest

401 Unauthorized
  • CommunicationErrorResponse

Unauthorized

403 Forbidden
  • CommunicationErrorResponse

Forbidden

404 Not Found
  • CommunicationErrorResponse

NotFound

500 Internal Server Error
  • CommunicationErrorResponse

InternalServerError

Examples

Play audio in the call.

Sample Request

POST https://contoso.communications.azure.com/calling/callConnections/18dea47f-b081-4107-9a5c-4300819d2c6c/:playAudio?api-version=2021-08-30-preview

{
  "audioFileUri": "https://app.contoso.com/audio/message.wav",
  "loop": false,
  "operationContext": "31130c66-2f86-41b5-af61-23850243e093",
  "audioFileId": "42922e2c-a204-4ac4-8d80-375ae2792389"
}

Sample Response

{
  "status": "running",
  "operationContext": "31130c66-2f86-41b5-af61-23850243e093"
}
{
  "error": {
    "code": "400",
    "message": "The request contains invalid data."
  }
}
{
  "error": {
    "code": "401",
    "message": "Request is not authorized."
  }
}
{
  "error": {
    "code": "403",
    "message": "User is not allowed to perform specified action."
  }
}
{
  "error": {
    "code": "404",
    "message": "Resource not found on the server."
  }
}
{
  "error": {
    "code": "500",
    "message": "Internal server error."
  }
}

Definitions

OperationStatus

The status of the operation

PlayAudioRequest

The request payload for playing audio.

PlayAudioResult

The response payload for play audio operation.

ResultInfo

Result info class to be used to report result status for actions/operations.

OperationStatus

The status of the operation

Name Type Description
completed
  • string
failed
  • string
notStarted
  • string
running
  • string

PlayAudioRequest

The request payload for playing audio.

Name Type Description
audioFileId
  • string

An id for the media in the AudioFileUri, using which we cache the media resource.

audioFileUri
  • string

The media resource uri of the play audio request. Currently only Wave file (.wav) format audio prompts are supported. More specifically, the audio content in the wave file must be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate.

callbackUri
  • string

The callback Uri to receive PlayAudio status notifications.

loop
  • boolean

The flag indicating whether audio file needs to be played in loop or not.

operationContext
  • string

The value to identify context of the operation.

PlayAudioResult

The response payload for play audio operation.

Name Type Description
operationContext
  • string

The operation context provided by client.

operationId
  • string

The operation id.

resultInfo

The result info for the operation.

status

The status of the operation

ResultInfo

Result info class to be used to report result status for actions/operations.

Name Type Description
code
  • integer

The result code associated with the operation.

message
  • string

The message is a detail explanation of subcode.

subcode
  • integer

The subcode that further classifies the result.