Relay.Calling.RecordAction

View as Markdown

Relay.Calling.RecordAction

This object returned from recordAsync method that represents a recording that is currently active on a call.

Methods-submenu

GetResult

Returns the final result of the recording.

Parameters

None

Returns

Relay.Calling.RecordResult - Final result of the recording.

Examples

Start recording in stereo mode and grab the result when it’s completed.

1var rec signalwire.RecordParams
2rec.Beep = true
3rec.Format = "wav"
4rec.Stereo = true
5rec.Direction = signalwire.RecordDirectionBoth.String()
6rec.InitialTimeout = 10
7rec.EndSilenceTimeout = 3
8rec.Terminators = "#*"
9
10// use anonymous function as callback
11resultDial.Call.OnRecordFinished = func(recordAction *signalwire.RecordAction) {
12 signalwire.Log.Info("Recording is at: %s\n", recordAction.Result.URL)
13 signalwire.Log.Info("Recording Duration: %d\n", recordAction.Result.Duration)
14 signalwire.Log.Info("Recording File Size: %d\n", recordAction.Result.Size)
15}
16
17recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
18if err != nil {
19 signalwire.Log.Error("Error occurred while trying to record audio\n")
20}
21
22// the recording can stop by itself when detected silence or it can be stopped via command
23
24[do something here]
25
26recordAction.Stop()

GetState

Return the current state of recording.

Parameters

None

Returns

string - Current state of recording.

GetCompleted

Return true if the recording has finished, false otherwise.

Parameters

None

Returns

Boolean - True/False accordingly to the state.

Examples

Start recording in stereo mode and check if it has finished.

1var rec signalwire.RecordParams
2
3rec.Beep = true
4rec.Format = "wav"
5rec.Stereo = true
6rec.Direction = signalwire.RecordDirectionBoth.String()
7rec.InitialTimeout = 10
8rec.EndSilenceTimeout = 3
9rec.Terminators = "#*"
10
11recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
12if err != nil {
13 signalwire.Log.Error("Error occurred while trying to record audio\n")
14}
15
16// we sleep but you can do something else in the main thread
17time.Sleep(3 * time.Second)
18
19signalwire.Log.Info("Stopping recording...\n")
20recordAction.Stop()
21
22// this can be run in a go routine
23for {
24 time.Sleep(1 * time.Second)
25
26 if recordAction.GetCompleted() {
27 break
28 }
29}

GetControlID

Return the UUID to identify the action.

Parameters

None

Returns

string - UUID to identify the action.

Examples

Start recording and print the controlId.

1recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
2if err != nil {
3 signalwire.Log.Error("Error occurred while trying to record audio\n")
4}
5Signalwire.Log.Info("Recording ControlID: %s\n", recordAction.GetControlID())

Stop

Stop the action immediately.

Parameters

None

Returns

Examples

Start recording with default params and stop it upon condition

1var rec signalwire.RecordParams
2recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
3if err != nil {
4 signalwire.Log.Error("Error occurred while trying to record audio\n")
5}
6
7[do something here]
8if (cond) {
9 recordAction.Stop()
10}