 <?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Broken Links &#187; html</title>
	<atom:link href="http://www.broken-links.com/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.broken-links.com</link>
	<description>Thoughts on web development and technologies by Peter Gasston</description>
	<lastBuildDate>Fri, 30 Jul 2010 00:10:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://www.broken-links.com/?pushpress=hub'/>
		<item>
		<title>Encoding Video for Android</title>
		<link>http://www.broken-links.com/2010/07/30/encoding-video-for-android/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=encoding-video-for-android</link>
		<comments>http://www.broken-links.com/2010/07/30/encoding-video-for-android/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 00:07:52 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=900</guid>
		<description><![CDATA[In my previous post, Making HTML5 Video work on Android phones, I said that you have to encode your videos as .m4v in order for them to work in Android. This isn’t actually correct. The suffix can be either .mp4 or .m4v, what matters is the way the video is encoded. Now, there are loads [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post, <a href="http://www.broken-links.com/2010/07/08/making-html5-video-work-on-android-phones/">Making HTML5 Video work on Android phones</a>, I said that you have to encode your videos as <code>.m4v</code> in order for them to work in Android. This isn’t actually correct. The suffix can be either <code>.mp4</code> or <code>.m4v</code>, what matters is the way the video is encoded.</p>
<p>Now, there are loads of blog and forum posts which give differing advice on presets and parameters, and I’m no expert — so what I’ll do is just show you two quick ways that worked for me (I have a Samsung Galaxy S). Note: the other two requirements from my previous blog post still stand.</p>
<p><span id="more-900"></span></p>
<p>The first is cross-platform, and use <a href="http://handbrake.fr/">Handbrake</a>. What I did with this was to use the <strong>iPhone &amp; iPod Touch</strong> preset, check the <strong>Web Optimized</strong> option, and change the <strong>Average bitrate</strong> option (in the <strong>Quality</strong> section) to <em>~1000kbps</em> (you should then save this as a new preset called Android).</p>
<p>You’ll also need to change the size of the output video in the <strong>Picture Settings</strong> options — I changed mine to 480 wide (keeping the aspect ratio) and they came out really crisp and sharp. You can see the result of that below (if your browser supports it).</p>
<p><video controls height="272" src="/tests/media/BBB_480_HB.mp4" width="480"></video></p>
<p>The second method is simpler, but works on Mac OSX 10.6 only. Open up your source video in Quicktime, then go to <strong>File &gt; Save As</strong>. Choose <strong>iPhone</strong> from the <strong>Format</strong> selector. You get less control over your output with this — the width is always 480 and the bitrate is calculated automatically — but it works without fuss. The output of this method is shown below.</p>
<p><video controls height="270" src="/tests/media/BBB_480_QT.m4v" width="480"></video></p>
<p>A slightly more convoluted method is to use <a href="http://www.doubletwist.com/">DoubleTwist</a>, which performs on-the-fly conversion. Connect your Android device, then transfer your video to it — the optimum parameters will be automatically selected. When complete, copy the file back from the device to your computer. (I haven’t actually tried this myself).</p>
<p>I’ll keep this post updated as I discover different methods, and do feel free to let me know in the comments what works for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/07/30/encoding-video-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making HTML5 Video work on Android phones</title>
		<link>http://www.broken-links.com/2010/07/08/making-html5-video-work-on-android-phones/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=making-html5-video-work-on-android-phones</link>
		<comments>http://www.broken-links.com/2010/07/08/making-html5-video-work-on-android-phones/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 16:26:10 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=890</guid>
		<description><![CDATA[I recently became the owner of an Android phone* and found that, despite it being listed as a feature of the browser, the HTML5 video element didn’t work for almost all of the examples I tried. I’ve just done some experimentation with this and think I’ve found a solution, so this post is offered in [...]]]></description>
			<content:encoded><![CDATA[<p>I recently became the owner of an Android phone* and found that, despite it being listed as a feature of the browser, the HTML5 <code>video</code> element didn’t work for almost all of the examples I tried. I’ve just done some experimentation with this and think I’ve found a solution, so this post is offered in the hope that it helps anyone who may be tearing their hair out over the same problem.</p>
<p><span id="more-890"></span></p>
<p>From what I can tell, there are three requirements for <code>video</code> to work in Android browsers:</p>
<ol>
<li>You must not use the <code>type</code> attribute when calling the video</li>
<li>You must manually call the <code>play()</code> method using JavaScript</li>
<li><del datetime="2010-07-29T13:46:34+00:00">The video must be encoded as <em>.m4v</em>, not <em>.mp4</em></del> <strong>Update:</strong> This is not correct (see below)</li>
</ol>
<p><strong>Update:</strong> This may be a specific encoding issue rather than all <em>.mp4</em>s; some <em>.mp4</em> videos seem to play with no problems, others do not. <strong>Further update:</strong> The video type was a red herring; ignore this.</p>
<p>You can see this working in the demo attached to an older post of mine: <a href="http://broken-links.com/tests/video/">Demo: HTML5 Video Controls With JavaScript</a>. This works, <attr title="as far as I know">AFAIK</abbr>, in Android, iPhone and all video-enabled desktop browsers. The markup I’ve used is:</p>
<pre>&lt;video id="video" autobuffer height="240" width="360"&gt;
&lt;source src="BigBuck.m4v"&gt;
&lt;source src="BigBuck.webm" type="video/webm"&gt;
&lt;source src="BigBuck.theora.ogv" type="video/ogg"&gt;
&lt;/video></pre>
<p>The first <code>source</code> element calls the video in <em>.m4v</em> format, without specifying the <abbr>MIME</abbr> type in the <code>type</code> attribute; I’ve tried both <em>video/mp4</em> and <em>video/x-m4v</em>, and neither works. Omitting the type attribute altogether lets the video play, and seems to have no ill-effect on other browsers which play the <em>.m4v</em> file.</p>
<p>In order to play the video in Android, I also have an event listener in the JavaScript which plays the video when the element is clicked on, somewhat like this:</p>
<pre>var video = document.getElementById('video');
video.addEventListener('click',function(){
  document.play();
},false);</pre>
<p>I tested this on my own phone and an HTC Desire, and it works just fine on both. Hope this is of help to someone.</p>
<p>* It’s a <a href="http://galaxys.samsungmobile.com/">Samsung Galaxy S</a>, and I’m delighted by it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/07/08/making-html5-video-work-on-android-phones/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>My Name In Print</title>
		<link>http://www.broken-links.com/2010/05/26/my-name-in-print/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=my-name-in-print</link>
		<comments>http://www.broken-links.com/2010/05/26/my-name-in-print/#comments</comments>
		<pubDate>Wed, 26 May 2010 13:06:31 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Miscellanea]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[glow]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[selfpromotion]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=814</guid>
		<description><![CDATA[I hope you’ll forgive a little self-promotion, as I’d just like to play a few quick notes on my own trumpet. The latest issue of Net magazine is now on sale, and features a tutorial article, Create A Dynamic Content Panel, written by me. In the article I explain how to build a dynamic Contact [...]]]></description>
			<content:encoded><![CDATA[<p>I hope you’ll forgive a little self-promotion, as I’d just like to play a few quick notes on my own trumpet. <a href="http://www.netmag.co.uk/zine/latest-issue/issue-203">The latest issue of Net magazine</a> is now on sale, and features a tutorial article, <em>Create A Dynamic Content Panel</em>, written by me.</p>
<p>In the article I explain how to build a dynamic Contact area, as we did on our recent redesign of <a href="http://preloaded.com/">Preloaded.com</a>, using the <a href="http://www.w3.org/TR/webstorage/">Web Storage API</a> and <a href="http://www.bbc.co.uk/glow/">the BBC’s Glow Javascript library</a>.</p>
<p>I’m not sure what the rights situation is with this article, but I hope that at some point in the future I’ll be able to post it here on my blog. But in the meantime, you can buy a copy of Net magazine in the UK at all good newsagents, as the saying goes (I don’t know if it will be in overseas editions also).</p>
<p><img src="/wp-content/uploads/2010/05/tut_js-1.jpg" alt="Printed Tutorial" title="Tutorial Page 1" width="190" height="250" class="aligncenter size-full wp-image-833" /><img src="/wp-content/uploads/2010/05/tut_js-2.jpg" alt="Printed Tutorial" title="Tutorial Page 2" width="190" height="250" class="aligncenter size-full wp-image-834" /><img src="/wp-content/uploads/2010/05/tut_js-3.jpg" alt="Printed Tutorial" title="Tutorial Page 3" width="190" height="250" class="aligncenter size-full wp-image-835" /></p>
<p>On the subject of print, I’m also currently writing a book about CSS3 which should be published later this year. I’ll have more information on that nearer the time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/05/26/my-name-in-print/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building a better HTML5 video player with Glow</title>
		<link>http://www.broken-links.com/2010/04/14/building-a-better-html5-video-player-with-glow/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=building-a-better-html5-video-player-with-glow</link>
		<comments>http://www.broken-links.com/2010/04/14/building-a-better-html5-video-player-with-glow/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 12:52:33 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[glow]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=767</guid>
		<description><![CDATA[Last year I wrote a post (Building HTML5 video controls with JavaScript) introducing the HTML5 Media Elements API and demonstrating a simple set of controls for playing video. In this (somewhat belated) follow-up I’m going to explore building a more interactive set of controls using a JavaScript UI library; I’m going to use Glow, but [...]]]></description>
			<content:encoded><![CDATA[<p>Last year I wrote a post (<a href="http://www.broken-links.com/2009/10/06/building-html5-video-controls-with-javascript/">Building HTML5 video controls with JavaScript</a>) introducing the HTML5 Media Elements API and demonstrating a simple set of controls for playing video.</p>
<p>In this (somewhat belated) follow-up I’m going to explore building a more interactive set of controls using a JavaScript UI library; I’m going to use <a href="http://www.bbc.co.uk/glow/">Glow</a>, but it could easily be adapted to <a href="http://jqueryui.com/">jQuery UI</a> or similar.</p>
<p><span id="more-767"></span></p>
<p>You can see the player I’ll be using as an example here — although it must be stressed that it’s not a final version, for reasons I’ll cover at the end:</p>
<p><a href="http://www.broken-links.com/tests/videoglow/">HTML5 &amp; Glow Video Player</a></p>
<h2>The markup</h2>
<p>The video player itself is pretty straightforward:</p>
<pre>&lt;video autobuffer controls height="180" poster="BBB_poster.jpg" width="320"&gt;
  &lt;source src="bbb.mp4" type="video/mp4"&gt;
  &lt;source src="bbb.webm" type="video/ogg"&gt;
  &lt;source src="bbb.theora.ogg" type="video/ogg"&gt;
  &lt;img alt="Film Poster" height="180" src="BBB_poster.jpg" width="320"&gt;
&lt;/video&gt;</pre>
<p>The <code>video</code> element has the <code>controls</code> attribute set, which we’ll remove with JavaScript later. Note also the <code>poster</code> attribute, which displays a still image until the video is ready to be played, at which point it displays the first frame instead.</p>
<p>Next there are two <code>source</code> elements, which serve the video to Firefox, Opera and Chrome (ogg) and Safari (mp4). Finally there’s an <code>img</code> element, which displays if the browser doesn’t have video support. <strong>Update:</strong> Added <a href="http://www.webmproject.org/">WebM</a> support.</p>
<p>As for the controls, rather than list them here I’ll ask you to view the source to see what I’ve done. Basically I’ve added a bunch of form elements; two <code>input</code> <code>image</code> types for the play and volume icons, and two <code>input</code> <code>text</code> types for the duration and volume sliders. The latter two aren’t necessary, but I wanted them there for accessibility reasons.</p>
<h2>The style</h2>
<p>How I’ve styled the player doesn’t matter too much; I’ve been influenced by the Quicktime player for the layout of the controls, but really the CSS isn’t too important here. The only thing to note is that I’ve added some rules here for screen overlays, which I’ll explain in due course:</p>
<pre>.overlay { background-repeat: no-repeat; height: 180px; position: absolute; width: 320px; }
.paused { background-color: rgba(0,0,0,0.2); background-image: url('pause.png'); background-position: left bottom; }
.play { background-image: url('play.png'); background-position: center center; }</pre>
<h2>The JavaScript</h2>
<p>You can see all the script I’ve used in the file <a href="http://www.broken-links.com/tests/videoglow/video.js">video.js</a>. I’ll go through some of the more important functions in turn.</p>
<h3>Setting up</h3>
<p>The first thing I’ve done is removed the native controls from the player for people who have JS enabled, so as not to provide two conflicting sets of controls:</p>
<pre>video[0].controls = false;</pre>
<p>Next I’ve defined some of the key variables which I’ll be using throughout the script. One of those variables, <em>volumeSlide</em>, is assigned to one of Glow’s native widgets, a <a href="http://www.bbc.co.uk/glow/docs/1.7/api/glow.widgets.slider.shtml">Slider</a>; this will be used to control the volume:</p>
<pre>volumeSlide = new glow.widgets.Slider('#volume',{bindTo:'#vol_count', buttons:false, step:0.1, min:0, max:1, size:70, val:1});</pre>
<p>You can see what all the options do in the Glow documentation, but the key ones I’ve set are for it to appear in &lt;div id=“volume”&gt;, to have a minimum value of 0 and a max of 1, and to increment in steps of 0.1. This matches the volume setting for the <code>video</code> element.</p>
<h3>Waiting for the metadata</h3>
<p>For the next step I’m going to create another slider, but this time for the duration/seek bar. In order to do this, however, I need to query the video’s metadata to know what the duration of the video is, and in Safari (which uses mp4 video) that doesn’t load before the rest of my JS has run.</p>
<p>To get around this I’ll poll the <code>readyState</code> attribute every half a second — with the <code>setInterval</code> function — until it’s value is at least 1, which means the metadata has loaded; once that’s done, I’ll load the slider:</p>
<pre>t = window.setInterval(function() {
  if (video[0].readyState >= 1) {
    window.clearInterval(t);
    durationSlide = new glow.widgets.Slider('#vid_duration',{bindTo:'#duration_count', buttons:false, step:1, min:1, max:Math.round(video[0].duration-1), size:260, val:0});
    playVid();
  }
},500);</pre>
<p>So you can see there that I’ve created the slider with a minimum value of 1 and a maximum of the duration of the video (in seconds), to increment in steps of 1. After that the setup is complete so I can begin the actual playback functions.</p>
<h3>Playback controls</h3>
<p>There are too many functions to go into in detail, so I’ll quickly go through what happens. First an overlay is placed over the top of the video, which begins playback when clicked. Next, event listeners are added to the play button, the volume icon, and the volume and duration sliders.</p>
<p>The listener on the play button runs the function <em>playControl</em>, which determines the state of playback (<em>ended</em>, <em>paused</em> or playing) and either plays or pauses the video accordingly. It also updates the icon to reflect its action (if it is paused, the icon changes to a play icon, and <span lang="la">vice versa</span>), and adds the pause overlay onto the video screen when relevant:</p>
<pre>function playControl() {
  if (video[0].paused === true) {
    video[0].play();
    /* Further functions here */
  };
} else if (video[0].ended === true) {
    video[0].play();
     /* Further functions here */
} else {
    video[0].pause();
     /* Further functions here */
}</pre>
<p>There’s a function called <em>startCount</em> which uses <code>setInterval</code> to move the duration slider along by one second while the video is playing, and a function called <em>pauseCount</em> which uses <code>clearInterval</code> to pause.</p>
<p>The <em>muteToggle</em> function does what you expect, and mutes the video; it also changes the volume icon to show that state, and disables the volume slider while it is active.</p>
<p>A further function, <em>volumeIcons</em>, sets the state of the volume icon; there are four possible icon states, which are used depending on the value of the volume.</p>
<p>And the last function, <em>secondsToTime</em>, converts second values into hour/minute/second values, allowing for the timer to be updated. This is done every second by the <em>startCount</em> function, and also used for the function which is called from the event listener on the duration slider.</p>
<p>That event is probably worth looking at in detail:</p>
<pre>glow.events.addListener(durationSlide,'slideStop',function(event){
  video[0].currentTime = event.currentVal;
  var currentSecs = secondsToTime(event.currentVal);
  vidTimer.text(currentSecs.h + ':' + currentSecs.m + ':' + currentSecs.s);
});</pre>
<p>Using the <code>slideStop</code> event I can check when the slider has been moved, and first set the video to begin playback from that point, then update the timer with the same values. The volume slider has a similar event set on it.</p>
<h2>Next steps</h2>
<p>So as a reminder, here’s what I have so far:</p>
<p><a href="http://www.broken-links.com/tests/videoglow/">HTML5 &amp; Glow Video Player</a></p>
<p>Please bear in mind that this is very much a work in progress; I started writing the controls without Glow and introduced it at a later stage, so some of the JavaScript could do with being optimised.</p>
<p>The markup for the controls could also do with some extra work to make them fully accessible, which they probably aren’t right now. Also, all of the dimensions are built around this video size, and won’t scale if different sized videos are used.</p>
<p>I hope to return to this topic when I have more time, and create a robust set of video player controls which can be used in any site without extra work.</p>
<p>Please feel free to let me know if you encounter any bugs or oddities as you use this; it will help with the next stage of development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/04/14/building-a-better-html5-video-player-with-glow/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Building Preloaded.com: The Front-end</title>
		<link>http://www.broken-links.com/2010/01/21/building-preloaded-com-the-front-end/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=building-preloaded-com-the-front-end</link>
		<comments>http://www.broken-links.com/2010/01/21/building-preloaded-com-the-front-end/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 15:53:37 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[glow]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=686</guid>
		<description><![CDATA[This post discusses the redesign project of my employer’s own website, Preloaded.com, and is cross-posted from there with permission.

At the beginning of the redesign project we agreed some design tenets: the new site should be a best-practice showcase and an opportunity to learn and use some of the latest web technologies; and it should employ existing services where practical.]]></description>
			<content:encoded><![CDATA[<p><em>This subject of this post is the redesign of my employer’s website, <a href="http://preloaded.com/">Preloaded.com</a>, and is cross-posted from the Preloaded blog with permission.</em></p>
<p>At the beginning of the redesign project we agreed some design tenets: the new site should be a best-practice showcase and an opportunity to  learn and use some of the latest web technologies; and it should employ existing services where practical.</p>
<p><span id="more-686"></span></p>
<p>To achieve the former we targeted users with the most modern web browsers, using the <a href="http://en.wikipedia.org/wiki/Progressive_enhancement">graceful (or progressive) enhancement</a> method to ensure that even with older technology, no-one would be left unable to read all of the site content.</p>
<p>The most obvious example of this is in the design of the buttons; users with a decent browser (e.g. Firefox or Safari) would see these with rounded corners — because these browsers are capable of producing them natively with the CSS3 <em>border-radius </em>declaration — while users of other browsers (e.g. Internet Explorer) would see them square:</p>
<p><img src="http://preloaded.com/site_media/uploads/blog/preloaded_frontend/comparison.jpg" alt="" width="475" height="243" /></p>
<p><em>Browser comparison. Top: Safari 4; Bottom: Internet Explorer 8</em></p>
<p>While all users see the same content, those with a modern browser are rewarded with a slightly improved experience. We used other variations of this method elsewhere throughout the site.</p>
<h2>Technology</h2>
<h3>Web Fonts</h3>
<p>In order to achieve brand consistency we had a font in mind which we were going to implement using the <a href="http://cufon.shoqolate.com/">Cufón</a> Javascript technique. During the process of adding this the font foundry clarified their licensing, excluding this font from online use in this way, so we had to scrap it and look for a different angle.</p>
<p>While we were trying out various alternatives using Flash and Javascript (we now know more about font licensing and implementation than we ever wanted to), a new solution presented itself. Using <a href="http://www.fontsquirrel.com/fontface/generator">Font Squirrel’s web font generator</a> and <a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">Paul Irish’s bulletproof syntax</a> we were able to use the browsers’ own built-in font support (with <em>@font-face</em>) and achieve our desired result for 95% of our users; the other 5% will see a standard system font, as per the graceful en­hance­ment method.</p>
<h3>Glow</h3>
<p><a href="http://www.bbc.co.uk/glow/">Glow</a> is a BBC-developed Javascript library, with a jQuery-like syntax but a focus on interface widgets, which makes it easy to create animations and UI elements for websites. Having already used it briefly on a project earlier in the year, we decided it would be a good fit for what we wanted — and something new to learn.</p>
<p>The image carousel on the homepage was made with Glow, as was the slide-down contact details on each page, and the lightbox overlay effect for screenshots on the case study pages.</p>
<p>The only drawback we found with Glow was a bug in their carousel rendering in IE8; this meant that we had to force <a href="http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx">compatibility view</a> for IE8 to display as IE7, but it’s something we’re hoping to change after the next Glow release.</p>
<h3>HTML5</h3>
<p>Under the bonnet we used some cutting-edge code to mark up our content. HTML5 is a very new specification and still somewhat in a state of flux, but we used it in two different ways:</p>
<p>First was to provide semantic structure to the pages with the new structural elements (the definitions of which are still being discussed, so may not be completely correct — <a href="http://html5doctor.com/">HTML5 Doctor</a> was an invaluable resource for this).</p>
<p>Second, and of more impact to the user, was using <em>sessionStorage</em> to take advantage of the opportunities for storing data in the user’s browser. We used this in conjunction with Glow to create the carousel and slide-down effects; if you have a modern browser these are created only once and held in the browser’s storage, whereas older browsers create them anew each time you visit the page — this leads to the site being somewhat snappier in modern browsers.</p>
<h2>Conclusion</h2>
<p>Working with brand new and cutting edge features meant spending time chasing down false leads and up blind alleys, but was a great way of learning and gave us invaluable experience to take into the sites we make for our clients in future.</p>
<p>There are still one or two changes which we’ll be rolling into the site in the coming months, but if you spot any problems — or just want to talk more in-depth about the methods and techniques we’ve used — don’t hesitate to leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/01/21/building-preloaded-com-the-front-end/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Building HTML5 video controls with JavaScript</title>
		<link>http://www.broken-links.com/2009/10/06/building-html5-video-controls-with-javascript/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=building-html5-video-controls-with-javascript</link>
		<comments>http://www.broken-links.com/2009/10/06/building-html5-video-controls-with-javascript/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 16:04:06 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=582</guid>
		<description><![CDATA[The HTML5 video element is now included in Firefox, Safari &#38; Chrome, and on its way in Opera. By using JavaScript to access the media elements API it’s easy to build your own custom controls for it; in this article I’m going to show how I built a (very) basic control interface. A quick disclaimer: [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#video">HTML5 video element</a> is now included in Firefox, Safari &amp; Chrome, and on its way in Opera. By using JavaScript to access the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/media-elements.html#media-elements">media elements API</a> it’s easy to build your own custom controls for it; in this article I’m going to show how I built a (very) basic control interface.</p>
<p><span id="more-582"></span></p>
<p>A quick disclaimer: my JavaScript is a little rusty, so may not use best practice throughout; if you can see a way my code could be better, don’t hesitate to let me know.</p>
<p>Anyway, <a href="http://www.broken-links.com/tests/video/">here’s the finished demo</a>.</p>
<h2>Getting started</h2>
<p>First you must include the <code>video</code> element. <del datetime="2010-04-01T16:39:46+00:00">There are a number of attributes available, but for our purposes we need define only the <code>src</code>, which is the URI of our video file</del> <strong>Update</strong>: changed the markup to use the more correct <code>source</code> elements inside <code>video</code>.</p>
<pre>&lt;video&gt;
  &lt;source src="filename.mp4"&gt;
  &lt;source src="filename.webm"&gt;
  &lt;source src="filename.ogg"&gt;
&lt;/video&gt;</pre>
<p>The video has been encoded twice, once in Theora and once in H264, to cater for different browsers; <a href="http://camendesign.com/code/video_for_everybody">Kroc Camen’s Video for Everybody</a> explains the reasons behind this (and how to make a bulletproof player). <strong>Update:</strong> added <a href="http://www.webmproject.org/">WebM</a> support.</p>
<p>Having marked up a few controls with HTML (I’ve used <code>id</code> attributes on all of them to make this demo easier), the next step is to write the JavaScript to access the API (<a href="https://developer.mozilla.org/En/NsIDOMHTMLMediaElement">which is well explained in this article at the Mozilla Developer Center</a>) for the controls.</p>
<p>The first and most important control is the play/pause button; for this I’ve written a function which checks so see if the <code>paused</code> attribute is true or false, and triggers the <code>play()</code> or <code>pause()</code> methods accordingly:</p>
<pre>play.addEventListener('click',playControl,false);
function playControl() {
    if (video.paused == false) {
        video.pause();
        this.firstChild.nodeValue = 'Play';
        pauseCount();
    } else {
        video.play();
        this.firstChild.nodeValue = 'Pause';
        startCount();
    }
}</pre>
<p>You’ll notice that it also updates the control text to indicate the action that the control will perform. There are also two function calls — <code>pauseCount()</code> and <code>startCount()</code> — which control the timer shown next to the play button.</p>
<p>The timer uses the <code>currentTime</code> and <code>duration</code> attributes (although the latter doesn’t seem to be currently supported by Chrome). To get the current time I’ve used <code>setInterval</code> to create a loop:</p>
<pre>function startCount() {
    t = window.setInterval(function() {
        if (video.ended != true) {
            timer.firstChild.nodeValue = Math.round(video.currentTime + 1);
        } else {
            play.firstChild.nodeValue = 'Play';
            window.clearInterval(t);
        }
    },1000);
}</pre>
<p>First it uses an <code>if…else</code> statement on the <code>ended</code> attribute to check that the video has not finished playing; if it hasn’t, it updates the timer with <code>currentTime</code> (plus a little maths). If the video HAS finished, it uses <code>clearInterval</code> to stop the loop; this is also used in a function to pause the timer if the pause control is used:</p>
<pre>function pauseCount() {
    window.clearInterval(t);
}</pre>
<p>To complete the controls we have functions to increase and decrease the volume. Both are very similar:</p>
<pre>vUp.addEventListener('click',volUp,false);
function volUp() {
    if (video.volume < 1) {
        video.volume = Math.round((video.volume + 0.1)*10)/10;
        volume.firstChild.nodeValue = Math.round(video.volume*10);
    }
}</pre>
<p>First they check that the minimum/maximum limits have not been reached, and increase/decrease the <code>volume</code> attribute if not. Volume is on a scale of 0 to 1, and this function changes that value in increments of 0.1. The on-screen volume counter is also changed accordingly.</p>
<p>There are a number of small details elsewhere in the script, so feel free to have a dig through to see what else I’ve done; <a href="http://www.broken-links.com/tests/video/">here’s another link to the finished demo</a>.</p>
<h2>Further steps</h2>
<p>I’ve obviously used a little CSS to tidy the controls up, but a lot more could be done; using images instead of text, for example, or perhaps using something like <a href="http://jqueryui.com/">jQuery’s user interface library</a> to make more dynamic controls.</p>
<p>This article was intended only to show how easy it is to get started; what will be exciting is to see how these techniques can be expanded upon.</p>
<p><strong>Update:</strong> If you found this article useful, you may be interested to know that I returned to this subject in a later post, <a href="http://www.broken-links.com/2010/04/14/building-a-better-html5-video-player-with-glow/">Building a better HTML5 video player with Glow</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/10/06/building-html5-video-controls-with-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HTML5 Round-up</title>
		<link>http://www.broken-links.com/2009/09/28/html5-round-up/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=html5-round-up</link>
		<comments>http://www.broken-links.com/2009/09/28/html5-round-up/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 22:45:53 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=567</guid>
		<description><![CDATA[There’s been a noticeable increase in chatter about HTML5 recently, as the spec is moving towards Last Call status in October. The working group now has three co-chairs (from Apple, Microsoft, and IBM) and, despite some debate over semantics, the Working Draft of the spec was recently updated.]]></description>
			<content:encoded><![CDATA[<p>There’s been a noticeable increase in chatter about HTML5 recently, as the spec is moving towards Last Call status in October. <a href="http://www.theregister.co.uk/2009/08/31/three_html_5_leads/">The working group now has three co-chairs</a> (from Apple, Microsoft, and IBM) and, despite some <a href="http://visitmix.com/Opinions/The-HTML5-Semantics-Debate">debate over semantics</a>, the <a href="http://www.w3.org/TR/2009/WD-html5-20090825/">Working Draft of the spec was recently updated</a>.</p>
<p><span id="more-567"></span></p>
<p>Earlier this month a group of high-profile developers—including <a href="http://simplebits.com/notebook/2009/08/31/html5.html">Dan Cederholm</a> and <a href="http://www.zeldman.com/2009/08/31/loving-html5/">Jeffrey Zeldman</a>—got together to discuss the spec and declare their support (albeit with some caveats) for the direction it’s moving in. Although I’m not comfortable with the self-aggrandising name they chose—the <a href="http://www.zeldman.com/superfriends/">HTML5 Super Friends</a>—their support is a positive move and their concerns have already made an impact in the <a href="http://html5doctor.com/september-html5-spec-changes/">September updates</a> to the language.</p>
<p>It must be noted, however, that the ‘Super Friends’ concentrated on the markup language, while another aspect (the drag and drop module) has been <a href="http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html">roundly savaged in a strongly-worded attack by QuirksBlog’s Peter-Paul Koch</a>.</p>
<p>Many browsers now have HTML5 implemented to varying degrees (Opera 10 is first with <a href="http://people.opera.com/brucel/demo/html5-forms-demo.html">HTML5 Forms</a>, for example), so if you haven’t already, it’s time to start learning. <a href="http://www.alistapart.com/articles/get-ready-for-html-5/">A List Apart gave a concise introduction</a>, and the document highlighting <a href="http://www.w3.org/TR/2009/WD-html5-diff-20090825/">differences from HTML4</a> is also a good starting point.</p>
<p>But if you want advice, the best thing you can do is see <a href="http://html5doctor.com/">the Doctor</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/09/28/html5-round-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Misunderstanding markup</title>
		<link>http://www.broken-links.com/2009/07/31/misunderstanding-markup/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=misunderstanding-markup</link>
		<comments>http://www.broken-links.com/2009/07/31/misunderstanding-markup/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 00:22:20 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[comics]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=490</guid>
		<description><![CDATA[Misunderstanding Markup: an explanation of the different flavours of HTML &#38; XHTML, in comic strip form, by Brad Colbow. I’m not sure if it makes Jeremy Keith’s original blog post any easier to understand, but it’s certainly more fun to look at.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.smashingmagazine.com/2009/07/29/misunderstanding-markup-xhtml-2-comic-strip/">Misunderstanding Markup: an explanation of the different flavours of HTML &amp; XHTML, in comic strip form</a>, by <a href="http://www.bradcolbow.com/">Brad Colbow</a>. I’m not sure if it makes <a href="http://adactio.com/journal/1595">Jeremy Keith’s original blog post</a> any easier to understand, but it’s certainly more fun to look at.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/07/31/misunderstanding-markup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML 5 &amp; web fonts; exciting times</title>
		<link>http://www.broken-links.com/2009/05/28/exciting-times-html-5-web-fonts/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=exciting-times-html-5-web-fonts</link>
		<comments>http://www.broken-links.com/2009/05/28/exciting-times-html-5-web-fonts/#comments</comments>
		<pubDate>Thu, 28 May 2009 23:24:57 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Typography]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[web fonts]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=422</guid>
		<description><![CDATA[With (standards-compliant) browser innovation firmly back on the agenda, there's a lot of exciting new technology to get to grips with. This week, Google have thrown their weight firmly behind HTML5, while a new start-up aims to bring web fonts to all.]]></description>
			<content:encoded><![CDATA[<p>With (standards-compliant) browser innovation firmly back on the agenda, there’s a lot of exciting new technology to get to grips with. This week, Google have thrown their weight firmly behind HTML5, while a new start-up aims to bring web fonts to all.</p>
<p><span id="more-422"></span></p>
<p>Starting with the latter, I today discovered that Jeffrey Veen’s new company, Small Batch Inc., has started touting a new licensing service for web fonts. It’s called <a href="http://blog.typekit.com/2009/05/27/introducing-typekit/">TypeKit</a> and, while details are scarce, it seems to be a server to host web fonts with some Javascript magic to not make them downloadable to end users.</p>
<p>It’s an intriguing solution to <a href="http://www.broken-links.com/2008/08/04/an-alternative-suggestion-for-web-fonts-licensing/">the problem I mentioned before</a>, even if I’m not convinced it is the right solution; without knowing the specifics, it seems to me there are two fairly obvious sticking points:</p>
<p>First, how do we develop the site using the font if the license is only for the production server? Will there be a special development license, or will we have to buy a copy of the font and then an extra licensing fee?</p>
<p>Second, what about server latency (will there be a long lag until the fonts appear?) and uptime (how irritating will it be if the server is constantly falling over?).</p>
<p>I look forward to seeing how those issues are addressed. I personally don’t see a problem in the current/forthcoming Safari/Firefox implementation — but then, I’m not a type foundry.</p>
<p>It’s Google’s I/O event this week, and <a href="http://www.webmonkey.com/blog/Google_Throws_Its_Weight_Behind_HTML_5">they’re making a big deal about supporting some of the new HTML5 syntax</a> — principally, the <code>video</code> element, an example of which is on this <a href="http://www.youtube.com/html5">YouTube mock-up</a> (Firefox 3.5, Safari 4, or Chrome 3 required).</p>
<p>So stable is the new element that video site <a href="http://blog.dailymotion.com/2009/05/27/watch-videowithout-flash/">dailymotion.com have announced that they have converted 300,000 of their videos to use it</a>, and the open video codec Ogg Theora. With all of the main non-IE browsers about to launch their implementation, adoption will hopefully be pretty rapid.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/05/28/exciting-times-html-5-web-fonts/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>HTML 5, CSS 3, DRM &amp; fonts</title>
		<link>http://www.broken-links.com/2009/05/01/html-5-css-3-drm-and-fonts/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=html-5-css-3-drm-and-fonts</link>
		<comments>http://www.broken-links.com/2009/05/01/html-5-css-3-drm-and-fonts/#comments</comments>
		<pubDate>Fri, 01 May 2009 12:20:02 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Typography]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[drm]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=420</guid>
		<description><![CDATA[I'm at home with the flu at the moment, so taking the opportunity to un-star some items in Google Reader; this post is a link-dump with a little added comment.

A few of them have been in my favourites for a couple of months, so apologies if you've seen them already.]]></description>
			<content:encoded><![CDATA[<p>I’m at home with the flu at the moment, so taking the opportunity to un-star some items in Google Reader; this post is a link-dump with a little added comment.</p>
<p>A few of them have been in my favourites for a couple of months, so apologies if you’ve seen them already.</p>
<p><span id="more-420"></span></p>
<p>First, a new <a href="http://www.w3.org/TR/2009/WD-html5-20090423/">working draft of HTML 5</a> has been released, with <a href="http://www.w3.org/TR/2009/WD-html5-diff-20090423/#changes-2009-02-12">a list of changes since the last version</a>. Mostly API calls, although a new <code>spellcheck</code> attribute has been introduced.</p>
<p>Representatives of Mozilla, Microsoft and Opera presented talks on CSS 3 at SXSWI, and <a href="http://www.molly.com/2009/03/18/css3-panel-slides-from-sxswi/">have made the slides available to view</a>. They have some good demos &amp; examples of upcoming features, and hint that the Internet Explorer team may be doing an iterative release later this year. Fingers crossed.</p>
<p>Sitepoint reports on <a href="http://www.sitepoint.com/blogs/2009/05/01/drm-cutting-off-your-prose-to-spite-your-face/">the extraordinary lengths that an Australian business site has gone to to stop having their content re-used</a>. The author plays up the search engine indexing angle, but to me that’s less of an issue; if you don’t want your site indexed, you can use robots.txt. In fact this is a way to stop people from copying and pasting your content, which is far more extraordinary. It’s also two fingers up (or just one, if you’re not British) to anyone using a screen reader.</p>
<p>Mark Pilgrim posted an angry attack on font manufacturers in his post <a href="http://diveintomark.org/archives/2009/04/21/fuck-the-foundries">Fuck the foundries</a> which, I have to say, I completely agree with. <a href="http://www.sitepoint.com/blogs/2009/04/23/web-fonts-do-something-positive/">Sitepoint suggest we be proactive</a> by buying a font (good) and letting foundries know we would pay extra to use them as web fonts (bad).</p>
<p>I believe that the problem of font piracy has been overstated; they don’t have the mainstream appeal of media like films or music, for a start. And it’s not as if they’re hard to find right now; I just performed a Google search and found a copy of Helvetica in seconds. Foundries need to leave behind the idea that every unlicensed copy is a sale lost (some people would never pay for a font) and instead focus on potential sales to conscientious users who would happily buy a font to use on the web, at the same price as a font used for print.</p>
<p>Finally, if you want to make the most out of your fonts you need to see these <a href="http://www.clagnut.com/blog/2255/">presentations on typography</a> from <a href="http://clagnut.com/">Richard Rutter</a> and <a href="http://jontangerine.com/">Jon Tan</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2009/05/01/html-5-css-3-drm-and-fonts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
