Chromecast binding - Youtube not working?

It might be possible to put video in Google Photos and then use the shareable link, but I’m not confident about that. Putting the video on your server is the way I’d personally go, since it removes the Internet from the equation.

Thanks, yes… removing internet is always the way to go if possible.

Well I finally made it work but with “local” media since I could not get the youtube videos URI.

For those who like me didn’t understand how to make this work
Do something like this:

Create this Thing:

Thing chromecast:chromecast:THING_NAME          "THING_LABEL"                 [ipAddress="192.168.XXX.XXX", port=8009]

The IP is your TV/Chromecast IP address. Name and labels are up to you.

Create these Items:

Player  StartPlaying          "Start Playback"                           {channel="chromecast:chromecast:THING_NAME:control"}
String  PlayUri               "Play Uri"                              {channel="chromecast:chromecast:THING_NAME:playuri"}
Switch  Play                 "Play"
Switch  Stopit               "Stop "                              {channel="chromecast:chromecast:THING_NAME:stop"}

Then, find the video you want to play and download it.
Put it inside your Openhab instalation directory inside : …\conf\html folder. For example “c:\openhab\conf\html”. Let’s say the video is called “video.mp4”.

Then finally, make this rule:

rule "Chromecast"

when 

    Item Play changed to ON

then 
                        // HERE PUT YOUR OPENHAB SERVER ADDRESS AND PORT
    PlayURI.sendCommand("https://192.168.xxx.xxx:8080/static/video.mp4")
    StartPlaying.sendCommand("PLAY")

end

It should work now if you go to your openhab items board and flick the switch “Play”

The rest of the rule is up to you. I’m still figuring it out.

New important question…

Is it possible to set the video to “repeat forever” ?

Video can be a pain to cast as google REQUIRE CORS headers to be supplied at least for some formats. I had to implement this in the ipcamera binding so that cameras on your local network can cast their streams, mp4, gif and jpg files. Which formats require this are outlined in the google docs, however it is not very clear if you don’t go looking for the info. If you have a camera setup with the ipcamera binding, you can serve some files and take advantage of this if your having issues using the normal static server.

I cast a lot of media around my home and it works pretty well once you take care of the CORS or use the IpCamera binding as it does this for you.

google cast - How to enable CORS for streaming on Chromecast using Media Player library? - Stack Overflow

1 Like

You probably have to set up something like Design Pattern: Looping Timers to play the video, sleep for a bit until it ends, then play it again.

Thanks! will try that