Back to Feed
article 3m read

The smart screen guesses which player is my TV, and two blanks count as a match

The media server and the streaming box share no ID for the TV, so the screen matches players on address or name. Rereading it, I found that a missing value on both sides still counts as a match, and that the screen can't tell a broken server from an idle one.

Article DepthPractice

Flow

Where the headline comes from, and where it slips

  1. 1Ask the server first

    It knows the episode and if it is paused.

  2. 2Match on address or name

    Either one counts; the first fit wins.

  3. 3Blank equals blank

    Two missing values still count as a match.

  4. 4Nothing or broken

    Both fall back to the box, so they look the same.

  5. 5Clean up the box text

    Home, menu or no app says nothing is playing.

The biggest text on my smart screen's media card was the label. It asked what's playing. The real answer sat under it in small type. When the streaming box was idle, that answer was the home screen's name with the word "close" on the end. That's how the box talks. Nobody in the room talks like that.

Making the box's answer readable

First I fixed the screen. The answer moved up into the headline and the label went away. If no app is open, or it's the home screen or the menu, the screen now says nothing is playing. When an app is open, a handful of empty words get dropped. The old code had filled in the home screen's name when the app was missing, then tacked on the state. That's how the bad headline got made. The headline is also one big line now, and a long title gets cut off with dots.

That made it readable, but not useful. The box only knows which app is open. My media server knows the episode, where you are in it, and if it's paused. So the screen now asks the server first and the box second.

Two records, no shared ID

The two systems don't know each other. The server lists who is watching, and each player has a name and a network address. My setup for the remote has its own ID, a host and a name. Nothing links them. So the screen uses a loose match.

A session matches if the address is equal or the name is equal, ignoring case.

"Either" sounds smart at first, because addresses can change and names usually don't.

Two blanks agreeing

That line has a hole. A missing value turns into an empty string, and two empty strings are equal. So a remote with no host set would match any player with no address. Check that both values exist before you compare them. Two players with the same name have a smaller version of the same problem, since the first one in the list wins.

Nothing and broken look alike

The server side keeps three answers apart. It found a match. It found nothing, which is fine. Or it broke. The screen then treats nothing and broke the same way and just asks the box. That's what the room needs. But it means I can't tell a broken link to my media server from a night when nobody turned the TV on.

Keep reading

Pick up a connected idea or branch into a nearby one.

5 paths forward