Sat, Dec 17 2005 1:03 AM Erwyn van der Meer

Cleaning up the Windows Media Center SDK JavaScript files

Since a couple of weeks I am very busy working on a new project. We are building a hosted HTML application for Windows Media Center Edition 2005.

The Green Windows Media Center Button

One of the tricky aspects is that one of the requirements is that the site must be able to work with minimal changes in other interactive TV devices such as set-top boxes. We chose the route of strict separation of content and layout by authoring the pages in XHTML 1.0 Strict and CSS 2.1. On top of that we use JavaScript for things like focusing and selecting elements with a remote control.

The examples provided in the Media Center SDK use non-standard HTML coding like custom attributes that are not in the (X)HTML DTDs. For example, the SDK JavaScripts look for the MCFocusable attribute on HTML elements as an indication that the element can receive the focus. They also use .htc files. A much cleaner approach is to use CSS classes on elements to indicate behavior and to attach appropriate events like onmouseover using JavaScript after the page has been loaded. We use class=”bh_focusable” on elements to indicate that they can receive the focus. To be able to do this, we had to rewrite the JavaScript “engine” provided in the Media Center SDK.

One of the nasty things with the Media Center SDK JavaScripts is that they rely on the Quirks Mode rendering in Internet Explorer 6.0. We noticed that some things break when we put the XHTML 1.0 Strict DOCTYPE declaration on top of our XHTML files:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

This puts IE 6.0 in (Almost) Standards Mode. We are still working on resolving some of these issues.

One issue we solved is the scaling behavior of the site when the site is not running full screen in Windows Media Center. The application can be running in a window that can be scaled by the user. You author a page as if the resolution is always 1024*768 pixels or 1366*768 pixels. In Quirks Mode the scaling is a simple as using document.body.style.zoom = nScale;. This scales all HTML elements on the page. But in Standards Mode absolutely positioned elements do not scale. We added code to the onScaleEvent function to walk the DOM tree and scale each absolutely positioned element individually. It was a bit tricky because these elements have to be repositioned as well, i.e., the left and top CSS properties have to be scaled. This involved storing the original positions using a expando initialPosition property on the HTML elements and using these for the scaling calculation.

Filed under: ,

# re: Cleaning up the Windows Media Center SDK JavaScript files

Saturday, December 17, 2005 2:03 PM by Nathan Pledger

Hi Erwyn,

This project interests me on two points:

1/ Windows Media Centre sounds sexy and I am saving up for a super PC to replace my TiVo and AudioTron set-up. While Windows MCE sounds sexy, it seems to be a closed framework with very little extensibility. Yet you are working with it in this way? (I'm currently favouring MediaPortal)
2/ I'm interested in rendering web content using Accessible contents so it works on different mediums using technologies defined by standards bodies such as the W3C. I'm intrigued why you would be using JavaScript to do your scaling. I appreciate you'll probably be using it for interactive content? This project seems exactly what the CSS media type "tv" is made for?

# re: Cleaning up the Windows Media Center SDK JavaScript files

Sunday, December 18, 2005 1:41 PM by Erwyn van der Meer

Hi Nathan.

The UI for the application we are developing is tuned in every way for the interactive TV medium: large font-sizes, usable through a remote control, large focussable buttons for navigation, interactive videos etc.

The HTML rendering engine of Windows Media Center is IE 6. The client demands that the application will work on WMC first. Since WMC does not support CSS-TV we don't use this for the first release.

The SDK function for WMC does little more than document.body.style.zoom = vScale; (I know zoom is a Microsoft CSS extension).

WMC is a pretty open platform. It can be extended in two ways: hosted HTML applications and add-ins. Check out the Media Center SDK for more details.

# re: Cleaning up the Windows Media Center SDK JavaScript files

Sunday, December 18, 2005 11:25 PM by Nathan Pledger

"Since WMC does not support CSS-TV"

I should have known! A perfect opportunity to adopt standards missed by MS again.

I'll certainly look into the SDK, though due to the price of MCE kit and the limited availability of the OS, I don't really see myself buying into that.

# The new www.rabobank.nl web site

Tuesday, February 07, 2006 4:16 PM by Erwyn van der Meer

The new www.rabobank.nl web site has gone live. XHTML 1.0 rules!