Method: Adhearsion::CallController::Output#play

Defined in:
lib/adhearsion/call_controller/output.rb

#play(*outputs, options) ⇒ Object

Plays the specified sound file names. This method will handle Time/DateTime objects (e.g. Time.now), Fixnums (e.g. 1000), Strings which are valid Fixnums (e.g “123”), and direct sound files. To specify how the Date/Time objects are said pass in as an array with the first parameter as the Date/Time/DateTime object along with a hash with the additional options. See play_time for more information.

Examples:

Play file hello-world

play 'http://www.example.com/hello-world.mp3'
play '/path/on/disk/hello-world.wav'

Speak current time

play Time.now

Speak today's date

play Date.today

Speak today's date in a specific format

play Date.today, :strftime => "%d/%m/%Y", :format => "dmy"

Play sound file, speak number, play two more sound files

play %w"http://www.example.com/a-connect-charge-of.wav 22 /path/to/cents-per-minute.wav /path/to/will-apply.mp3"

Play two sound files

play "/path/to/you-sound-cute.mp3", "/path/to/what-are-you-wearing.wav"

Parameters:

  • outputs (Array<String, Fixnum, Time, Date>, String, Fixnum, Time, Date)

    A collection of outputs to render.

  • options (Hash)

    A set of options for output. Includes everything in Adhearsion::Rayo::Component::Output.new.

Raises:

  • (PlaybackError)

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



101
102
103
104
105
106
107
108
# File 'lib/adhearsion/call_controller/output.rb', line 101

def play(*outputs, options)
  options = process_output_options outputs, options
  ssml = output_formatter.ssml_for_collection(outputs) || return
  player.play_ssml ssml, options
  true
rescue NoDocError
  false
end