0

I am able to send the songs to amazon echo devices and the song is playing. I am not understanding what i have to send to show the song in the player or queue screen in alexa app as it is coming to other music apps like saavn, spotify etc. Please let me know if there are any link or info regarding this.

![Alexa App queue image for saavn app]1

Rajeev Shetty
  • 1,534
  • 1
  • 17
  • 27

1 Answers1

0

Check out Amazon's AudioPlayer Interface Reference. It gives a pretty comprehensive guide on how to make the audio interface work. Essentially, it boils down to adding another directive to the list of directives you're returning in your response JSON. For me, this will automatically come up with the audio player screen.

A basic version of the audio directive looks like the following:

    {
      "type": "AudioPlayer.Play",
      "playBehavior": "ENQUEUE",
      "audioItem": {
        "stream": {
          "token": "Audio Playback",
          "url": "http://www.audio.com/this/is/the/url/to/the/audio",
          "offsetInMilliseconds": 0
        }
      }
    }

ENQUEUE adds the specified stream to the end of the current stream queue. The offsetInMilliseconds key sets how far into the stream (in milliseconds) playback should begin.

When you nest this into the larger response JSON, it takes on the form of following:

{
  "version": "1.0",
  "sessionAttributes": {},
  "response": {
    "outputSpeech": {},
    "card": {},
    "reprompt": {},
    "directives": [
      {
        "type": "AudioPlayer.Play",
        "playBehavior": "ENQUEUE",
        "audioItem": {
          "stream": {
            "token": "Audio Playback",
            "url": "http://www.audio.com/this/is/the/url/to/the/audio",
            "offsetInMilliseconds": 0
          }
        }
      }
    ],
    "shouldEndSession": true
  }
}

There are a handful of other options to include in your audio directive. These can be found in the link I mentioned above.

I find it most beneficial to make a function where you can pass in given values to create the AudioPlayer directive JSON. For example, in python, this may look like the following:

def build_audio_directive(play_behavior, token, url, offset)
    return {
          "type": "AudioPlayer.Play",
          "playBehavior": play_behavior,
          "audioItem": {
            "stream": {
              "token": token,
              "url": url,
              "offsetInMilliseconds": offset
            }
          }
        }

There are multiple ways to build up the response, but I find this way is the easiest for me to visualize.

peachykeen
  • 4,143
  • 4
  • 30
  • 49
  • I have used the same directives and the song is playing. here in this directives we are not giving any image rite. Then how it will appear with image and name in the player screen? Are you sure your song is coming in the player screen ? If it is coming then how the song name and image is appearing ? – Rajeev Shetty Jan 30 '18 at 04:57
  • From the AudioPlayer Interface Reference I linked in my post: _AudioPlayer has a visual appearance on Echo Show and Echo Spot, although the developer does not have any control over its appearance. Thus, the behavior of audio is the same regardless of whether the device with Alexa has a screen or not, and the Long Form Audio and AudioPlayer appearance on supported screen devices cannot be controlled by the developer. AudioPlayer appears as shown here in Echo Show and Echo Spot._ – peachykeen Jan 30 '18 at 09:05
  • So it looks like unfortunately you have no control over what image appears etc. But you can display a screen before the audio player starts going. – peachykeen Jan 30 '18 at 09:05
  • I have added an image in my question where i can see saavn music apps complete playlist is visible with images and name in alexa app queue section. Do you have any idea how to do this ? – Rajeev Shetty Feb 08 '18 at 06:48