Method: AGI#control_stream_file
- Defined in:
- lib/AGI.rb
#control_stream_file(file, digits = '""', skipms = 3000, ffchar = '*', rewchar = '#', pausechar = nil) ⇒ Object
Signals Asterisk to stream the given audio file to the channel starting at an optional offset until either the entire file has been streamed or the user provides one of a set of DTMF digits. Unlike stream_file, this allows the user on the channel to control playback using a fast-forward key, a rewind key, and a pause key.
Returns an AGIResponse including the DTMF digit provided by the channel.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/AGI.rb', line 180 def control_stream_file(file, digits='""', skipms=3000, ffchar='*', rewchar='#', pausechar=nil) response = AGIResponse.new if pausechar.nil? command_str = "CONTROL STREAM FILE file digits skipms ffchar rewchar" else command_str = "CONTROL STREAM FILE file digits skipms ffchar rewchar pausechar" end begin response.native = execute(command_str) rescue AGITimeoutError, AGICommandError, AGIHangupError raise end if response.native == -1 then raise AGIChannelError.new(@last_response, "Channel Failure in (#{command_str})") elsif response.native == 0 response.success = true else response.success = true response.data = response.native.chr end return response end |