如何关闭使用 AudioPlayer 接口的 Alexa 技能
How to close an Alexa skill that uses AudioPlayer interface
我目前正在开发一项 Alexa 技能,我使用 AudioPlayer
界面播放歌曲。
当取消意图被调用时,我做了一个:
'AMAZON.CancelIntent': function() {
this.emit(':tell', "Bye!");}
问题是 alexa 说 "Bye" 后,音频没有暂停,技能仍然是 运行。
如何从 Intent 处理程序关闭技能?
您必须发送一个 AudioPlayer.Stop
指令来停止任何当前正在播放的音频流。
'AMAZON.CancelIntent': function() {
this.response.speak('Bye').audioPlayerStop();
this.emit(':responseReady');
}
在ask-sdk-v2中你可以使用:
return handlerInput.responseBuilder
.addAudioPlayerStopDirective()
.getResponse();
更新
Alexa 服务将跟踪您的音频播放器技能,作为最近流式传输音频的技能,对于任何内置意图,Alexa 将创建一个新会话并触发对您的技能的请求。
When your skill sends a Play directive to begin playback, the Alexa service sends the audio stream to the device for playback.
Once the session ends normally (for instance, if your response
included the shouldEndSession flag set to true), Alexa remembers that
your skill started the playback until the user does one of the
following:
- Invokes audio playback with a different skill.
- Invokes another service that streams audio, such as the built-in music service or the flash briefing.
- Reboots the device.
查看此文档Built-in Intents for Playback Control
有关 AudioPlayer 指令的更多信息 here
我目前正在开发一项 Alexa 技能,我使用 AudioPlayer
界面播放歌曲。
当取消意图被调用时,我做了一个:
'AMAZON.CancelIntent': function() {
this.emit(':tell', "Bye!");}
问题是 alexa 说 "Bye" 后,音频没有暂停,技能仍然是 运行。
如何从 Intent 处理程序关闭技能?
您必须发送一个 AudioPlayer.Stop
指令来停止任何当前正在播放的音频流。
'AMAZON.CancelIntent': function() {
this.response.speak('Bye').audioPlayerStop();
this.emit(':responseReady');
}
在ask-sdk-v2中你可以使用:
return handlerInput.responseBuilder
.addAudioPlayerStopDirective()
.getResponse();
更新
Alexa 服务将跟踪您的音频播放器技能,作为最近流式传输音频的技能,对于任何内置意图,Alexa 将创建一个新会话并触发对您的技能的请求。
When your skill sends a Play directive to begin playback, the Alexa service sends the audio stream to the device for playback. Once the session ends normally (for instance, if your response included the shouldEndSession flag set to true), Alexa remembers that your skill started the playback until the user does one of the following:
- Invokes audio playback with a different skill.
- Invokes another service that streams audio, such as the built-in music service or the flash briefing.
- Reboots the device.
查看此文档Built-in Intents for Playback Control
有关 AudioPlayer 指令的更多信息 here