Subscribe to RSS feed

A few tips on TV web development

, , , ...

An Opera TV Store seminar in Tokyo

Over the past few days I've been lucky enough to give a couple of talks on web development for TV. It seems there's growing interest and enthusiasm in this area, which I'm pleased to see, because although it can be frustrating, web on TV also offers opportunities for innovation and interesting technical challenges.

There are many things to consider when creating a great user experience and we have some in-depth TV tutorials over on Dev.Opera, but in my experience there are a handful of priority problems that, when fixed, go a long way towards making life easier for TV users. They can mostly be linked to three main characteristics of TVs:

  • TV screen — actually quite small from a normal viewing distance.
  • Remote control — keypad-based and slow, due to infrared lag.
  • TV hardware — generally less powerful than mobile phones.

These characteristics lead to a number of problems; in the next section we'll expand on these and outline some possible solutions.

Problems (and what to do about them)

Font size
Text on most websites is too small to be read on a TV while sitting on a sofa. Try increasing the font size by about 2.5 times.
Lack of on-screen space
Because the text should be large, you now have less space for other elements so reduce or hide unnecessary page sections, much as you would for mobile.
Non-focusable elements
With a keypad, it's hard or impossible to click on a div or image that is pretending to be a button, for example if you are using JavaScript to capture a click or other event. Use tabindex="0" to make such elements focusable, as in this spatial navigation challenge.
Cumbersome scrolling
Scrolling should be minimized where possible. A relatively unknown but useful optimization is to use CSS directional focus navigation for easily moving around lists of objects, like an image gallery for example. See our Tweaking spatial navigation article for more details and an example.
Inputting text
Quite simply, avoid this wherever possible! Text input on a keypad over infrared is fiddly and frustrating. Either offer lists of choices to provide users with sensible defaults or see if any of the newer HTML5 input types can help.
Animation
Try to minimize the use of animation. Because of the lack of processing power you'll encounter on TVs, animations can really slow things down if you're not careful. A couple of tips are a) use CSS3 effects rather than JavaScript; b) animate properties that require fewer reflows, for example transitioning left or top is usually faster and smoother than width or height.
Caching/localStorage
This can be unreliable because of a lack of hardware storage space and inconsistent behaviour across devices. Store things like user preferences on the server-side if possible.
Detecting TVs
Unfortunately the TV media type is rarely used, including in Opera's TV browser and Google TV. An alternative is to detect TVs with media queries — there are only 2 or 3 standard TV resolutions. It's a bit of a hack, but here's an example of how to use it to enlarge font size when a page is viewed on a TV.
Difficulty in testing
Using your hand to estimate a TV screen's viewing sizeTesting on a TV is essential but can be time-consuming, so in the early stages of development I recommend simply moving back from your PC until the finger and thumb on your outstretched hand are the same size as the PC screen. Believe it or not, this viewing size is about the same as for the average TV viewer sitting on their sofa. To test keypad usage, a handy feature in Opera is the ability to press [Shift] + [arrow keys] to move around a page with spatial navigation. Finally, we have a free TV emulator, which provides the same environment as that on many actual TVs.

The good news!

Despite the hurdles, TVs have some key advantages over PCs and mobile devices:

  • The big screen and speakers mean good video and audio quality.
  • Many people, especially the young and the elderly, and more familiar with using a TV than other devices.
  • TVs enjoy pride of place in the home and can be viewed by multiple people at the same time.
  • You don't need to be close to a TV to use it.

There are a few ideas of using these advantages to create TV apps towards the end of my TV strategy slide deck. As you can see, we're restricted in what design techniques we can use but these restrictions can be fuel for creativity. It's still a young area of web development and is ripe for a new breed of apps and experiences to emerge.

Graceful User Agent Sniffing

,

A common sad story in the world of user agent sniffing. This time it is with Alto, a mail service from AOL. Note that it is a widespread issue, not specific to AOL and altomail, which could easily be avoided. This post is not about altomail specifically.

User-Agent sniffing is a very high maintenance task

This should be on top of the screen of every project manager and web developer in their companies. There are many ways to get it wrong. And even if you get it right now, there is no guarantee that it won't be wrong in the future.

What happened in the case of Alto? Trying to access this Web site, you get a classic message such as:

OOPS!

It looks like you're using a browser we don't support. The application works best with Chrome, Firefox, and Safari

Alto's 'OOPS!' served to Opera users

Skilled Opera users will eventually go to their configuration settings and lie about the User-Agent string. For example, here we decided to set the User-Agent to be Firefox for this specific domain name.

Opera's site preferences, with the 'Network / Browser identification' set to mask as Firefox

Note that at this stage, one of the consequences for Opera Software is that the browser is not visible anymore in the Web site's statistics. The browser market shares are then not representative of the reality. To fix the problem at the source, we are currently trying to contact Alto to solve the issue.

Initial conversations with Alto's support on Twitter, simply stating that Opera is not a supported browser

Eventually, if it doesn't work, we will turn to Opera's browserJS, a central patch list which will modify the User-Agent strings for this domain for all users automatically. Even if we disappear from the statistics of this web site, it is still better for the users. So once the dance of lies takes place, we can access the Web site.

Alto displaying fine in Opera, once we've set it to mask as Firefox

Is there a better way?

  1. Avoid User-Agent Sniffing. It is hard to get it right. Really.
  2. If you need to use specific technologies, use feature detection first.
  3. If the only resort is to do User-Agent sniffing, check all the browsers you are sure about and then always offer a fallback.

Note that blocking access to a site purely based on a User-Agent string is often a future fail scenario. Browsers evolve and you do not know in advance what set of features (removed or added) they will have. User-Agent sniffing is a very high maintenance task. We understand that not all companies can afford to thoroughly test their sites in all browsers, but just because they didn't test shouldn't be a reason to completely deprive users of those browsers that didn't make the list from accessing any of the content. Sure, cover your back, and state upfront that this particular browser wasn't tested (and not that it's an old/outdated browser, or that your site absolutely requires browser X), but let the the user decide if they still want to try and proceed.

The State of Vertical Range Inputs (as of Nov 2012)

,

Yesterday I found myself needing to write a silly demo to sketch out some code (to be used in a larger project). The idea was to dump a ton of <input type=range> elements on a page, alternate between horizontal and vertical orientations, and manipulate the value property in various magical ways.

The default rendering of type=range is a horizontal slider widget. To see it yourself quickly, put the following in your browser URL bar:

data:text/html, <input type="range">

There's a catch though — not all browsers support this yet. But we're really, really close, especially with an implementation in progress for Firefox (Microsoft beating Mozilla? End of days, etc.).

So how do you get a vertical range slider? The HTML Standard mentions "determin[ing] the orientation of the control from the ratio of the style-sheet-specified height and width properties." So as long as you define the width to be smaller than the height, your browser should create a vertical range input for you.

You can see if this works in your browser right now.

Unfortunately, Opera is still the only browser to support this out of the box. Webkit-based browsers can get by with the -webkit-appearance: slider-vertical non-standard CSS, but that doesn't help Firefox or IE10.

But what about Firefox? Luckily there's a handful of polyfills out there. You'll just have to let me know if anyone of them enable vertical ranges, and will work for IE10!

So the good news is that we're really close to all modern browsers supporting <input type=range>. And the less good news is that native vertical ones need more time. It's time to tweak my silly demo.