aws-lambda - 如何关闭使用 AudioPlayer 界面的 Alexa 技能

标签 aws-lambda alexa-skills-kit

我目前正在开发一项 Alexa 技能,其中我使用 AudioPlayer 界面来播放歌曲。

当调用取消意图时,我执行以下操作:

'AMAZON.CancelIntent': function() {
this.emit(':tell', "Bye!");}

问题是,Alexa 说“再见”后,音频未暂停,技能仍在运行。

如何从意图处理程序中关闭技能?

最佳答案

您必须发送 AudioPlayer.Stop 指令来停止任何当前正在播放的音频流。

'AMAZON.CancelIntent': function() {
   this.response.speak('Bye').audioPlayerStop();
   this.emit(':responseReady');
}

在ask-sdk-v2中您可以使用:

return handlerInput.responseBuilder
      .addAudioPlayerStopDirective()
      .getResponse();

更新
Alexa 服务将跟踪您的音频播放器技能作为最近传输音频的技能,对于任何内置意图,Alexa 将创建一个新 session 并触发对您的技能的请求。

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:

  1. Invokes audio playback with a different skill.
  2. Invokes another service that streams audio, such as the built-in music service or the flash briefing.
  3. Reboots the device.

查看此文档 Built-in Intents for Playback Control

有关 AudioPlayer 指令的更多信息 here

关于aws-lambda - 如何关闭使用 AudioPlayer 界面的 Alexa 技能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52532272/

相关文章:

node.js - Alexa AWS 错误 : task timed out after 3. 00 秒

amazon-web-services - 转到AWS Lambda:事件在哪里?

node.js - Null SpeechletResponse 问题 (Alexa)

alexa - 您将如何设计字母和数字代码的插槽?

spring - Spring是否兼容无服务器计算

amazon-web-services - 使用 HTTP 终端节点时,如何将 GET 参数传递给我的 AWS Lambda 函数?

amazon-web-services - 如果资源创建已存在于无服务器中,如何忽略资源创建

date - 日期时间的 Alexa 技能自定义插槽

node.js - 在 Alexa 上创建广播电台

javascript - Spread 运算符在 Alexa 中抛出意外的 token 错误