Welcome !

Read, comment and forward on your own risk :-)

Saturday, November 21, 2009

Displaying XML code in HTML

In my previous post about playlist for WD TV I wanted to show some XML examples. From endless reading of developer blogs and sites I know that the best practice is to show the block of code in its own section, easy for copying, preferably indented and, as a bonus, with the syntax highlight. After compromising on the last one, the quickest solution I find for the problem is to use the <pre> tag with some extra style definitions.
First of all, the XML has to be converted to replace the bracket and other characters with HTML entities, their decimal or hexadecimal codes. There are several tools for this task, including text editors with Text2HTML converters or online tools such as http://htmlentities.net. If the indentation is important - make sure you’re source XML is indented before the conversion.
The next step is to define the HTML section that will contain your XML:
<pre style="background-color: #F5F5F5; border-left: 2px solid silver; padding: 5px; overflow:auto;">CONVERTED XML GOES HERE...</pre>


If you have several XML code sections, you can reuse the same technique or define the style for all <pre> tags by the stylesheet file that could be used for several pages or in the <head> section for this page only. I guess, it should be possible to add this to my Blogger definitions and use it automatically for all my posts – maybe I’ll check this in the future. Meanwhile, here is the second technique: style override at the <head> section that will be applied each time you’ll use <pre> tag.

<head>
<style type="text/css">
pre{ background-color: #F5F5F5; border-left: 2px solid silver; padding: 5px; overflow:auto; }
</style>
</head>

Friday, November 20, 2009

WD TV Video Playlists




I bought the WD TV HD Media Player a few months ago and I’m totally pleased with this little device. It finally brought my TV to its top capabilities showing full HD content so brilliantly.
WD (Western Digital) has a team working on the firmware updates bringing additional features to the hardware owners. One remarkable addition in the latest 1.03 firmware was the video playlist support. Unfortunately, the documentation of this feature seems to me too general. It says in the FAQ section:

How do I find media files and create playlists?

Several media player applications are currently available, such as Winamp and iTunes, that let you play, arrange, and edit media files. These media players also let you create playlists and edit the metadata information for media files. You can search the Internet with your browser to locate where these applications are available for download.
Searching the web I didn’t find anything more specific, so I decided to discover it by try and fail. My first try was Microsoft Windows Media Player that generated the following playlist:
<?wpl version="1.0"?>
<smil>
<head>
<author/>
<title>Playlist Name</title>
</head>
<body>
<seq>
<media src="F:\VIDEO\Video.01.avi"/>
<media src="F:\VIDEO\Video.02.avi"/>
<media src="F:\VIDEO\Video.03.avi"/>
<media src="F:\VIDEO\Video.04.avi"/>
</seq>
</body>
</smil>

I also check the playlists (*.m3u and *.pls) provided by WinAmp but the one above looks more robust for me due to SMIL it’s based on. The only problem with it at the first sight was the absolute path to the files defined in the playlist. I searched again for defining a relative path in SMIL and found something related describing the ‘\’ character as the root reference for the relative paths. After the fix my video playlist got its final shape shown below which was tested and works fine on the 1.03 firmware.
<?wpl version="1.0"?>
<smil>
<head>
<author/>
<title>Playlist Name</title>
</head>
<body>
<seq>
<media src="\VIDEO\Video.01.avi"/>
<media src="\VIDEO\Video.02.avi"/>
<media src="\VIDEO\Video.03.avi"/>
<media src="\VIDEO\Video.04.avi"/>
</seq>
</body>
</smil>

P. S. Strangely, but it’s impossible to play the whole playlist by hitting the Play button while you see it in the list of other entries. You have to enter first into the list and only then Play will do the job. Is this a bug or a feature?