Alexa media player automation

Quick question. I have the following automation which gets triggered separately in homekit. The problem is that music doesn’t always start once the automation is triggered on the first try. I have to sometimes turn off the associated switch trigger and turn it back on several times. Is there a way for this automation to check whether music is playing after about 4-5 seconds, and if it’s not, run itself again?

- alias: Boys Bedtime Music On
  - platform: state
    entity_id: input_boolean.boys_bedtime
    from: 'off'
    to: 'on'
  - service: media_player.volume_set
      entity_id: media_player.boys_echo
      volume_level: 0.5
  - service: media_player.play_media
      entity_id: media_player.boys_echo
      media_content_id: "Boys Bedtime playlist"
      media_content_type: AMAZON_MUSIC

You could write a second automation that gets triggered when you switch the homekit switch. Then check if its playing and if not, turn off and on the switch again. Repeat.

I didn’t explain the homekit thing. The “boys_bedtime” boolean is part of a homekit bedtime automation, which turns it on. That’s what triggers this automation.

What I’m looking for is some sort of a loop under “action” that keeps trying to play the playlist until it actually starts playing.

This loop is super easy to do in NodeRed… for YAML im not sure how to do it best.
Probably i would start by creating a script with the Amazon Echo Music playing, and call this from the automation. Then put a wait for timer to check if its playing and an IF function template to recall the script if the answer is false.