← Back to blog

Videos play, right there on the page

· TinyX · 4 min read

Videos play, right there on the page

There is a small, specific indignity in being sent a video file.

Someone shares a cut of the edit, or the clip from the shoot, or the screen recording of the bug they can't describe in words. You click the link. You get a page with a Download button. So you download it — four hundred megabytes, a minute or two, into a Downloads folder you have long since stopped organising — you find it, you open it in whatever your machine thinks should open it, and then, finally, you find out whether it was the right cut.

It usually was. That's the part that stings. You did all that to confirm something you could have confirmed in four seconds.

As of this release you just press play.

The player is your browser's

Share a video through TinyX and the person you send it to gets a real player on the link page. Not a download prompt with better manners — an actual video, sitting in the page, ready to go.

We deliberately didn't build our own. The player is the one your browser already ships, which means fullscreen works, picture-in-picture works, AirPlay works, playback speed works, captions work, and the keyboard shortcuts you have in your fingers work. Every skinned custom player on the web is someone's attempt to re-implement that list, and most of them get about two thirds of the way there. We'd rather hand you the two thirds nobody has to re-implement.

The unglamorous part: seeking

Here is the thing that made this a real piece of work rather than a one-line change.

Video files are big, and nobody watches them from byte zero to the end. You drag to the middle. For that to work, the server has to be able to answer "give me bytes 40,000,000 through 41,000,000" — a range request — rather than only ever handing over the whole thing from the start.

We weren't doing that. Anything you opened in the browser arrived as one long stream from the beginning, which meant dragging the scrubber to the twelve-minute mark quietly downloaded the first twelve minutes to get there.

And iPhones were stricter than that. Before Safari on iOS will play a video at all, it asks a small, pointed question: it requests the first two bytes of the file. Not to watch them — to find out whether the server understands range requests in the first place. Answer that question with the entire file and Safari concludes the server can't seek, and simply declines to play anything. Which is exactly what it had been doing.

So the real work of this release was byte-range serving: 206 responses, honest Content-Range headers, a proper 416 when someone asks for a range past the end of the file. It's about as unglamorous as engineering gets. It's also the whole reason the scrubber works and the reason it plays on your phone.

A frame instead of a black rectangle

A video player with nothing loaded is a black rectangle, which is a poor advertisement for the thing inside it. So when you upload a video now, your browser quietly grabs a still from it and keeps that alongside the file.

Two small decisions in there we're quite fond of. It doesn't take the first frame — first frames are fades, slates, and lens caps — it skips a little way in to somewhere with actual picture in it. And that same still becomes the preview image when you paste the link into Slack or iMessage, so a shared video now unfurls as the video rather than our logo on a card.

One honest caveat: the still is captured by your browser as the file uploads, which means videos already sitting in your library don't have one. They play and scrub perfectly well — they just look blank until someone presses play. If you want the frame, re-upload.

Watching is not downloading

If you cap a link at three downloads, you mean three people can have the file. You don't mean the video may be scrubbed three times.

So watching costs nothing. Someone can rewatch it, drag around in it, leave it and come back — the counter doesn't move. It moves when they click Download, because that's the moment they actually took a copy. Send a folder of clips and it behaves the same way: each one opens in a player on the page, you close it, you keep browsing.

The boring specifics

MP4, M4V, WebM, OGV and MOV play. MKV, AVI, WMV and FLV don't, and never will here — no browser can decode them, and we're not about to start transcoding your files behind your back. Those keep exactly the download page they have today. If a file turns out to use a codec your particular browser can't handle, the player tells you so and points at the download, rather than showing you a broken rectangle and letting you wonder.

Inline playback is on Pro and above. Free links work exactly as they always have.

Small feature. Absurd amount of plumbing. Press play.