Homey Community Forum

*SOLVED* Chromecast app: Use variable in youtube URL

I am trying to play a 1 hour Youtube video but starting at a random time in the clip.
This because it’s linked to a zone active and re-starting the video is boring.

Youtube supports a T variable:
‘(Dua Lipa, Coldplay, Martin Garrix & Kygo, The Chainsmokers Style - Feeling Me #38 - YouTube)’
This starts the video at 2 minutes.

Now I tried to use this URL in the Chromecast app, but it starts the video from the start and not at 2 minutes: https://www.youtube.com/watch?v=Qz6XNSB0F3E&t=120

The next step would be to randomize the start using:
t={{round(random(0,120))}}

Does anyone know how to include the variable in the Chromecast app URL ?`

Flow Example: Gedeelde Flow | Homey

Also tried to use a tag in the url and to let a viarable calculate the random number.
But this also didn’t do the trick.
Google TTS gives a random number, so that parts works, but the video starts at at 0 seconds:

As far as I know Homey only allows number calculations, not string calculations. Google cast does allow tags for the URL, so what I would do is use Homeyscript to generate the complete URL and put it in a Better Logic variable (normal logic variables cannot be set from Homeyscript as far as I know). You then can use the variable as an URL you can cast.

It should at least be possible to maybe make a separate flow that does a calculation, put the result in a text variable and use that variable as your URL tag?

I think the app (developed by Athom) supports only one variable in the URL. And that is the video ID. A second variable is ignored :frowning:

Well not completely, because using a ?t= Instead of the &t= starts the player, loads the video, but doesn’t start to play.

If anyone reading this is willing to compile an url that could do the trick… I am looking forward to a reply :blush:

Unfortunatly: Not in the sourcecode

Using a variable isn’t in the sourcecode of the app :frowning:

Youtube card only allows videoID.
image

Also found an seek function , but seems like it’s not in use:
Screenshot 2021-02-16 at 10.35.46

Found the solution for playing YT at a specific time:
Using an embed url it works:
https://homey.app/nl-nl/flow/ZI6pGu/

https://homey.app/nl-nl/flow/wH7pGu/

1 Like

You’re a magician :smiley:

IT WORKS! :smiley:
image

1 Like