Relay.Calling.RecordAction
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.
var rec signalwire.RecordParams
rec.Beep = true
rec.Format = "wav"
rec.Stereo = true
rec.Direction = signalwire.RecordDirectionBoth.String()
rec.InitialTimeout = 10
rec.EndSilenceTimeout = 3
rec.Terminators = "#*"
// use anonymous function as callback
resultDial.Call.OnRecordFinished = func(recordAction *signalwire.RecordAction) {
signalwire.Log.Info("Recording is at: %s\n", recordAction.Result.URL)
signalwire.Log.Info("Recording Duration: %d\n", recordAction.Result.Duration)
signalwire.Log.Info("Recording File Size: %d\n", recordAction.Result.Size)
}
recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
if err != nil {
signalwire.Log.Error("Error occurred while trying to record audio\n")
}
// the recording can stop by itself when detected silence or it can be stopped via command
[do something here]
recordAction.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.
var rec signalwire.RecordParams
rec.Beep = true
rec.Format = "wav"
rec.Stereo = true
rec.Direction = signalwire.RecordDirectionBoth.String()
rec.InitialTimeout = 10
rec.EndSilenceTimeout = 3
rec.Terminators = "#*"
recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
if err != nil {
signalwire.Log.Error("Error occurred while trying to record audio\n")
}
// we sleep but you can do something else in the main thread
time.Sleep(3 * time.Second)
signalwire.Log.Info("Stopping recording...\n")
recordAction.Stop()
// this can be run in a go routine
for {
time.Sleep(1 * time.Second)
if recordAction.GetCompleted() {
break
}
}
GetControlID
Return the UUID to identify the action.
Parameters
None
Returns
string
- UUID to identify the action.
Examples
Start recording and print the controlId.
recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
if err != nil {
signalwire.Log.Error("Error occurred while trying to record audio\n")
}
Signalwire.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
var rec signalwire.RecordParams
recordAction, err := resultDial.Call.RecordAudioAsync(&rec)
if err != nil {
signalwire.Log.Error("Error occurred while trying to record audio\n")
}
[do something here]
if (cond) {
recordAction.Stop()
}