Let's Talk Media Player Limitations - Playlists Versus Files, etc

Volumio on a Raspberry Pi3 mixed with Home Assistant is pretty slick, unless you want to use it as a source for audible notifications.

So, it seems that some of these media players require that there be a playlist to call as a source and don’t allow calling a single mp3 file.

I have a virtual grandfather clock that has been playing chimes through Google Home, but no matter what I’ve done with timing or silent mp3’s, I can’t get it to shut up with the initial bleep noise that it makes. I don’t know about you, but I don’t need a sound to tell me that a sound is coming. Just play the sound.

So, I figured using a different media player would be better. And it sort of is, except for this playlist problem. For each sound I want to trigger, I need to add that single sound to a separate playlist. This is overkill, but clearly solves a current problem, which is the inability to directly call a specific file.

This leads to the next problem. If a media player has been queued up to play a set of songs and is currently playing, HA will trigger the playlist with the sound effect, send it to the media player, and the media player (Volumio in this case) wipes out all of the songs currently in the queue, plays the media, then stops, leaving you hanging to start-up your music manually again, and recreate the entire queue. Not a viable option in any setting.

On a side note, Google Home also stopped playback of already playing music.

At this point, there doesn’t seem to be a way to capture the information from the current song, play the sound effect, then re-start playing from where it left off. And there’s that deleted queue problem.

The only solution, currently, is to run two separate Volumio media players. One for music, and one for sound effects, and feed them directly into a mixer and then distribute the audio signal via whatever means you prefer.

To the developers: Is there a way to fix this behavior?

I know someone created an automation for squeezebox that saves the current playlist, plays the notification (or chime, or whatever) and then resumes the playlist. It might give you some inspiration. I’ll see if I can find the thread.

Edit: here Squeezebox Audio Alert Script

Wouldn’t it be possible to call a shell command like
aplay <your_mp3>
Which is definitely for audio files.

As I understand, not from within HASS.io. Unless I’m mistaken.

I’m running HASS.io in Docker on Ubuntu 16.04 and all of the media files are stored in the

/usr/share/hassio/homeassistant/config/www/sounds/ folder.

If I ran a shell command, it seems that I would need to be able to play that sound from the host, which is a server that doesn’t have a sound card.

In any event, even if executed on the client (sound making) computer aplay would not address the issue of the interruption of the playlist and resuming it after the notification is delivered.

The squeezebox script I referred to above does take care of the playlist, and also shows how to play a file as opposed to a playlist. However it does this by direct calls (via curl) to the squeezebox api, not via services that are generally applicable to the media_player component of home assistant.

I believe you could do the same with the volumio api. https://volumio.github.io/docs/API/REST_API.html

The general approach I believe would be to:

getState # get the current state of the player
getQueue # get the current playlist
playplaylist # play the message you want
(there must be some way to restore the state but I can't find it at present)
replaceAndPlay # retrieve the playlist and play it