Saturday, 29 November 2008

Bringing QuickTime to the Wii

OK so while the title is true it is rather misleading. Let me explain.

I have a web application that contains QuickTime movies (film trailers) and I wanted to make sure that if the user of the site didn't have QuickTime installed they could still see the movies. My main reason for this is that I wanted the site to work fully when viewed through the web browser on the Wii and the Wii doesn't support QuickTime.

The solution is to try and use QuickTime but if it isn't installed then to convert, on the fly (using FFmpeg), the QuickTime movie to an FLV file and then play this back in a Flash based movie player (specifically the JW FLV Player) that will work on the Wii.

Now I know that there are a number of systems available that use the web browser on the Wii to turn it into a media player but these are all huge systems with their own front and back end code and didn't seem like a reasonable starting point for what I wanted. A few people have also tried to work on a small scale and do what I wanted to achieve but from my perspective their approaches suffered from two problems 1) none of them used servlets as the back end code and I was already committed to using Tomcat and 2) they all had problems with seeking within the resulting FLV movies. So I set out to solve both of these problems.

It's taken me a few days to get something that works but I'm now happy enough with the code to release it into the wild for others to play with and improve upon. Unfortunately I can't easily show you a demo as the machine hosting this blog doesn't provide me with the ability to run server side scripts but you can download the entire example which when unzipped provides a complete Tomcat webapp.

v0.4 (08/04/2011): Updated to the newest version of JW FLV Player, fixed numerous bugs and re-factored the code to make it more flexible and maintainable. This release should be much more usable then the previous ones.

v0.3 (14/03/2010): Fixed a bug that was causing an error on the Wii and updated the JW FLV Player to the newest version. The code is now also being hosted (and built by Hudson) along with the rest of my projects.

Updated 02/12/2008: I've cleaned up a lot of the server side code to make it easier to understand and maintain. I've also updated the bundled copy of FFmpeg to a much newer build. Finally I've updated the version of the QuickTime embedding script to the newest version.

Friday, 28 November 2008

Where On The Map Am I?

When I blogged about using KMLMapLoader to load easily load KML/KMZ files onto a map I quietly side-stepped one problem. The KMLMapLoader requires you to specify the latitude and longitude on which to centre the map and a zoom level, but where do you get these values from?

You could play around with the main Google Maps page and try and figure out appropriate values but this can be a bit hit or miss. The easiest way it to use a new feature in TagME. Simply open your project, choose to configure Google Maps from the tools menu and then specify the size of the map (in pixels) and it will give you the latitude, longitude and zoom values to use. Nice and simple!

Wednesday, 26 November 2008

Calum's Road

I'm going to a Runrig concert this evening and so was playing some Runrig music on my iPod on the way to work. While listening to Wall of China I decided that I should blog about a book called Calum's Road by Roger Hutchinson. Whilst at first glance this may seem a bizarre jump bare with me for a few more lines and everything will become clear (I hope).

If I was writing the blurb for the dust jacket I'd write:
Calum's Road chronicles one man’s attempt to save a dying community. The north of the Hebridean Island of Raasay didn’t used to be connected to the rest of the island by road. It’s inaccessible nature saw the population dwindle until the population was just two; Calum and his wife. One morning Calum set out to change his world, he started to single-handedly build a road. It took him twenty years but eventually he brought a road to his hamlet at Arnish.
Still confused by the Runrig reference? OK I'll explain. I only found out about the book as it was reviewed in The Wire (the newsletter of the Runrig fan club) as it's subject matter had been used as the basis for the song Wall of China from The Stamping Ground album.

My Rating: 5 Stars I would probably have never picked this book up without having read the review, but I am so glad I did. A heart warming tale of perseverance in the face of an intransigent political system.

Monday, 24 November 2008

F1 Without the Adverts

Next year sees F1 coverage in the UK move back to the BBC. Finally after goodness knows how many years we can again see an F1 race uninterrupted by adverts! Now like most fans I've known about the move for a while but today the BBC have announced their presenting line-up.

