Module: Adhearsion::CallController::Record

Included in:
Adhearsion::CallController
Defined in:
lib/adhearsion/call_controller/record.rb

Defined Under Namespace

Classes: Recorder

Constant Summary collapse

RecordError =

Represents failure to record such as when a file cannot be written.

Class.new StandardError

Instance Method Summary collapse

Instance Method Details

#record(options = {}) {|event| ... } ⇒ Object

Start a recording

Examples:

Record in a blocking way and use result

record_result = record :start_beep => true, :max_duration => 60
logger.info "Recording saved to #{record_result.complete_event.recording.uri}"

Asynchronous recording, execution of the controller will continue

record :async => true do |event|
  logger.info "Async recording saved to #{event.recording.uri}"
end

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :async (Boolean, Optional)

    Execute asynchronously. Defaults to false

  • :start_beep (Boolean, Optional)

    Indicates whether subsequent record will be preceded with a beep. Default is false.

  • :start_paused (Boolean, Optional)

    Whether subsequent record will start in PAUSE mode. Default is false.

  • :max_duration (String, Optional)

    Indicates the maximum duration (seconds) for a recording.

  • :format (String, Optional)

    File format used during recording.

  • :initial_timeout (String, Optional)

    Controls how long (seconds) the recognizer should wait after the end of the prompt for the caller to speak before sending a Recorder event.

  • :final_timeout (String, Optional)

    Controls the length (seconds) of a period of silence after callers have spoken to conclude they finished.

  • :interruptible (Boolean, String, Optional)

    Allows the recording to be terminated by any single DTMF key, default is false

Yields:

  • (event)

    Handle the recording completion event asyncronously.

Yield Parameters:

Returns:

  • Adhearsion::Rayo::Component::Record


140
141
142
143
144
145
146
147
148
149
# File 'lib/adhearsion/call_controller/record.rb', line 140

def record(options = {})
  recorder = Recorder.new self, options

  recorder.handle_record_completion do |event|
    catching_standard_errors { yield event if block_given? }
  end

  recorder.run
  recorder.record_component
end