module Adhearsion::CallController::Record

Constants

RecordError

Public Instance Methods

record(options = {}) { |event| ... } click to toggle source

Start a recording

@example 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}"

@example Asynchronous recording, execution of the controller will continue

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

@param [Hash] options @option options [Boolean, Optional] :async Execute asynchronously. Defaults to false @option options [Boolean, Optional] :start_beep Indicates whether subsequent record will be preceded with a beep. Default is false. @option options [Boolean, Optional] :start_paused Whether subsequent record will start in PAUSE mode. Default is false. @option options [String, Optional] :max_duration Indicates the maximum duration (seconds) for a recording. @option options [String, Optional] :format File format used during recording. @option options [String, Optional] :initial_timeout Controls how long (seconds) the recognizer should wait after the end of the prompt for the caller to speak before sending a Recorder event. @option options [String, Optional] :final_timeout Controls the length (seconds) of a period of silence after callers have spoken to conclude they finished. @option options [Boolean, String, Optional] :interruptible Allows the recording to be terminated by any single DTMF key, default is false

@yield [event] Handle the recording completion event asyncronously. @yieldparam [Punchblock::Event::Complete] event the complete event for the recording

@return Punchblock::Component::Record

# File lib/adhearsion/call_controller/record.rb, line 125
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