Is it possible to coordinate (queue or wait to finish) multiple calls to media_player.play_media? I think to do so would require knowing when the media player is done playing what you sent it, but when you send to multiple that may be problematic if they are not all closely in sync. Maybe knowing the time duration of the audio file being played would be sufficient if there isn’t a way to know whether what you played has finished.
I’m playing local audio notifications with a script config so that I can have a chime sound followed by the TTS message. What I have found is that the TTS plays before the chime has completed (sometimes the chime hasn’t even started). I have also found that a subsequent call to my script will end anything already playing, so if more than one thing at a time is trying to notify the last call wins and the other notifications are either partially heard or not heard at all.
My current solution is a delay in the script sequence to ensure the chime plays fully before the TTS plays, but that’s weak because different chime sounds are different lengths. It also means we can’t have the TTS generation happening in parallel with the chime sound so it’s less delayed if the TTS generation is slow.
I actually have 2 scenarios I’d like to achieve. First, if the same entity sends a subsequent notification while playing a previous notification it’s ok if it cuts off the playing notification because only the latest state matters (i.e., a door opens and then closes quickly. The other scenario is when different entities play notifications at the same time, they should all be heard one after the other without cutting each other off. In my mind I’m picturing a queue where each entity can only be in the queue once and only the most recent notification for each entity is played in turn. I’m sure anything that fancy will require a custom integration or something.
Thoughts?