<?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, 03 Feb 2012 19:47:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://www.broken-links.com/?pushpress=hub'/>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Styling HTML5 Form Validation Errors</title>
		<link>http://www.broken-links.com/2011/06/16/styling-html5-form-validation-errors/</link>
		<comments>http://www.broken-links.com/2011/06/16/styling-html5-form-validation-errors/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 13:25:37 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=1213</guid>
		<description><![CDATA[Back in March I wrote about HTML5 Form validation and the problem with the appearance of error messages. I proposed a syntax for styling the error messages, and shortly after I published the post, I submitted the proposal to the W3C via the www-style mailing list. I’ll discuss quickly the result of that submission, but [...]]]></description>
			<content:encoded><![CDATA[<p>Back in March I wrote about <a href="http://www.broken-links.com/2011/03/28/html5-form-validation/">HTML5 Form validation</a> and the problem with the appearance of error messages. I proposed a syntax for styling the error messages, and shortly after I published the post, I submitted the proposal to the <a href="http://w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a> via the <a href="http://lists.w3.org/Archives/Public/www-style/">www-style mailing list</a>.</p>
<p>I’ll discuss quickly the result of that submission, but first I should mention that I’ve since found out that the Google Chrome developers have already implemented their own syntax, and it’s not too far removed from what I proposed. Before I get to that, however, allow me to gripe.</p>
<p><span id="more-1213"></span></p>
<p>What the feedback on my proposal would be, I have no idea — and may never know. As I mentioned, I submitted it via the www-style list, but my emails were never published. I was told that as a new user my mail would be held for approval, but that was six weeks ago. I emailed the list administrator and tried to submit it again, but never got a reply.</p>
<p>I have to say that, as a developer trying to get involved in the standards process — which is what the <abbr>W3C</abbr> claim they want — this was not a good experience for me. I had a serious proposal which I wanted to open up for discussion, but was completely unable to do so and met with a wall of silence. I’m not against there being a moderation and approval process, but only if there’s an eventual result and some kind of communication throughout.</p>
<p>OK, with the moan out of the way, I’ll talk about the Chrome validation error styling syntax. The error message, known as the ‘bubble’, is made of four <code>div</code> elements which are accessible via four pseudo-classes, each of which applies to a different <code>div</code> in the bubble:</p>
<pre>::-webkit-validation-bubble {}
::-webkit-validation-bubble-arrow-clipper {}
::-webkit-validation-bubble-arrow {}
::-webkit-validation-bubble-message {}</pre>
<p>The parent element is <code>::-webkit-validation-bubble</code>, which sets the size and position of the bubble, and has two child elements. The first child is <code>::-webkit-validation-bubble-arrow-clipper</code>, which has its own child, <code>::-webkit-validation-bubble-arrow</code>; these two set the styles of the tail of the bubble. The body of the bubble is the second child, <code>::-webkit-validation-bubble-message</code>, which contains the text node with the error itself.</p>
<p>I’ve made a quick example which you can see in action on the <a href="http://www.broken-links.com/tests/html5forms/">HTML5 Forms demo</a> — you’ll need to use Chrome to see it, and you can view the source to see the styles I’ve used. Below is an image comparison of the default message (top) and my styled version. Note: I took a little criticism for calling the default styles ‘ugly’ in my original post, and I don’t want to claim that mine is any better, because it’s really not; it’s just different, to act as an example.</p>
<p><img width="349" height="246" alt="Default (top) and styled validation error message" src="/wp-content/uploads/2011/06/error-bubble-2.png"></p>
<p>You can <a href="http://trac.webkit.org/wiki/Styling%20Form%20Controls#WebKitr82180orlater">read a little more about this syntax on the WebKit wiki</a>, and also see <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css?rev=82180#L588">the default styles</a> the error message uses. I’ve no idea if Firefox or Opera implement their error messages in the same way so don’t know if this is likely to become standard, or will always remain a WebKit-only syntax. I have to say it’s not really an elegant solution, but it works.</p>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=1213&amp;md5=d4d1a1dec76bde2977b63f8c3e59eba7" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2011/06/16/styling-html5-form-validation-errors/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=1213&amp;md5=d4d1a1dec76bde2977b63f8c3e59eba7" type="text/html" />
	</item>
		<item>
		<title>HTML5 Form Validation</title>
		<link>http://www.broken-links.com/2011/03/28/html5-form-validation/</link>
		<comments>http://www.broken-links.com/2011/03/28/html5-form-validation/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 13:21:46 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[constraint validation api]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=1127</guid>
		<description><![CDATA[A lot of the attention paid to HTML5 Forms has been centred around the new input types. email, url, date, and the rest are all very convenient, but for me the really useful feature is the built-in validation. In case you’re not aware of it, the browser will now handle all of the validation that [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of the attention paid to HTML5 Forms has been centred around the new input types. <code>email</code>, <code>url</code>, <code>date</code>, and the rest are all very convenient, but for me the really useful feature is the built-in validation. In case you’re not aware of it, the browser will now handle all of the validation that we used to use JavaScript for.</p>
<p>This is great for the future, but although you can start using these functions now (in many browsers), they aren’t without their drawbacks — well, one big drawback really. I’m going to explain briefly the problem, and then propose a solution.</p>
<p><span id="more-1127"></span></p>
<h2>How Form Validation Works</h2>
<p>The simplest form of validation is to say that a field is required, which is done by adding the <code>required</code> attribute (it’s boolean, so needs no explicit value):</p>
<pre>&lt;input type="text" <mark>required</mark>&gt;</pre>
<p>This will check to see if a value is supplied, and returns an error if it isn’t. You can add parameters to validation by using the <code>pattern</code> attribute with a JavaScript regex value; for example, to only accept a numeric value you would use the following:</p>
<pre>&lt;input type="text" <mark>pattern="[-0-9]+"</mark> required&gt;</pre>
<p>Some field types have pattern validation baked in; <code>email</code> and <code>url</code> will only accept correctly formatted email addresses and URLs, respectively, while <code>number</code> and <code>range</code> can have maximum and minimum numeric values applied. There’s also a <code>maxlength</code> attribute to restrict the number of characters, which can also cause a validation error.</p>
<h2>The Problem With Error Messages</h2>
<p>Probably the biggest drawback of the validation process is that the error messages are, for the most part — and there’s no polite way to put this — ugly. Take a look at this image showing the validation error message in (from the top) Chrome, Opera, and Firefox:</p>
<p><img src="/wp-content/uploads/2011/03/errormessages.png" alt="Validation error messages in different browsers" width="317" height="270"></p>
<p>I think the Opera message is the better of the three, but I think it’s fair to say that the designers weren’t having their best days when they made these. (I’m using Ubuntu here, but they really aren’t any better in any other <abbr>OS</abbr>.) The problem I have with these is that I’d like to use them, but I don’t think any designer I work with would find these acceptable and I’d no doubt end up using a <abbr>JS</abbr> implementation just to get some form of consistency.</p>
<p>Using <abbr>JS</abbr> is a short term solution, and there’s a good <a href="https://developer.mozilla.org/en/HTML/HTML5/Forms_in_HTML5#Constraint_Validation_API">Validation <abbr>API</abbr></a> to aid in using it (which I aim to write about soon). But longer term we will need better-designed messages, or a way to style them ourselves, or both. I don’t think that the error messages need to look identical in every browser on every OS, but I do think they should be more closely aligned with the browser chrome and sympathetic to the OS; they should feel like a natural part of the platform, rather than an add-on.</p>
<h2>A Proposal For Styling Error Messages</h2>
<p>There’s no formalised suggestion for CSS styling of error messages, but I think it’s probably inevitable that there will be. This could take the form of a pseudo-element, perhaps something like:</p>
<pre>input<mark>::error</mark> {}</pre>
<p>This would allow us to set background, colour and font options. It may be necessary to also have a property to set where the validation error message appears in relation to the input it’s attached to; perhaps modifying <code>position</code> with values of <em>above</em>, <em>below</em>, <em>before</em>, or <em>after</em>:</p>
<pre>input::error { <mark>position: below</mark>; }</pre>
<p> And, perhaps, another property to set the appearance of the box which contains the message; perhaps the <code>appearance</code> property with values of <em>box</em> for a rectangle, or <em>balloon</em> for the current speech balloon style:</p>
<pre>input::error { <mark>appearance: balloon</mark>; }</pre>
<p>There’s also the text inside the validation error; the main message, and an optional extra which can be set with the <code>title</code> attribute (or JavaScript). These could have further pseudo-elements for finer control over the text formatting:</p>
<pre>input<mark>::error-message</mark> { }
input<mark>::error-text</mark> { }</pre>
<p>This is all straight off the top of my head, of course, and no doubt needs plenty of development; but as there’s no formal proposal at the moment, it’s a good time to be thinking about these things.</p>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=1127&amp;md5=c6c601da1f07e0e07763a86b3876f7c7" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2011/03/28/html5-form-validation/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=1127&amp;md5=c6c601da1f07e0e07763a86b3876f7c7" type="text/html" />
	</item>
		<item>
		<title>HTML5 for Web Developers</title>
		<link>http://www.broken-links.com/2011/02/23/html5-for-web-developers/</link>
		<comments>http://www.broken-links.com/2011/02/23/html5-for-web-developers/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 20:01:15 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[whatwg]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=1133</guid>
		<description><![CDATA[The WHATWG have released the HTML5 Edition for Web Developers, which removes all of the overly-technical details aimed at browser makers and leaves the important stuff you need to learn — and with a nice readable stylesheet applied.]]></description>
			<content:encoded><![CDATA[<p>The <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr> have released the <a href="http://developers.whatwg.org/">HTML5 Edition for Web Developers</a>, which removes all of the overly-technical details aimed at browser makers and leaves the important stuff you need to learn — and with a nice readable stylesheet applied.</p>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=1133&amp;md5=05a92828a4128d9c92e1b75f4b252958" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2011/02/23/html5-for-web-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=1133&amp;md5=05a92828a4128d9c92e1b75f4b252958" type="text/html" />
	</item>
		<item>
		<title>Data Attributes in HTML and jQuery</title>
		<link>http://www.broken-links.com/2010/11/18/data-attributes-in-html-and-jquery/</link>
		<comments>http://www.broken-links.com/2010/11/18/data-attributes-in-html-and-jquery/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 14:11:58 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[microformats]]></category>
		<category><![CDATA[rdfa]]></category>
		<category><![CDATA[semantics]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=1068</guid>
		<description><![CDATA[Sometimes the existing HTML attributes aren't sufficient for describing an element's content. We can use class, ref, rel, title and more, but even so there are occasions where we need more. <abbr>HTML5</abbr> addresses this problem with the introduction of Data Attributes, which allow you to add simple metadata to individual elements, largely for the purpose of providing information to make JavaScript functions easier.]]></description>
			<content:encoded><![CDATA[<p>Sometimes the existing HTML attributes aren’t sufficient for describing an element’s content. We can use <code>class</code>, <code>ref</code>, <code>rel</code>, <code>title</code> and more, but even so there are occasions where that’s not enough. <abbr>HTML5</abbr> addresses this problem with the introduction of Data Attributes, which allow you to add simple metadata to individual elements, largely for the purpose of providing information to make JavaScript functions easier.</p>
<p><span id="more-1068"></span></p>
<p>The syntax is a key:value pair, with the key being a keyword prefixed with <code>data–</code>, like so:</p>
<pre>&lt;div data-foo="bar"&gt;&lt;/div&gt;</pre>
<p>Note that this is not intended to compete with or replace <a href="http://microformats.org/">Microformats</a> or <a href="http://www.w3.org/TR/xhtml-rdfa-primer/"><abbr title="Resource Description Framework in attributes">RDFa</abbr></a>; data attributes were developed only to <q><a href="http://dev.w3.org/html5/spec/elements.html#custom-data-attribute">store custom data [about an element] when there is no more appropriate attribute or element available</a></q>.</p>
<p><a href="http://blog.jquery.com/2010/10/16/jquery-143-released/">jQuery introduced support for data attributes in version 1.4.3</a>, which was released in October 2010. You use the existing <code>data()</code> method to get and set values. Getting a value involves just using the keyword, as in this example which operates on the markup above:</p>
<pre>var baz = $('div').data('foo');</pre>
<p>This would set the value of ‘bar’ to the <code>baz</code> variable. jQuery’s implemenation is so clever that the variable will take on the correct value type — string, number, boolean — automatically. In the example above it would be a string, but given markup like this:</p>
<pre>&lt;div data-retail="3.99"&gt;&lt;/div&gt;</pre>
<p>The value of the variable would be provided as a number type. You can also use <a href="http://www.json.org/js.html"><abbr title="JavaScript Object Notation">JSON</abbr></a> syntax in data attributes, like so:</p>
<pre>&lt;div data-foobar='{"foo":"bar"}'&gt;&lt;/div&gt;</pre>
<p>Note that the attribute uses single quotes while the key:value pair inside are in double quotes; this is required to be valid <abbr>JSON</abbr> syntax. To access this with jQuery, just add the key name as an object at the end of the string:</p>
<pre>var baz = $('div').data('foobar').foo;</pre>
<p>This will once again instruct the variable <code>baz</code> to have the value ‘bar’.</p>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=1068&amp;md5=7b1629c867aec301a7fe0fd97e7f038b" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/11/18/data-attributes-in-html-and-jquery/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=1068&amp;md5=7b1629c867aec301a7fe0fd97e7f038b" type="text/html" />
	</item>
		<item>
		<title>HTML5 block-level link bug in IE7+</title>
		<link>http://www.broken-links.com/2010/09/14/html5-block-level-link-bug-in-ie7/</link>
		<comments>http://www.broken-links.com/2010/09/14/html5-block-level-link-bug-in-ie7/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 10:26:47 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=925</guid>
		<description><![CDATA[HTML5 allows the use of block elements inside the a tag, which was not permitted in HTML4. This means that you can wrap a link around whole sections of markup, making all of the child elements of the a become the link. You use it like so: &#60;a href="http://example.com"&#62; &#60;div&#62; &#60;h3&#62;I'm an example&#60;/h3&#62; &#60;/div&#62; &#60;/a&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 allows the use of block elements inside the <code>a</code> tag, which was not permitted in HTML4. This means that you can wrap a link around whole sections of markup, making all of the child elements of the <code>a</code> become the link. You use it like so:</p>
<pre>&lt;a href="http://example.com"&gt;
  &lt;div&gt;
    &lt;h3&gt;I'm an example&lt;/h3&gt;
  &lt;/div&gt;
&lt;/a&gt;</pre>
<p>You can begin to use this straight away, as every browser supports it — although you must be wary of one rather glaring bug in Internet Explorer.</p>
<p><span id="more-925"></span></p>
<p>The bug occurs if you try to nest other <code>a</code> elements inside the block-level one, as shown in this example markup:</p>
<pre>&lt;a href="http://example.com"&gt;
  &lt;div&gt;
    &lt;h3&gt;<mark>&lt;a href="http://example.com"&gt;</mark>I'm an example<mark>&lt;/a&gt;</mark>&lt;/h3&gt;
  &lt;/div&gt;
&lt;/a&gt;</pre>
<p>With this markup <abbr>IE7</abbr> fails to render some elements, and <abbr>IE8</abbr> and <abbr>IE9</abbr> create an empty, ‘phantom’ element. I’ll show you what I mean, starting with the way this markup <em>should</em> render; on the left is the <abbr>HTML</abbr> markup as it displays in your browser, and on the right I’ve placed a screenshot from Firefox to act as a comparison.</p>
<div class="post-925">
<a href="http://example.com"></p>
<div>
<h3><a href="http://example.com">I’m an example</a></h3>
</p></div>
<p></a>
</div>
<p><img src="/wp-content/uploads/2010/09/block-link-bug-correct.png" alt="" title="block-link-bug-correct" width="250" height="128" class="aligncenter size-full wp-image-977"></p>
<p>And now see how they appear in <abbr>IE7</abbr> (left) and <abbr>IE8</abbr> &amp; <abbr>IE9</abbr> (right):</p>
<p><img src="/wp-content/uploads/2010/09/block-link-bug-ie7.png" alt="" title="block-link-bug-ie7" width="250" height="90" style="float: left;"><img src="/wp-content/uploads/2010/09/ie-block-link-bug1.png" alt="" title="IE Block Link Bug" width="267" height="188"></p>
<p>As you can see, in <abbr>IE7</abbr> the <code>h3</code> element loses its background color and margin, and in <abbr>IE8</abbr> &amp; <abbr>IE9</abbr> there’s an empty box above my markup; this is the ‘phantom’ element, which is inheriting the border from the <code>div</code> element, and the <code>margin-bottom</code> from the <code>h3</code>. Were I to add <code>margin-top</code> (or further properties that affect the box model) to my markup, they would also show up here.</p>
<p>Strangely, this bug doesn’t seem to occur in IE6.</p>
<p>The fix is quite simple: don’t nest <code>a</code> elements. I only did it as I needed an element to create a particular style effect, but it can be done just as easily with a <code>span</code>. I tried a number of other approaches but this seemed to be the only one that worked.</p>
<p><strong>Update:</strong> As has been pointed out in the comments, nesting <code>a</code> elements is in fact prohibited by the HTML5 specification. I’ll leave this post here for the other people like me who weren’t aware of that.</p>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=925&amp;md5=549c5089958a8ec80ead74d4acfd64b9" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/09/14/html5-block-level-link-bug-in-ie7/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=925&amp;md5=549c5089958a8ec80ead74d4acfd64b9" type="text/html" />
	</item>
		<item>
		<title>Playing WebM in Safari with plugins</title>
		<link>http://www.broken-links.com/2010/09/01/playing-webm-in-safari-with-plugins/</link>
		<comments>http://www.broken-links.com/2010/09/01/playing-webm-in-safari-with-plugins/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 13:33:10 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[h264]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[webm]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=919</guid>
		<description><![CDATA[As you're no doubt aware, HTML5 video is this year's big thing - but there's a dispute going on about which should become the default standard video codec. The current nascent <span lang="la">de facto</span> standard is <abbr>H.264</abbr>, but recently the new <a href="http://www.webmproject.org/">WebM</a> format is gaining traction. But this post isn't really about that; it's about clearing up a misconception.]]></description>
			<content:encoded><![CDATA[<p>As you’re no doubt aware, <abbr>HTML5</abbr> video is this year’s big thing — but there’s a dispute going on about which should become the default standard video codec. The current nascent <span lang="la">de facto</span> standard is <abbr>H.264</abbr>, but recently the new <a href="http://www.webmproject.org/">WebM</a> format is gaining traction.</p>
<p>I’ve no idea how the web video format war will end. My preference is that a free, non-patent encumbered, high-quality video codec will become the standard, and WebM is the best fit for that description. Despite the recent announcement by the <abbr>MPEG LA</abbr>, the patent pool which controls licensing of H.264, that it will <a href="http://www.pcmag.com/article2/0,2817,2368359,00.asp">always be free for ‘video delivered to the internet without charge’</a>, that still doesn’t make it free-as-in-speech, and still not free-as-in-beer for anyone wanting to build a business around video encoding/decoding (which includes, if I’m not mistaken, bundling it with a browser). All that said, my preference is meaningless in the face of so many vested business interests.</p>
<p><span id="more-919"></span></p>
<p>But this post isn’t really about that; it’s about clearing up a misconception. One common statement I keep seeing repeated (<a href="http://www.webmonkey.com/2010/05/on-web-video-support-safari-now-stands-alone/">WebMonkey said this in May</a>, but I’ve seen it even more recently) is that Safari will be the only browser to not support WebM, when even the Internet Explorer team have promised to. That’s not the case. What the IE team said was that <a href="http://windowsteamblog.com/windows/b/bloggingwindows/archive/2010/05/19/another-follow-up-on-html5-video-in-ie9.aspx">they will support WebM (or rather, the <abbr>VP8</abbr> codec) as long as the user has installed the codec on Windows</a>. Safari’s position is identical, they just haven’t publicly stated so.</p>
<p>The current free alternative to <abbr>H.264</abbr>, <abbr>OGG</abbr> video, is also not supported in Safari — but you can play <abbr>OGG</abbr> videos in Safari by downloading and installing the <a href="http://www.xiph.org/quicktime/">Xiph Quicktime Components</a>. Likewise, Windows Media files are supported through <a href="http://www.microsoft.com/mac/products/flip4mac.mspx">Flip4Mac</a>. WebM can be supported in Safari in the same way, as soon as someone creates a QuickTime plugin (I believe experimental support is in <a href="http://perian.org/">Perian</a> already). This is <strong>exactly</strong> the same situation as with <abbr>IE</abbr>.</p>
<p>Where this doesn’t apply is on mobile devices; many — principal amongst them, the <abbr>iOS</abbr> range — don’t allow extra codecs to be installed. However, this is slightly supplemental to my point, which is that both <abbr>IE</abbr> and Safari — on desktop — are capable of playing WebM via a plugin. I believe that if people will install the Flash plugin, they will install the WebM plugin — and when we have choice and competition, a true standard can be reached by consensus, rather than financial clout.</p>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=919&amp;md5=87063ea1ab31800d9134c30594d622e8" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/09/01/playing-webm-in-safari-with-plugins/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=919&amp;md5=87063ea1ab31800d9134c30594d622e8" type="text/html" />
	</item>
		<item>
		<title>Encoding Video for Android</title>
		<link>http://www.broken-links.com/2010/07/30/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[html]]></category>
		<category><![CDATA[Technology]]></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).</p>
<p><span id="more-900"></span></p>
<p>A couple of things to note: this post refers specifically to video embedded in web pages with the <code>video</code> element, so the other two requirements from my previous blog post still stand; also, the methods shown below should mean your videos play on iOS too, so you don’t have to encode for different platforms.</p>
<p>The first is cross-platform, using <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" poster="/tests/images/BBB_480_Poster.jpg" src="/tests/media/BBB_480_HB.mp4" width="480"></video></p>
<p>The second method is also cross-platform, and uses <a href="http://videolan.org/"><abbr>VLC</abbr></a> (I’m using version 1.1.1, not sure if older versions work the same). It involves more set-up the first time around, but will be easier with each subsequent conversion. <strong>Update:</strong> I was using VLC for Linux, but the OSX version seems to be quite different.</p>
<p>Go to <strong>Media &gt; Convert/Save</strong>, add the file to be converted, and choose <strong>Convert</strong> from the selection at the bottom. Name your <strong>Destination File</strong> <em>[filename].mp4</em>, and from the <strong>Profile</strong> list choose <em>Video — H.264 + AAC (TS)</em>.</p>
<p>Hit the <strong>Edit</strong> icon next to the list, and go through each tab in turn; in <strong>Encapsulation</strong> choose <em>MP4/MOV</em>; in <strong>Video Codec</strong> un-check the <em>Keep original video track box</em>, choose<em> H-264</em> from the <em>Codec</em> list, empty the <em>Scale</em> field and enter a value in <em>Width</em> (I used 480); in <strong>Audio</strong> un-check the <em>Keep original audio track</em> box and select <em>MPEG4 Audio (AAC)</em> from the <em>Codec</em> list. Now click <strong>Save</strong>, and all of these settings will be remembered so you don’t have to enter them again.</p>
<p>With all that done, hit <strong>Start</strong> to encode your video. You can see the result of the <abbr>VLC</abbr> encoding below. <strong>Update:</strong> This video doesn’t seem to play on iOS.</p>
<p><video controls height="270" poster="/tests/images/BBB_480_Poster.jpg" src="/tests/media/BBB_480_VLC.mp4" width="480"></video></p>
<p>The third method is the simplest, but works on Mac <abbr>OSX</abbr> 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" poster="/tests/images/BBB_480_Poster.jpg" 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’ve read that you can use <a href="http://winff.org/">WinFF</a>, although I haven’t been able to make this work so far.</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>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=900&amp;md5=204c5101ce3aa44c095475fe71af0d4c" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/07/30/encoding-video-for-android/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=900&amp;md5=204c5101ce3aa44c095475fe71af0d4c" type="text/html" />
	</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/</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[html]]></category>
		<category><![CDATA[Technology]]></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; see my follow-up post, <a href="http://www.broken-links.com/2010/07/30/encoding-video-for-android/">Encoding Video for Android</a>, for more about 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(){
  video.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>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=890&amp;md5=c92a6501dc63076d2195ae4941bb205e" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></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>44</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=890&amp;md5=c92a6501dc63076d2195ae4941bb205e" type="text/html" />
	</item>
		<item>
		<title>My Name In Print</title>
		<link>http://www.broken-links.com/2010/05/26/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[html]]></category>
		<category><![CDATA[Miscellanea]]></category>
		<category><![CDATA[Scripting]]></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>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=814&amp;md5=09c44add3a197c7626bbcbc2ca965f40" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></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>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=814&amp;md5=09c44add3a197c7626bbcbc2ca965f40" type="text/html" />
	</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/</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[html]]></category>
		<category><![CDATA[Scripting]]></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>
 <p><a href="http://www.broken-links.com/?flattrss_redirect&amp;id=767&amp;md5=4ed76e9e964e3d93b7fd6fe2084766ec" title="Flattr" target="_blank"><img src="http://www.broken-links.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></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>9</slash:comments>
		<atom:link rel="payment" href="http://www.broken-links.com/?flattrss_redirect&amp;id=767&amp;md5=4ed76e9e964e3d93b7fd6fe2084766ec" type="text/html" />
	</item>
	</channel>
</rss>

