Skip to main content

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.

play_action = call.play_audio('https://cdn.signalwire.com/default-music/welcome.mp3')

sleep 2
result = play_action.pause

puts "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

play_action = call.play_audio('https://cdn.signalwire.com/default-music/welcome.mp3')

sleep 2
play_action.pause
sleep 2
result = play_action.resume

puts "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

play_action = call.play_audio('https://cdn.signalwire.com/default-music/welcome.mp3')

result = play_action.volume 20

puts "Volume change was successful" if result.successful