Out of the box, a Sonos system is not able to play (the audio of) YouTube videos. How to achieve this? If you have a server (or a VM running Linux) that is always turned on in your house, here is a rough tutorial on how to set this up using only free software. Press the Send to TV button on your phone's YouTube app, and your Sonos system will play the audio track of the video!
The idea is to have the YouTube audio play on your very own internet radio station, and have the Sonos tune to it. Here is the sketch of the solution:
Cast receiver. The "Send to TV" button of the phone's YouTube app uses the DIAL (or Cast Receiver) API to instruct your TV to play the selected YouTube content. The leapcast software (https://github.com/dz0ny/leapcast) emulates a Chromecast device, which understands the DIAL API. Install it on your server, and you will be able to use the Send to TV button to play the video on your server.
Internet radio. Use IceCast2 and Darkice to convert the audio output of your server into an Internet radio station the Sonos system can tune to. Whenever you send a video to your server with the Send to TV button, the radio station will broadcast the audio track of the video.
Monitor. A simple python script (below) monitors the audio output of the server, and instructs the Sonos system to tune to your radio station whenever it detects audio activity (using the SoCo remote control software - https://github.com/SoCo/SoCo).
The full tutorial and monitor script are now hosted on Github: https://github.com/gpothier/sonoscast
If you want to play YouTube on Sonos you can use the free software SonoAir: https://www.youtube.com/watch?v=ThQiw_UTYr8
You can play any sound (YouTube, Spotify...) from your Mac to your Sonos speakers by installing SonoAir (Mac OS El Capitan and Yosemite users) or AirSonos (for Mac OS Sierra users). Those 2 softwares are free and work really good.
For El Capitan and Yosemite users, here are the instructions: https://youtu.be/ThQiw_UTYr8
For Sierra users, here are the instructions: https://youtu.be/mi5u5Sa3UCk
SonosTube Android version has been released.
You do not need any software, you just need three little hardware:
1. Chromecast (1080P old version is enough)
2. HDMI to VGA adapter with audio (3.5mm)
3. 3.5mm audio to RCA cable (link from adapter to Sonos connect)
The connection is straight forward. Connect HDMI cable from Chromecast device to HDMI adapter; Connect 3.5mm audio line to HDMI adapter; Connect RCA lines to Sonos connect.
Then you can cast YouTube video to your Sonos connect without a problem. I just setup it up and it works like a charm. Because of hdcp the video from VGA maybe blank, but who cares, I just want the audio from 3.5mm.
Now I can stream YouTube video directly from YouTube app on mobile or Chrome browser on computer as standard Chromecast device.
BTW, there is no limitation on some YouTube apps on mobile that you need to keep your screen on and YouTube app in foreground to keep the video playing. You can just cast the video and then do other things on your mobile device, the Chromecast think you are using the VGA watching the video but actually not.
This is a perfect solution at low cost. Try it.
I recommend an iphone / ipad app that can play YouTube via Sonos: SonosTube.
It is the only app in Apple App Store to play YouTube via Sonos. SonosTube can play video on your iPhone / iPad, meanwhile, play audio on your Sonos speakers.