Class: Adhearsion::CallController::Output::AsyncPlayer

Inherits:
AbstractPlayer show all
Defined in:
lib/adhearsion/call_controller/output/async_player.rb

Instance Attribute Summary

Attributes inherited from AbstractPlayer

#controller

Instance Method Summary collapse

Methods inherited from AbstractPlayer

#initialize, #new_output, #play_ssml, #play_url

Constructor Details

This class inherits a constructor from Adhearsion::CallController::Output::AbstractPlayer

Instance Method Details

#output(content, options = {}) { ... } ⇒ Object

Yields:

  • The output component before executing it

Raises:

  • (PlaybackError)

    if (one of) the given argument(s) could not be played


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/adhearsion/call_controller/output/async_player.rb', line 12

def output(content, options = {})
  options.merge! :ssml => content
  component = new_output options
  component.register_event_handler Adhearsion::Event::Complete do |event|
    controller.logger.error event if event.reason.is_a?(Adhearsion::Event::Complete::Error)
    throw :pass
  end
  controller.write_and_await_response component
  component
rescue Adhearsion::ProtocolError => e
  raise PlaybackError, "Async output failed due to #{e.inspect}"
end