Build your own Audio Player or Sounds Skill with Amazon Alexa and WordPress website
Interested in developing your own Alexa sounds skill? Your new shiny Alexa sounds skill can be ready in a matter of minutes, using just your WordPress website and Convoworks WP GUI. Recently, with v0.21, we reworked our audio player interfaces and related components for even greater ease of use and more flexible customization capabilities.
First time here? Learn how to use Convoworks with our Getting started tutorial.
Before you start building your audio skill, we should cover some core audio player concepts.
To play your audio files, you first have to define where the system accesses them. We use service context components that implement the
IMediaSourceContext interface to help us track down those files. Currently, we have two context implementations. The Filesystem source that reads files from a specified folder (
convo-filesystem package). And the other one, WP_Query source that searches WordPress media library (
On top of that, you can use two new components in the package for starting audio playback: Media info element and Start audio playback element.
Media info and Start audio playback
Media info element gives you access to information about playback and tracks, and lets you customize the service workflow. You can pair it with the Start audio playback element to start the playback. Furthermore, this element lets you customize which track you want to start the playback from. All you need to do is provide the right track index via the Song to Play property.
After that, once the playback of the selected track starts, your service ends the session. While in the “player environment”, your user can make several predefined requests without invoking the skill: Next, Previous, Shuffle, Loop, etc. Additionally, if you own an Alexa-enabled device with a screen, you can access several touch controls when you touch the screen. They provide access to next, previous, and pause. Check the full list of available controls on Amazon.
Media block in our
convo-core package has built-in capabilities to handle all the playback requests. The only thing you have to worry about is responding with an appropriate message if the user’s request cannot be fulfilled (e.g. Next when it’s the last song and loop is off).
Now that we’ve got the core concepts covered, let’s move on to some of the shortcuts you can take to create your own audio player.
wp-core package comes with 2 audio player service templates. One simple and the second full featured, searchable audio service. Both of them should work without any additional configuration. Just connect them to Amazon and upload supported audio files to your WordPress media library.
Do not forget to:
1. turn on Audio Player interface on the “Amazon Alexa Configuration” Convoworks view.
2. enable the test Test option for your skill on the Amazon ASK GUI.
As for the
wp-core player templates, there’s two you can choose from: Loop player and Searchable player.
Loop player is a simple audio audio player service with only the most basic functionalities. It just plays whatever your WP Media source returns, with looping enabled by default. If you’re a first-time user, the playback starts from the first track. And if you’re a returning user, the playback resumes from the last played track. Next, Previous and all other built-in media requests that users can make without invoking the skill, are properly handled.
This is the upgraded version of a basic audio player skill with additional functionalities, like search, sort, and a few others. You can find all of them listed at the end of this section.
First, search. If a search term is provided, it can filter the search results by specific artist, playlist, track, or genre. What’s more, the user can also ask to listen to everything. Those search requests trigger either the custom
PlayAllIntent. In the WordPress implementation, search is
s argument for the
As for the sorting requests, they trigger either the
PlayNewestIntent with the
orderby parameter updating the sorting order.
In addition, we use the
PlayerStatusIntent custom intent to inform the user about the current player status (loop and shuffle status). We can access that information thanks to the Media Info element. Also, there are the
HowManyTracksAreThereIntent which inform the user of the current track and the total track number.
The service has just one step in conversation – Home, which start or resumes audio playback when there’s no specific user request. With a specific user request, the actual results handling is done in the Handle search results fragment. Once the player starts, the regular skill session ends. While in streaming environment, you can use a combination of commands. Some, as previously mentioned, don’t require skill invocation, while others do. Those custom intents that require skill invocation are handled in the processors of the Session start step.
You can say something like Alexa, ask Searchable Player:
- what’s playing
- how many tracks are there
- to play the last song
- to go to the track number [num]
- to go [num] tracks forward/backward
- to play [singer name]
- to play [track name]
- to play [folder name]
- to play [genre]
- to play all my music
- to rewind [num] seconds
- to fast forward [num] seconds
- what’s the player status
- to play tracks in alphabetical order
- to play the latest tracks first
- for help
What about Convoworks Prototype?
If you are running Convoworks Prototype, you can use the File Player template, which is a part of our
convo-filesystem package. It has pretty much the same functionality as Searchable Player and there is a walkthrough in our documentation section.
You now have a few basic examples you can build on to create your own audio skill. Hopefully, many variations are soon to follow, or you just might find our players great as they are.
One last thing before we part, media source is defined with the
IMediaSourceContext interface. This lets you create a media source component optimized for usage with existing mp3 player WordPress plugins. You can use it in tandem with cloud storage or any other viable data source.
Download Convoworks WP and try it for yourself!
Create Alexa music player skill with Audioigniter or MP3 Music Player by Sonaar plugins for WordPress
Many musicians have their own music websites with their creations. Like with everything on the Internet, many of them…VIEW FULL POST
Many of the WordPress-based websites have some kind of appointment scheduling functionality. To be more precise, there are a…VIEW FULL POST