Jake Humphrey (who I've never heard of) will anchor the show and be joined by David Coulthard and Eddie Jordan, who with their experience, as former F1 driver and team owner respectively, should make good pundits (I doubt they could be worse than Mark Blundell). Martin Brundle will continue as race commentator and be joined by Jonathan Legard (who currently works for 5 Live). I think it's a shame they couldn't have kept with James Allan as I actually quite liked his commentating style. And finally the pit-lane reporters will be Ted Kravitz and Lee McKenzie.

Hopefully the coverage of F1 on the BBC will be at least as good as the coverage ITV have provided, but with uninterrupted races it should be even better. Of course I won't need the TV coverage at next years British race as we have full 3 day passes to Silverstone, so watch out for us in the crowd!

Saturday, 22 November 2008

Easy Map Embedding

Every since starting the development of TagME I've been thinking about finding an easy way of showing the geotagged photos on my blog. Now it is quite easy to display a KMZ file in Google Maps (and of course Google Earth) using the simple method Google provides. Unfortunately this method doesn't allow you to access all the features of the Google Maps API. So to allow me more flexibility I've written some javascript to allow for easy map embedding. Here is the script in action:



To achieve this you need to have already loaded the Google Maps API and then in the head section of your page load my KMLMapLoader. The when you want to embed a map you create a DIV to contain it. For example, to create the map I showed above you add the following to your page:
<div kml="http://www.dcs.shef.ac.uk/~mark/blog/blog_files/journeys/to_work_updated.kmz"
zoom="11" latitude="53.4717" longitude="-1.511993"
maptype="G_PHYSICAL_MAP"
config="map.addControl(new GLargeMapControl());"
style="border: 1px solid black; width: 600px; height: 700px;">
</div>
It is reasonable straightforward but here is an explanation of the different attributes you can set:
kml
This should be the URL of the KML or KMZ file you wish to display on the map.

latitude
The latitude of the centre of the map.

longitude
The longitude of the centre of the map.

zoom
The zoom level (level 0 shows the whole earth, each increase in zoom level increase the area seen be a power of 2).

maptype
The map type. The default is the street level map, but you can specify any of the types Google supports. Note that id you specify G_SATELLITE_3D_MAP and the Google Earth plugin isn't installed then rather than an error message the script will revert to using G_SATELLITE_MAP

config
If specified this should be JavaScript that will be executed once the map has been initialised. The map itself is available in the variable map and this can be used to further configure the map (for example adding a large map control rather than the default small control the script uses).
Only the kml attribute is required, but to set the location of the map latitude, longitude and zoom must all be specified.

The script actually does a little more than loading the map, it also provides a fix for a bug in the current version of the Google Maps API. When loading a KMZ file the images etc are accessed through a server side script. Unfortunately the API uses a relative URL to point to this script and so KMZ files display properly if loaded through the main Google Maps website but not when loaded using the API. KMLMapLoader adds code to fix this bug which you can reuse even if you don't want to use the loading facilities.

Thursday, 20 November 2008

Heads I Win, Tails You Lose!

When we went to St. Andrews we made the mistake of escaping from the cold wind by looking around Waterstones. This is always an expensive mistake! One of the books I bought was How Many Socks Make A Pair? by Rob Eastaway. How Many Socks Make A Pair? aims to make mathematics interesting. Whilst there isn't an equation in sight you will learn about probability theory via the old choosing socks blindly from a draw problem, as well as learning magic and card tricks.

Having previously blogged about the changes to our coins I was particularly interested in a section on coin based probability, particularly the following fact about spinning a penny to determine heads or tails:
What happens if you try and remove the human error by spinning the coin on its axis instead [of flipping it in the air], on a smooth table? It turns out that this is even more biased. Depending on the currency you use, the results can be a long way from 50-50. If you spin an American penny, it has been found to end up showing tails as much as 80 per cent of the time. British pennies are also heavily biased towards tails.
Now given that the tail designs on our coins have changed I was interested to know if this was still true or not. So I conducted my own little experiment. I found two almost mint 2008 pennies; one with the old design and one with the new design. I then spun each coin a hundred times and recorded the outcome. I didn't record spins which didn't get fully up to speed or those that bounced off something else on the table as I felt that these may affect the result.

The first thing to note is that I couldn't replicate the result from the book as the old design penny actually landed 53 to 47 for heads. The new design, however, fell equal with 50 heads and 50 tails.

So what does this all tell us. Firstly the experiment isn't very scientific I'd need a lot more than a hundred spins to show a very small bias. Having said that it looks as if the new design is a fairer coin when spun than the old design.

My Rating: 5 Stars A really interesting book, that makes maths both fun and relevant without resorting to equations.

Tuesday, 18 November 2008

Dell Software License Agreement

I tend to treat license agreements like I do manuals -- I don't read them. However, as I was sorting out the junk that came in the box with my Mini 9 the sentence at the bottom of the first page of the Dell Software License Agreement caught me eye. It reads as follows:
If the package accompanying your computer contains compact discs, 3.5" and/or 5.25" disks, you may use only the disks appropriate for your computer.
Now I'm guessing it's been a while since Dell actually shipped a 3.5" floppy disk to a customer (most of their machines haven't even contained a floppy disk drive as standard for quite a while) but I'm guessing it may have been decades since they last shipped a 5.25" floppy! I think they need to seriously think about updating their license agreement to bring it into the twenty first century, especially that, as written, it doesn't seem to apply to the DVD of drivers and utilities I found in the bottom of the box.