 <?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</title>
	<atom:link href="http://www.broken-links.com/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>Web Directions @media 2010</title>
		<link>http://www.broken-links.com/2010/06/21/web-directions-media-2010/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=web-directions-media-2010</link>
		<comments>http://www.broken-links.com/2010/06/21/web-directions-media-2010/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 13:50:11 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[@media]]></category>
		<category><![CDATA[atmedia]]></category>
		<category><![CDATA[conference]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=883</guid>
		<description><![CDATA[Usually when I attend @media (that is, on two previous occasions) I write a follow-up blog post on what I saw there. Well I attended this year, and I’ve written the post, but it’s on the blog of my employer, Preloaded: HTML5, Mobile, and UCD: what we saw at @media.]]></description>
			<content:encoded><![CDATA[<p>Usually when I attend <a href="http://atmedia.webdirections.org/">@media</a> (that is, on two previous occasions) I write a follow-up blog post on what I saw there. Well I attended this year, and I’ve written the post, but it’s on the blog of my employer, Preloaded: <a href="http://preloaded.com/blog/2010/06/14/what-we-saw-atmedia/">HTML5, Mobile, and UCD: what we saw at @media</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/06/21/web-directions-media-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SVG in backgrounds with PNG fallback</title>
		<link>http://www.broken-links.com/2010/06/14/using-svg-in-backgrounds-with-png-fallback/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-svg-in-backgrounds-with-png-fallback</link>
		<comments>http://www.broken-links.com/2010/06/14/using-svg-in-backgrounds-with-png-fallback/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 13:04:38 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Miscellanea]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[svg]]></category>
		<category><![CDATA[technique]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=861</guid>
		<description><![CDATA[My last post was about using SVG values for the background-image property, and I pointed out one big problem with the technique: The drawback of this is that it’s not ready for use just yet—browsers that don’t support SVG in background-image will not provide any fallback, even if you supply another background-image value; so in [...]]]></description>
			<content:encoded><![CDATA[<p>My last post was about <a href="http://www.broken-links.com/2010/06/08/using-svg-in-background-image/">using <abbr title="Scalable Vector Graphics">SVG</abbr> values for the <code>background-image</code> property</a>, and I pointed out one big problem with the technique:</p>
<blockquote><p>
The drawback of this is that it’s not ready for use just yet—browsers that don’t support <abbr>SVG</abbr> in <code>background-image</code> will not provide any fallback, even if you supply another <code>background-image</code> value; so in non-supporting browsers, no image at all will be displayed.
</p></blockquote>
<p>This was annoying me a little, and I couldn’t find any workarounds that didn’t use JavaScript. However, after a bit of head-scratching I’ve come up with a way to get around it.</p>
<p><span id="more-861"></span></p>
<p>In order to have browsers which don’t support <abbr>SVG</abbr> display a <abbr>PNG</abbr> image instead, you should use this code:</p>
<pre>E {
background-image:  url('image.png');
background-image:  none,url('image.svg'), url('image.png');
background-size: 100% 100%;
}</pre>
<p>Browsers which support <abbr>SVG</abbr> and multiple backgrounds will show the <abbr>SVG</abbr>; browsers which don’t support <abbr>SVG</abbr> will fall back to the <abbr>PNG</abbr> in the <code>background-image</code> stack. As far as I know, all browsers which support <abbr>SVG</abbr> also support multiple backgrounds; any which don’t (i.e. <abbr>IE</abbr>) will fall back to the <abbr>PNG</abbr> in the first <code>background-image</code> declaration.</p>
<p><strong>Update:</strong> Thanks to a comment I have amended this technique. <abbr>IE</abbr> was not falling back to the first <code>background-image</code> as it should have done, but I got around this by adding a <em>none</em> value in the declaration. This invalidates the rule in <abbr>IE</abbr> and forces the fallback to the previous declaration.</p>
<p>You can see a demonstration of it here: <a href="http://www.broken-links.com/tests/svg/svg_hack.html">Background SVG with PNG fallback — demo</a>.</p>
<p>This technique is not without its own caveats, however. First and foremost, the <abbr>SVG</abbr> must not have a transparent background, or else the <abbr>PNG</abbr> in the background layer below it will probably show through. Also, depending on how fast the <abbr>SVG</abbr> file loads, the <abbr>PNG</abbr> file may show up first and then be covered over.</p>
<p>Finally, if you’re using the same background image at different sizes and either your browser doesn’t support <code>background-size</code> or you don’t want automatically resized <abbr>PNG</abbr>s, you’ll have to use the rule for each instance:</p>
<pre>E {
background-image:  url('image-small.png');
background-image:  none,url('image.svg'), url('image-small.png');
background-size: 100% 100%;
}

F {
background-image:  url('image-large.png');
background-image:  none,url('image.svg'), url('image-large.png');
background-size: 100% 100%;
}</pre>
<p>And of course, if you’re creating multiple <abbr>PNG</abbr> images anyway, you may feel there’s not a lot of point in using <abbr>SVG</abbr> images as well. I’ll be the first to admit that this isn’t a completely bulletproof technique, but I offer it in the hope that in certain circumstances it could be useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/06/14/using-svg-in-backgrounds-with-png-fallback/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using SVG in background-image</title>
		<link>http://www.broken-links.com/2010/06/08/using-svg-in-background-image/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-svg-in-background-image</link>
		<comments>http://www.broken-links.com/2010/06/08/using-svg-in-background-image/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 22:14:51 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[firefox 4]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[svg]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=843</guid>
		<description><![CDATA[While having a look through the list of features for developers planned for Firefox 4 earlier today, I noticed this: You can now use SVG with the img element, as well as the background image in CSS. I know you can already use SVG in background-image with Safari, Chrome and Opera, and this, coupled with [...]]]></description>
			<content:encoded><![CDATA[<p>While having a look through the list of <a href="https://developer.mozilla.org/en/Firefox_4_for_developers">features for developers planned for Firefox 4</a> earlier today, I noticed this:</p>
<blockquote><p>
You can now use <abbr title="Scalable Vector Graphics">SVG</abbr> with the <code>img</code> element, as well as the background image in <abbr>CSS</abbr>.
</p></blockquote>
<p>I know you can already use <abbr>SVG</abbr> in <code>background-image</code>  with Safari, Chrome and Opera, and this, coupled with Internet Explorer’s push towards <abbr>SVG</abbr> and the strong chance this will be available in IE9, made me decide to take a closer look.</p>
<p><span id="more-843"></span></p>
<p>I’ve put together a little demo page which you can view with Safari, Chrome or Opera — ironically, this doesn’t seem to be implemented in Firefox nightlies at the time of writing:</p>
<p><a href="http://www.broken-links.com/tests/svg/"><abbr>SVG</abbr> in background-image demo</a></p>
<p>The same image is used many times at different sizes on this page, displaying the grand advantage of <abbr>SVG</abbr> over <abbr>PNG</abbr>: it can be resized without the same loss of quality that bitmap images suffer.</p>
<p>Implementation is very easy:</p>
<pre>E { background-image: url('image.svg'); }</pre>
<p>If you’re looking at the demo in a WebKit browser, you’ll notice an empty box labelled ‘<abbr>SVGZ</abbr>’ — the <code>background-image</code> on this element is in the compressed <abbr>SVG</abbr> format, <abbr>SVGZ</abbr>, which only Opera supports:</p>
<pre>E { background-image: url('image.svgz'); }</pre>
<p>The file size is less than one-third of the non-compressed version.</p>
<p>The drawback of this is that it’s not ready for use just yet — browsers that don’t support <abbr>SVG</abbr> in <code>background-image</code> will not provide any fallback, even if you supply another <code>background-image</code> value; so in non-supporting browsers, no image at all will be displayed.</p>
<p><strong>Update:</strong> I’ve found a technique for <a href="http://www.broken-links.com/2010/06/14/using-svg-in-backgrounds-with-png-fallback/">using <abbr>SVG</abbr> images with <abbr>PNG</abbr> fallback</a>.</p>
<p><em>The image used in this demo is from <a href="http://www.allfreevectors.com/free-tree-with-heart-13840.html">All Free Vectors</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/06/08/using-svg-in-background-image/feed/</wfw:commentRss>
		<slash:comments>3</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>New to Firefox: –moz-calc and :-moz-any</title>
		<link>http://www.broken-links.com/2010/05/17/new-to-firefox-moz-calc-and-moz-any/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=new-to-firefox-moz-calc-and-moz-any</link>
		<comments>http://www.broken-links.com/2010/05/17/new-to-firefox-moz-calc-and-moz-any/#comments</comments>
		<pubDate>Mon, 17 May 2010 13:00:37 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[calculations]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[experimental]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[selectors]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=795</guid>
		<description><![CDATA[The latest nightly releases of what will become Firefox 4 have implemented a couple of experimental new CSS features. The –moz-calc function allows calculations on length values, and the :-moz-any selector permits grouping of simple selectors. If you have a nightly build of Firefox you can see a little demo I’ve put together of them [...]]]></description>
			<content:encoded><![CDATA[<p>The latest nightly releases of what will become Firefox 4 have <a href="http://www.squarefree.com/burningedge/2010/05/12/2010-05-12-trunk-builds/">implemented a couple of experimental new CSS features</a>. The <code>–moz-calc</code> function allows calculations on length values, and the <code>:-moz-any</code> selector permits grouping of simple selectors.</p>
<p>If you have a <a href="http://www.mozilla.org/developer/#builds">nightly build of Firefox</a> you can see a little <a href="http://www.broken-links.com/tests/calc-any/">demo</a> I’ve put together of them in action.</p>
<p><span id="more-795"></span></p>
<p>The first new property is <code>–moz-calc</code>, which is the experimental implementation of CSS3’s <a href="http://www.w3.org/TR/css3-values/#calc"><code>calc</code> function</a>. This allows you to perform simple mathematical functions on length values.</p>
<p>Take a look at the <a href="http://www.broken-links.com/tests/calc-any/">demo</a>, where you’ll see two <code>h2</code> elements; both have the same styles applied to them, but the second also has some extra <code>calc</code> values for some of its properties:</p>
<pre>font-size: -moz-calc(120% * 3);
letter-spacing: -moz-calc(0 + 2px);
text-shadow: rgba(0,0,0,0.33) -moz-calc(4px / 2) -moz-calc(4px / 2);
word-spacing: -moz-calc(0.75em - 0.25em);</pre>
<p>The <code>font-size property</code> has a value of <em>120% * 3</em>, or <em>360%;</em> the <code>letter-spacing</code> property has a value of <em>0 + 2px</em>, or <em>2px</em>; the <code>text-shadow</code> property has x and y offset values of <em>4px / 2</em>, or <em>2px</em>; and the <code>word-spacing</code> property has a value of <em>0.75em — 0.25em</em>, or <em>0.5em</em>.</p>
<p>The values themselves are abitrary and not important; what matters is that we’re doing calculations in CSS!</p>
<p>At the moment the only properties which support <code>–moz-calc</code> values are:<code>–moz-column-rule-width</code>, <code>–moz-column-width</code>, <code>letter-spacing</code>, <code>word-spacing</code>, <code>marker-offset</code>, <code>outline-offset</code>, <code>border-spacing</code>, <code>text-shadow</code> and <code>–moz-box-shadow</code>; but work is underway to add this to all properties which accept length values.</p>
<p><strong>Update:</strong> You can read more about <code>calc()</code> at <a href="http://hacks.mozilla.org/2010/06/css3-calc/">hacks.mozilla.org</a>.</p>
<p>Also implemented is a new selector, <code>:-moz-any</code>. With this you can group other simple selectors, removing the need for repetitive code. Consider, for example, a typical web page which has many types of list, and nested lists:</p>
<pre>
&lt;ul&gt;
  &lt;li&gt;We are all list items now
    &lt;ul&gt;
      &lt;li&gt;We are all list items now&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
  &lt;li&gt;We are all list items now
    &lt;ul&gt;
      &lt;li&gt;We are all list items now&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;menu&gt;
  &lt;li&gt;We are all list items now
    &lt;ul&gt;
      &lt;li&gt;We are all list items now&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/menu&gt;
</pre>
<p>If we wanted to select all of the <code>li</code> children of nested <code>ul</code> elements we would currently have to do this:</p>
<pre>ul ul li, ol ul li, menu ul li { property: value; }</pre>
<p>But with <code>–moz-any</code> we can group the selectors like so:</p>
<pre>:-moz-any(ul,ol,menu) ul li { property: value; }</pre>
<p>In my <a href="http://www.broken-links.com/tests/calc-any/">demo</a> page I’ve provided a couple of examples; the first selects all list types which are direct child elements of the body:</p>
<pre>body > :-moz-any(ol, ul, menu) {
	float: left;
	width: 33%;
}</pre>
<p>And the next selects list items of the lists which are children of those elements:</p>
<pre>:-moz-any(ol, ul, menu) ul li {
	font-weight: bold;
	margin-left: 0;
}</pre>
<p>The <code>:any</code> selector isn’t in any of the CSS3 modules, but it’s pretty useful and definitely a candidate for inclusion. You can read more about it on <a href="http://dbaron.org/log/20100424-any">the blog of David Baron</a>.</p>
<p><strong>Update: </strong>Changed the examples for clarity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/05/17/new-to-firefox-moz-calc-and-moz-any/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An updated studio-style backdrop with CSS3</title>
		<link>http://www.broken-links.com/2010/04/26/an-updated-studio-style-backdrop-with-css3/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=an-updated-studio-style-backdrop-with-css3</link>
		<comments>http://www.broken-links.com/2010/04/26/an-updated-studio-style-backdrop-with-css3/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 18:43:20 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[css transformations]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[demo]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=784</guid>
		<description><![CDATA[I’ve updated my post, Create a studio-style backdrop with CSS3, as I realised a way to do the reflection without requiring an extra image — using the scale transformation function to flip the image vertically. The demo works in Firefox and WebKit.]]></description>
			<content:encoded><![CDATA[<p>I’ve updated my post, <a href="http://www.broken-links.com/2010/03/22/create-a-studio-style-backdrop-with-css3/">Create a studio-style backdrop with CSS3</a>, as I realised a way to do the reflection without requiring an extra image — using the <code>scale</code> transformation function to flip the image vertically.</p>
<p><a href="http://www.broken-links.com/tests/studio_effect/">The demo works in Firefox and WebKit</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/04/26/an-updated-studio-style-backdrop-with-css3/feed/</wfw:commentRss>
		<slash:comments>0</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>Create a studio-style backdrop with CSS3</title>
		<link>http://www.broken-links.com/2010/03/22/create-a-studio-style-backdrop-with-css3/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=create-a-studio-style-backdrop-with-css3</link>
		<comments>http://www.broken-links.com/2010/03/22/create-a-studio-style-backdrop-with-css3/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 23:25:50 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[gradients]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.broken-links.com/?p=741</guid>
		<description><![CDATA[Sitepoint's Web Design blog featured an article this week called <a href="http://www.sitepoint.com/blogs/2010/03/18/create-a-studio-style-backdrop-in-photoshop/">Create A Studio Style Backdrop In Photoshop</a>, which provides instructions for making a glossy, reflective surface effect, similar to what you often see in adverts. As the title makes clear, the tutorial is for creating the effect in Photoshop - but really, the same effect is fairly easily achievable with some bleeding-edge CSS. That said, it won't work in every browser, so currently it's just a proof-of-concept piece.]]></description>
			<content:encoded><![CDATA[<p>Sitepoint’s Web Design blog featured an article this week called <a href="http://www.sitepoint.com/blogs/2010/03/18/create-a-studio-style-backdrop-in-photoshop/">Create A Studio Style Backdrop In Photoshop</a>, which provides instructions for making a glossy, reflective surface effect, similar to what you often see in adverts.</p>
<p>As the title makes clear, the tutorial is for creating the effect in Photoshop — but really, the same effect is fairly easily achievable with some bleeding-edge CSS. That said, it won’t work in every browser, so currently it’s just a proof-of-concept piece.</p>
<p><span id="more-741"></span></p>
<p>You can see the finished work here: <a href="http://www.broken-links.com/tests/studio_effect/">Create a studio-style backdrop with CSS3</a>. You’ll need Firefox 3.6, Safari 4, or Chrome to see it as intended.</p>
<p>The first step is to create the markup for the backdrop; it’s pretty simple, you just need two <code>div</code>s:</p>
<pre>&lt;div id="studio"&gt;
&lt;div id="surface"&gt;&lt;/div&gt;
&lt;/div&gt;</pre>
<p>Next, the CSS. Set <code>#studio</code> to the required dimensions — I’ve used 800x600 pixels — and set <code>#surface</code> to occupy a third of that height, and absolutely position it to the bottom of <code>#studio</code>.</p>
<p>In the Photoshop tutorial they use circles and gaussian blur to create the gloss effect, but for our CSS tutorial we’ll use gradients. We must make two (one for each <code>div</code>), using the same colours but with slightly different dimensions. And we must use a different syntax for Firefox and WebKit, as I wrote about in my article <a href="http://www.broken-links.com/2009/11/30/css-gradient-syntax-comparison-of-mozilla-and-webkit-part-2/">CSS gradient syntax: comparison of Mozilla and WebKit (Part 2)</a>:</p>
<pre>#studio {
background-image: -moz-radial-gradient(circle farthest-side, white, #011601 80%, black);
background-image: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 340, from(white), color-stop(95%, #011601), to(black));
}
#surface {
background-image: -moz-radial-gradient(circle farthest-side, white, #011601 60%, black);
background-image: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 320, from(white), color-stop(80%, #011601), to(black));
}</pre>
<p>I won’t go into the details of why the syntaxes differ — I’ve done that in-depth already — but in essence I’ve set a gradient from <i>white</i> to <i>black</i>, passing through a shade of green (<code>#011601</code>) between. This gives the green-tinted gloss effect. The radius of the gradient in <code>#surface</code> is smaller, to display a pronounced difference between the two.</p>
<p>The next step was to add the product image — I’ve used the same <a href="http://www.sxc.hu/photo/942576">generic media player</a> image by <a href="http://www.sxc.hu/profile/pzado">Pzado</a>. <del datetime="2010-04-26T13:39:31+00:00">What I wanted to do was use the same image twice and flip it with CSS, but unfortunately that’s not possible, so I’ve had to make a copy of the original and flip it vertically to create two separate images. I’ve added these to the markup</del> <strong>Update:</strong> I realised that I could use the <code>scale</code> transformation function to do this, so I just need to repeat the same image twice with a different id for each:</p>
<pre>&lt;img src="phone.png" id="product"&gt;
&lt;img src="phone.png" id="reflection"&gt;</pre>
<p>I’ve positioned these absolutely, then rotated them using the <code>transform</code> property; I’ve also made <code>#reflection</code> mostly transparent:</p>
<pre>#product {
-moz-transform: rotate(20deg);
-o-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
}
#reflection {
opacity: 0.2;
-moz-transform: scale(1,-1) rotate(20deg) translate(-50px,-140px);
-o-transform: scale(1,-1) rotate(20deg) translate(-50px,-140px);
-webkit-transform: scale(1,-1) rotate(20deg) translate(-50px,-140px);
}</pre>
<p><strong>Update:</strong> So what I’ve done here is flipped the reflection image by using a negative (<em>–1</em>) value for the <code>scale</code> function; I’ve also used <code>translate</code> to reposition it directly below the main image.</p>
<p><del datetime="2010-04-26T13:39:31+00:00">WebKit rotates them nicely, but the output in Firefox is very jagged; hopefully this will be fixed in a future version.</del> <strong>Update:</strong> I was using Firefox 3.7a4 on Linux; in Firefox 3.6 (on Mac, at least) it rotates smoothly.</p>
<p>Finally, I’ve added some promotional text in <a href="http://www.theleagueofmoveabletype.com/fonts/7-league-gothic">The League Of Moveable Type’s League Gothic</a> font, using <code>@font-face</code>.</p>
<p>You can see the final result here: <a href="http://www.broken-links.com/tests/studio_effect/">Create a studio-style backdrop with CSS3</a>; as I mentioned, you’ll need Firefox 3.6, Safari 4, or Chrome to see it as intended. If you don’t have access to those, take a look at these screen grabs (click to see them full size):</p>
<p><a href="http://www.broken-links.com/wp-content/uploads/2010/03/studio-firefox.jpg"><img src="/wp-content/uploads/2010/03/studio-firefox-150x150.jpg" alt="Screenshot taken in Firefox 3.6" title="Studio-style backdrop (Firefox)" width="150" height="150" class="aligncenter size-thumbnail wp-image-761" /></a> <a href="http://www.broken-links.com/wp-content/uploads/2010/03/studio-chrome.jpg"><img src="/wp-content/uploads/2010/03/studio-chrome-150x150.jpg" alt="Screenshot taken in Google Chrome" title="Studio-style backdrop (Chrome)" width="150" height="150" class="aligncenter size-thumbnail wp-image-745" /></a> <a href="http://www.broken-links.com/wp-content/uploads/2010/03/studio-minefield.jpg"><img src="/wp-content/uploads/2010/03/studio-minefield-150x150.jpg" alt="Screenshot taken in Firefox 3.7a4" title="Studio-style backdrop (Firefox 3.7a4)" width="150" height="150" class="aligncenter size-thumbnail wp-image-746" /></a></p>
<p>So what was the point of this? An intellectual exercise, really. It’s not suitable for use on a production site, and will need some polishing to be in any way useful. But it’s fun to play around with new CSS properties, and to start to get an idea of how we can use it to replicate effects which used to only be possible in graphics packages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.broken-links.com/2010/03/22/create-a-studio-style-backdrop-with-css3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
