Audio Player Skills
AudioPlayer Skills can be used to stream long-form audio files like music or podcasts. The audio file must be hosted at an Internet-accessible HTTPS endpoint. The supported formats for the audio file include AAC/MP4, MP3, and HLS. Bitrates: 16kbps to 384 kbps. More information can be found here at the official reference by Amazon.
Get started by creating a new Jovo project with the alexa-audioplayer
template:
Configuration
To be able to use the Alexa AudioPlayer, you need to enable the AudioPlayer interface for your Alexa Skill Project.
The alexa-audioplayer
template already comes with the right configuration in its project.js
file:
This will write the necessary information into the skill.json
and deploy it to your Alexa Skill project with the following commands:
Alternatively, you can also go to the Alexa Developer Console and enable AudioPlayer in the interfaces tab:
Audio Player Features
Play
Play a file. Speech will take place before the file begins to play.
play(url, token, playBehavior)
Play has the following parameters.
Name | Description | Value | Required |
---|---|---|---|
url |
Specify the URL source of your audio must be HTTPS | String |
YES |
token |
An opaque token that represents the audio stream. This token cannot exceed 1024 characters. | String |
YES |
PlayBehavior |
Describes playback behavior. Accepted values: REPLACE_ALL : Immediately begin playback of the specified stream, and replace current and enqueued streams.ENQUEUE : Add the specified stream to the end of the current queue. This does not impact the currently playing stream. REPLACE_ENQUEUED : Replace all streams in the queue. This does not impact the currently playing stream. |
String |
NO - Defaults to REPLACE_ALL |
Enqueue
Adds specified audio file to the queue. Remember that the URL must be HTTPS.
Name | Description | Value | Required |
---|---|---|---|
expectedToken |
token of the currently playing stream | String |
YES |
url |
Specify the URL source of your audio must be HTTPS | String |
YES |
token |
An opaque token that represents the audio stream. This token cannot exceed 1024 characters. | String |
YES |
Stop
Stops the current file from playing.
Start Over
Starts the file specified by the url from the beginning.
Name | Description | Value | Required |
---|---|---|---|
url |
Specify the URL source of your audio must be HTTPS | String |
YES |
token |
An opaque token that represents the audio stream. This token cannot exceed 1024 characters. | String |
YES |
Clear Queue
Use to clear all the queue or just the enqueue files.
Name | Description | Value | Required |
---|---|---|---|
clearBehavior |
CLEAR_ALL - to clear everything CLEAR_ENQUEUED - to clear just the queue. |
String |
YES |
Set Track Metadata
You can set track metadata that is used to show additional information for Alexa devices with a screen. Learn more about Audioplayer displays in the official reference by Amazon.
Name | Description | Value | Required |
---|---|---|---|
title |
The title text to display | String |
NO |
subtitle |
Subtitle to display | String |
NO |
artwork |
URL for the image to display | String |
NO |
background |
URL for the background image to display | STRING |
NO |
For more information about the album artwork and the background image, refer to the official image guidelines by Amazon. Here are the recommended minimum sizes:
- Artwork: 480 x 480 pixels
- Background image: 1024 x 640 pixels
Audio Player Directives
Add the following to your handlers variable:
Playback Controller
PlaybackController
requests are used to notify you about user interactions with audio player controls, e.g. touch controls on Alexa-enabled devices.
All these requests are mapped to built-in intents inside the PLAYBACKCONTROLLER
state. You can respond to them with AudioPlayer
directives, e.g. play
, pause
, etc.