Record state of media player before playing tts message, restore after tts message is finished


I have a Squeezebox in every room. I love that I can use them to send tts messages from HA… however… if they are currently playing music or streaming audio, the tts message INTERRUPTS the music.

What I’d like is if tts could attempt to record state of player before tts message, play tts message, and then restore media player state after tts message finished playing.

It seems like there should be a generic pre and post hook for this in the tts code that allows media player specific tools to get current state, and set that state again after playing tts.

Also, I think that it would be nice to be able to set default media player settings for tts use - like - power on, volume = 75%, and then reset these to what they were before tts was played

Another squeezebox fan!

Try this thread Squeezebox Audio Alert Script

Thanks! That’s really helpful, however… I still think that the main tts code should be enhanced to attempt to get media player state before tts and restore afterwards :slight_smile:

What media player state ?

There are many integrations for many players, it is not a single integration and each has its own subtleties so there is no one size fits all solution.

@rcampbel3 that would be nice, but I think @Mutt may be right.

Actually …
I’ve been thinking about this.
And admittedly I’m thinking in terms of API’s and translation layers but if we change the angle of attack, this might work.
The problem though would be that everyone’s media interfaces may suffer as a result for the period until the change permeates all integrations.
So if the HA instance HAS to go through a common defined ‘media player function suite’ (an abstraction layer if you will. change name as appropriate) then ALL the required functions could be defined for all media players (and be available even if the ‘Bob’s media player’ integration does not support all of them).
So ‘you’ as a user, interface with the ‘media player function suite’ and that interfaces with “media_player.bobsmp_living_room” (or whatever) which is connected under the ‘Bob’s media player’ integration.
So this is a bigger task than just one integration, as a new layer would have to be created, agreed and published (probably not in that order :rofl: ) and all integrations tested with it. Then we have to live with it until any resultant bugs are ironed out.
This is quite an investment of time from both the devs and the authors of all the current integrations. With an upfront commitment from the devs.
First off though you’d need a full list of media player interface requirements. Easy ones are volume up, volume down, volume percent, power, play, pause, stop, next, last, source, position etc. Then you have the more difficult ones of resume_source, resume_position, resume volume, resume index, default media volume (maybe needs to be per source) , default tts volume, default tts play gap (that irritating chunk you lose at the start of tts) etc. (edit: you might as well include nice to haves, like favourite sources, playlists, shuffle, straight list, repeat one, repeat all, target player (easy) target group (more difficult), groups, synchronisation plus all the others I’ve forgotten).
It’s quite a big task but doable if there’s a will.

… And - who isn’t a squeezebox fan ? . . . :puzzled: . . . :rofl:


Note: there was a patch released today (2020_04_09 release 0.108.1) that seems to be specifically addressing tts as one of its major notes (rereading that its a bit odd phrasing but you get what I mean)