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
| Property | Type | Description |
|---|---|---|
result | Relay.Calling.PlayResult | Final result of playing. |
state | string | Current state of playing. |
completed | boolean | Whether the playing has finished. |
payload | dict | Payload sent to Relay to start playing. |
control_id | string | UUID 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
| Parameter | Type | Required | Description |
|---|---|---|---|
volume | number | required | Volume 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)