Skip to main content

Relay.Calling.PlayAction

Relay.Calling.PlayAction

This object returned from one of asynchronous play methods that represents a playing currently active on a call.

Properties

PropertyTypeDescription
resultRelay.Calling.PlayResultFinal result of playing.
statestringCurrent state of playing.
completedbooleanWhether the playing has finished.
payloaddictPayload sent to Relay to start playing.
control_idstringUUID to identify the playing.

Methods

pause

Pause the playback immediately.

Parameters

None

Returns

coroutine - Coroutine that will return a Relay.Calling.PlayPauseResult object.

Examples

Start playing an audio file and pause it after 5 seconds:

import asyncio # to use sleep

action = await call.play_audio_async('https://cdn.signalwire.com/default-music/welcome.mp3')
await asyncio.sleep(5)
pause_result = await action.pause()

resume

Resume the playback immediately.

Parameters

None

Returns

coroutine - Coroutine that will return a Relay.Calling.PlayResumeResult object.

Examples

Start playing an audio file, stop it and then resume it after 5 seconds:

import asyncio # to use sleep

action = await call.play_audio_async('https://cdn.signalwire.com/default-music/welcome.mp3')
await asyncio.sleep(5)
pause_result = await action.pause()
await asyncio.sleep(5)
resume_result = await action.resume()

stop

Stop the action immediately.

Parameters

None

Returns

coroutine - Coroutine that will return a Relay.Calling.StopResult object.

Examples

Play an Mp3 file and stop it after 5 seconds:

import asyncio # to use sleep

action = await call.play_audio_async('https://cdn.signalwire.com/default-music/welcome.mp3')
await asyncio.sleep(5)
await action.stop()

volume

Control the volume of the playback.

Parameters

ParameterTypeRequiredDescription
volumenumberrequiredVolume value between -40dB and +40dB where 0 is unchanged.

Returns

coroutine - Coroutine that will return a Relay.Calling.PlayVolumeResult object.

Examples

Start playing an audio file and increase the playback volume:

action = await call.play_audio_async('https://cdn.signalwire.com/default-music/welcome.mp3')
result = await action.volume(5.0)