How does your phone change my TV?
You paste a link on a website. A few seconds later, a TV in my living room plays it. Here's every piece in between, explained like you're five.
One video's trip, step by step
From your thumb to my couch, in under half a minute (plus the vote).
- 1You paste a link.
The web page sends it over the internet to the Referee. Not a YouTube link? It reads the page's title and searches YouTube for you.
your phone - 2The Referee checks it with YouTube.
Is it real? Public? Not age-restricted? Not a live stream? Playable in the US? Long videos aren't turned away: they play just the first 3 minutes.
the internet - 3I approve it (from my phone).
A grown-up looks before it hits the living room. If I turn approvals off, it skips straight to the vote.
my phone - 4Everyone votes for 20 seconds.
The 3 most-wanted videos go on the ballot. One vote each. The winner plays.
the internet - 5The Referee tells the Helper in my house.
The Helper is already on the line (it called out first, so nothing can call in). It opens YouTube on the TV if it's closed.
my house - 6The Helper "casts" it, like the Cast button on your phone.
It uses the same language your YouTube app uses to send a video to a TV. The TV doesn't know it's a crowd.
my TV - 7The TV reports back, and you watch along.
YouTube on the TV says "playing, at 0:42" or "paused." That goes back up to every phone, so your page plays the same video at the same second, and shows ⏸ when the TV pauses.
everyone's phone
Why is there a Helper in my house?
Because nobody on the internet can knock on my TV's door. That's a good thing.
Calling in: blocked
My home router is a locked front door. The internet can't reach in and press buttons on the TV.
Calling out: allowed
The Helper inside calls the Referee and keeps the line open, like a walkie-talkie. Orders come down that line. No door is ever opened.
The parts list
The real names, if you want to look them up.
One web page
A single HTML file, no app to install. It holds a live connection (a WebSocket) so votes and the clock update instantly.
Cloudflare Worker + Durable Object
A tiny program that runs on Cloudflare's servers worldwide. The "Durable Object" is one room with a memory: the queue, the ballot, who's here, and a log of every submission.
YouTube Data API
Asks YouTube about each video: length, age rating, region, channel. Answers are saved for 6 hours so we don't ask twice.
A Node.js relay
Runs on a Mac in my house and starts by itself when the Mac turns on. It only knows two commands: play this YouTube video, and play/pause. Everything else is refused.
YouTube "Lounge" protocol
How phones talk to YouTube on TVs. The Helper pairs with the TV once, then sends "play this list." It also turns off autoplay so random videos don't sneak in.
A normal Samsung smart TV
Nothing installed, nothing hacked. It just runs the regular YouTube app, which is told what to play.
The synced mirror
Your page embeds the same video and jumps to the TV's real position whenever it drifts more than 2 seconds.
tvplay.lol
A domain pointed at Cloudflare. Same code also answers the admin page I use to approve videos from my phone.
Rules that keep it fun (and my house safe)
- You can't touch the TV itself. No volume, no channels, no settings, no turning it off. Only: suggest, vote, skip, pause.
- Skipping takes a crowd. 60% of the people here have to vote skip.
- No spamming. One link every 10 seconds, 3 tabs per network, and anyone flooding buttons gets muted for a minute.
- Your address isn't stored. Your network's IP is scrambled into a code (a "hash") before anything is saved. The raw number is never kept.
- An off switch. I can call an Intermission from my phone, and everything freezes.
- What my family watches stays private. When we're watching our own stuff, the page just says "TV is playing its own thing," never what's on.
Things that didn't work
Most of building this was finding out what the TV won't let you do.
- Telling the TV "open YouTube at this video." Tried three different ways. The TV opens YouTube and ignores the video.
- Installing my own app on the TV. The secret developer-mode menu never appears on this model, no matter how many times you type 12345.
- Reusing connections to the TV. The TV hangs up on them at random, so every request is a fresh call.
- Trusting "YouTube is open." If it's open but in the background, it can't receive a cast. Now the Helper waits until the TV actually says "playing."