首页 > 解决方案 > 从需要 Alexa 标头的外部来源播放媒体

问题描述

我正在开发一项 Alexa 技能,我需要播放从我自己的 API 获得的媒体。

根据文档,我必须向 Alexa 发送要播放的媒体网址:

{
  "version": "1.0",
  "sessionAttributes": {},
  "response": {
    "outputSpeech": {},
    "card": {},
    "reprompt": {},
    "shouldEndSession": true,
    "directives": [
      {
        "type": "AudioPlayer.Play",
        "playBehavior": "ENQUEUE",
        "audioItem": {
          "stream": {
            "url": "https://cdn.example.com/url-of-the-mp3-to-play/audiofile.mp3",
            "token": "1234AAAABBBBCCCCCDDDDEEEEEFFFF",
            "expectedPreviousToken": "9876ZZZZZZZYYYYYYYYYXXXXXXXXXXX",
            "offsetInMilliseconds": 0
          },
          "metadata": {
            "title": "My opinion: how could you diss-a-brie?",
            "subtitle": "Vince Fontana",
            "art": {
              "sources": [
                {
                  "url": "https://cdn.example.com/url-of-the-skill-image/brie-album-art.png"
                }
              ]
            },
            "backgroundImage": {
              "sources": [
                {
                  "url": "https://cdn.example.com/url-of-the-skill-image/brie-background.png"
                }
              ]
            }
          }
        }
      }
    ]
  }
}

事情是:

我的 API 需要 Authorization 标头,而 Alexa 似乎只获取我在 url 中传递的源,我如何指示 Alexa 在请求中插入 Authorization 标头?

标签: amazon-web-servicesauthenticationalexa

解决方案


在与 AWS Alexa 团队联系后,他们澄清说:

要使用 AudioPlayer 播放的音频文件必须托管在端口 443 上可访问 Internet 的 HTTPS 端点上 - 根据以下 audioItem.stream.url 上的文档,目前不支持授权: https ://developer.amazon .com/docs/custom-skills/audioplayer-interface-reference.html#play-params

所以在此期间,我们不能使用需要授权的音频文件。


推荐阅读