PlayAction

View as Markdown

Relay::Calling::PlayAction

This object is returned by the asynchronous play! family of methods and represents a playing action that is currently active on a call.

Properties

PropertyTypeDescription
resultRelay::Calling::PlayResultFinal result of playing.
stateStringCurrent state of playing.
completedBooleanWhether the playing has finished.
payloadHashPayload sent to Relay to start playing.
control_idStringUUID to identify the playing.

Methods

stop

Stop the action immediately.

Parameters

None

Returns

Relay::Calling::StopResult - A StopResult object with a successful property.

pause

Pause the playback immediately.

Parameters

None

Returns

Relay::Calling::PlayPauseResult - A PlayPauseResult object with a successful property.

Examples

Play some audio and pause after 2 seconds.

1play_action = call.play_audio('https://cdn.signalwire.com/default-music/welcome.mp3')
2
3sleep 2
4result = play_action.pause
5
6puts "Pause was successful" if result.successful

resume

Resume the playback immediately.

Parameters

None

Returns

Relay::Calling::PlayResumeResult - A PlayResumeResult object with a successful property.

Examples

Play some audio and pause after 2 seconds, then resume playing after 2 more seconds

1play_action = call.play_audio('https://cdn.signalwire.com/default-music/welcome.mp3')
2
3sleep 2
4play_action.pause
5sleep 2
6result = play_action.resume
7
8puts "Resume was successful" if result.successful

volume

Sets the volume for the playback.

Uses a value from -40dB to +40dB where 0 is original audio and -40 is muted. It follows the standard amplitude voltage gain factor: 10 pow (value / 20).

Parameters

ParameterTypeRequiredDescription
settingNumericYesVolume setting

Returns

Relay::Calling::PlayVolumeResult - A PlayVolumeResult object with a successful property.

Examples

Play some audio and change the volume

1play_action = call.play_audio('https://cdn.signalwire.com/default-music/welcome.mp3')
2
3result = play_action.volume 20
4
5puts "Volume change was successful" if result.successful