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 are using WordPress to achieve that. Some of the plugins that can help you with it are Audioigniter or MP3 Music Player by Sonaar.
We have previously created an article which describes how to create an Alexa Audio Player skill. In that example we used the standard WordPress media library for mp3’s to be played. Since Audioigniter and MP3 Music Player by Sonaar use a bit different structure which represent the songs (grouped into albums), we had to create a new context component WP_Query album mp3 source.
To make yourself familiar with the Searchable Player template, please check out the mentioned article here.
Modifying the Searchable Player template
In a few simple steps, you’ll be able to modify the existing Searchable Player to work with either Audioigniter or MP3 Music Player by Sonaar.
First of all, enable convo-wp-plugin-pack
in the Configure Package section This will add WP_Query album mp3 source in the Contexts tab of your workflow. Feel free to replace the existing context with the new one WP_Query album mp3 source in the Contexts Container. Modify it to your needs following the examples like in Fetching the Songs While Using Audioigniter or Fetching the Songs While Using MP3 Music Player by Sonar.
And that’s it. This is all you need to do for the modification of the Searchable Player template.
WP_Query Album MP3 Source
First of all, we’re assuming that you are already familiar with Audioigniter or MP3 Music Player by Sonar and you know how to create playlists. This element is very similar to the WP_Query MP3 Source, but there are some differences that have to be considered. In the WP_Query MP3 Source context mp3’s were treated as regular WP Posts, but in case of Audioigniter or MP3 Music Player by Sonaar, the songs are stored in the form of playlists.
Examples of fetching the songs for Audioigniter and MP3 Music Player by Sonar are located below.
Fetching the Songs While Using Audioigniter
In this section, we will use the example that is related to Audioigniter.
Since Audioigniter stores its songs in so-called Playlists, in the form of post_type => ai_playlist
and post_meta_key => _audioigniter_tracks
as an array, we have to use WP_Query album mp3 source context to fetch the songs.
Several WP Query arguments should be set to fetch the Audioigniter albums correctly: post_type = ai_playlist
and post_status = publish
. For now, we just have the playlists, but we need the songs of those fetched playlists.
To get the songs of a playlist, we need to populate the Songs of Album and Song of Album fields like this:
- Songs of Album –
${get_post_meta(post.ID,"_audioigniter_tracks", true)}
- Song of Album –
song_of_album
Songs retrieved from a playlist have a bit different structure than the plain post attachments, and you’ll have to manually map them to the corresponding properties.
So, the final context settings looks like this:
- Song URL –
${song_of_album.track_url}
- Song Title –
${song_of_album.title}
- Artist –
${song_of_album.artist}
- Song Image –
${wp_get_attachment_url(song_of_album.cover_id)}
Fetching the Songs While Using MP3 Music Player by Sonar
In this example, you can refer to Audioigniter, since we will still use WP_Query album mp3 source. Although, the configuration will be slightly different by post_type in WP Query arguments, Songs of Album and the structure of fetched songs because the songs are stored in the same manner as in Audioigniter. Songs are also stored in Playlists in the form of post_type => album
and post_meta_key => alb_tracklist
as an array.
The configuration of WP_Query album mp3 source for MP3 Music Player by Sonar might look like this:
- In WP Query arguments add
post_type = album
andpost_status = publish
- Songs of Album –
${get_post_meta(post.ID,"alb_tracklist",true)}
- Final context settings looks like this:
- Song URL –
${song_of_album.track_mp3}
- Song Title –
${get_post(song_of_album.track_mp3_id).post_title}
- Artist –
${wp_get_attachment_metadata(song_of_album.track_mp3_id)["artist"]}
- Song Image –
${song_of_album.track_image}
- Song URL –
And that’s it for this example, now we have our songs from MP3 Music Player by Sonar.
What about the Search Capability?
The search capability will work with playlist titles, and you can also add an meta_query to WP_Query Args to retrieve albums that contain part of your search query. This will work just fine in case your playlists are well organized.
This is an example of how to prepare a meta_query for the WP_Query Args:
After you have created your meta_query, you can add it in the WP_Query Args of your WP_Query album mp3 source like this: meta_query – ${meta_query}
Conclusion
Now with the new WP_Query album mp3 source context you are able to modify the Searchable Player template to play your playlists or albums created with Audioigniter or MP3 Music Player by Sonaar in a matter of minutes and listen to your creations on your smart speaker or smart display.
Related posts
Seriously Simple Podcasting for WordPress – Now with your own Amazon Alexa Skill
Do you want to have Amazon Alexa skill for your podcast? Many businesses and individuals have started their own…
VIEW FULL POSTAppointment scheduling on your WordPress website – Now with Amazon Alexa skill
Many of the WordPress-based websites have some kind of appointment scheduling functionality. To be more precise, there are a…
VIEW FULL POST