Search code examples
javascriptalexa-skills-kit

Alexa Skill Kit - AudioPlayer Metadata Images


I'm trying to implement an audiostream (radio) with images to display on Alexa devices. The audio works fine, but for some reason my images stopped displaying after I tried to change the source image the first time. Not sure if I'm just messing up the syntax, or if it's something else entirely.

According to the doc the "audioItem.stream.token may be cached in the Alexa service for up to five days", which in term can affect image display. But changing the token to something new doesn't seem to do anything.

Hope somebody has some insight into this.

const radioStream = [
  {
    'token': '1',
    'url': 'https://url-to-stream/',
    'metadata': {
      "title": "title",
      "subtitle": "subtitle",
      "art": {
        "sources": [
          {
            "url": "https://url-to-image/image.png",
            "widthPixels": 512,
            "heightPixels": 512
          }
        ]
      },
      "backgroundImage": {
        "sources": [
          {
            "url": "https://url-to-image/image.png",
            "widthPixels": 1200,
            "heightPixels": 800
          }
        ]
      }
    }
  },
];
...
handle(handlerInput) {
    const stream = radioStream[0];
    handlerInput.responseBuilder
      .speak(handlerInput.t('AFFIRMATION'))
      .addAudioPlayerPlayDirective('REPLACE_ALL', radioStream.url, radioStream.token, 0, null, radioStream.metadata);
    return handlerInput.responseBuilder
      .getResponse();
  },

Solution

  • The implementation is correct.

    The documentation confirm that you have to update the token to allow the metadata to be refreshed. I tested and It work properly.

    Based on your comments, it seems that the issue persist on your Fire HD 8 Tablet with the Fire OS version 7.3.2.1.

    It's always a good practice to try on different devices to validate the root cause.

    I recommend you to contact the developer directly on the amazon developer forum. They should be able to push a fix for the device and fireOS version.