Play local media at a specific position on google cast (google home)

Hello,

i have been reading here and playing with home automation for a while. But now i have no idea how to get it working.
I am trying to play local media (mp3) from HA at google home at a specific positon.
My goal is to create an automation which plays an local mp3 for perhaps 20 minutes and stops. the next time i start this media it should start at 20 minutes and stop at 40 minutes and so on. But i am struggling at the beginning.

  1. I cant play local audio
  2. I cant play it at specific positon

my media is located in the media folder.

I hope someone can help me, thanks!

The issue I see is that when you stop a media the media position is lost.
So you need to make sure you update the media position before stopping the playing.

How will you stop the media? You will have to do play_media to update the position save it, then stop.

To play a media you use the media player play media with data:

{
    "entity_id": "media_player.kok_mini",
    "media_content_id": "https://IP_or_URL:8123/local/audio/Magic_Wand_Noise.mp3",
    "media_content_type": "audio/mp3"
}

The above is json, but that is because I use node red, but you can just convert that to yaml if that is your weapon of choice.

To play at a specific position you can use media player media_seek.

again… json…

{
        "entity_id": "media_player.chromecast_vardagsrum",
        "seek_position": 500  
}

to make it play from 500 seconds

Thank you for your help but it didnt work for me.
I get an login error each time i want to play local audio located at “media”. If I start it with the new “media browser” its playing for a couple of minutes and than suddenly stops.
If local media is playing and i call seek_position it start at the beginning.

entity_id: media_player.google_home_mini
media_content_id: 'http://LOCAL_IP:PORT/media/audio.mp3'
media_content_type: audio/mp3
entity_id: media_player.google_home_mini
seek_position: 240

Did you try like this?

yes i did it the same way and get the following error: “Login attempt or request with invalid authentication from Google-Home-Mini”

Try and move the file to the www folder and use /local/ instead of /media/

if i move the audio file to www i can play it but it is accessable from the internet for everyone and seek doesnt work as well

In that case you have some serious issues with your setup.

Can you please explain how that is accessible for everyone?

i have my own domin with an ssl-cerifacte. I forwarded my local ip to my domain: https://domain.com -> http://ha_ip:port. everything in my www folder is accessable like https://domain.com/local/audio.mp3

But that is only if you have the direct link to a file, right?

i dont know, is this important? its accessable without any kind of authentication. Is there no way to access my files without publishing it?

Just try and see.
Is it important… Well, it does make a difference in my opinion. What are the odds that someone guess your domain and your file name and want to listen to it?

I don’t know if there is a way around it but google devices are cloud devices, I wouldn’t be surprised if it’s not possible.