Skip to content

Commit 485d7e4

Browse files
Adding Response#add_audio_stop
`when 'AMAZON.PauseIntent' then output.add_audio_stop`
1 parent 4934362 commit 485d7e4

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version" : "1.0",
3+
"response" :
4+
{
5+
"directives": [
6+
{
7+
"type": "AudioPlayer.Stop"
8+
}
9+
],
10+
"shouldEndSession": true
11+
}
12+
}

lib/alexa_rubykit/response.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def add_audio_url(url, token='', offset=0)
3939
}
4040
end
4141

42+
def add_audio_stop
43+
@directives << { 'type' => 'AudioPlayer.Stop' }
44+
end
45+
4246
def add_reprompt(speech_text, ssml = false)
4347
if ssml
4448
@reprompt = { "outputSpeech" => { :type => 'SSML', :ssml => check_ssml(speech_text) } }

spec/response_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,12 @@
123123
expect(response_json).to eq(sample_json)
124124
end
125125

126+
it 'should create a valid response with an AudioPlayer.Stop directive' do
127+
response = AlexaRubykit::Response.new
128+
response.add_audio_stop
129+
response.build_response_object
130+
response_json = response.build_response
131+
sample_json = JSON.parse(File.read('fixtures/response-sessionAudioStop.json')).to_json
132+
expect(response_json).to eq(sample_json)
133+
end
126134
end

0 commit comments

Comments
 (0)