Tuesday, 1 April 2008

Urestrict BBC Radio iPlayer

As long as I can remember, the BBC's online music streaming service has restricted the control you have on playback streams, restricting the embedded realplayer controls to allow you pause, skip 5 minutes or skip 15 and change the volume. I can understand the legal obligations they may have, but from a piracy perspective stopping people skipping tracks is irrelevant, its only use is as a measure to stop people re-listening to the same track without having to go back to the start each time.

The controls on Mac OS X are less restrictive, but still restrict you to pause, fast forward or stop, however some simple javascript manipulation of the page can enable the regular RealPlayer controls, complete with a seek-bar.

Bookmark either download the source file or view the bookmarklet source. Unfortunately blogger won't let me create an actual bookmarklet link, so you will manually have to save the bookmarklet into a bookmark in your browser.

Labels: , , , , ,

Saturday, 1 March 2008

Google Maps Placemark

This post has been sitting for quite a while now, pending me having time to sit down and write some text to go alongside the code. It would appear that I now have the time to write it up.

Back when I was writing my Google Maps property finder I was using Google's Geocoding API to get a set of co-ordinates based on a search string.

Specifically I was using the getLocations method of the GClientGeocoder object. This would return a number of Placemark objects with a bunch of information about the potential matches. They don't really document this object, but to be honest they don't really need to, below is an example Placemark expressed in JSON-ish notation.

{   "id": "p1",
    "address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
    "AddressDetails": {
        "Country": {
            "CountryNameCode": "US",
            "AdministrativeArea": {
                "AdministrativeAreaName": "CA",
                "SubAdministrativeArea": {
                    "SubAdministrativeAreaName": "Santa Clara",
                    "Locality": {
                        "LocalityName": "Mountain View",
                        "Thoroughfare": {
                            "ThoroughfareName": "1600 Amphitheatre Pkwy"},
                            "PostalCode": {
                                "PostalCodeNumber": "94043"
                            }
                        }
                    }
                }
            },
        "Accuracy": 8
        },
    "Point": {
        "coordinates": [-122.081783,37.423111,0]
    }
}

The only thing is, if you want to get a specific element, the tree will not necessarily be the same each time, so traversal is a pain. The code below will condense all this into the root level of an object, so you can pick out the key/value pairs you want, and easily tell if some aren't there.

var Placemark = new Class({
 initialize: function(placemark){
  this.traverse(placemark);
 },
 traverse: function(item, key) {
  for (var key in item) {
   
   if (key == 'prototype')
    continue;
    
   if(typeof(item[key]) != 'object')
    this[key] = item[key];
   else
    this.traverse(item[key]);
  }
 }
})

One thing to note is that this was written for to use the Mootools class system, though it shouldn't be very hard to remove this dependancy.

Labels: , ,

Tuesday, 29 January 2008

Leaked UK National ID Register Document

In response to a post on boingboing requesting mirrors for a leaked document, here is my mirror copy. Enjoy :)

Labels: , ,

Saturday, 26 January 2008

Spring MVC Wizards & Form Taglib

I've been building a JSP based website for a course module titled "Technologies for Electronic Commerce". It's finished now, but I've only just got round to writing up this post.

As part of this I was trying to make a multi-page form, using Spring's AbstractWizardFormController and spent an hour or so trying to make the form submission change the form page. My problem was that it wasn't immediately obvious how to use the form taglib with the Wizard architecture.

The docs mentioned using request parameters, which was a bit confusing as I was using a POST form submission, however all you actually need to do is add one of these parameters to the form data (usually using a button).

Finish and cancel actions can be triggered by request parameters, named PARAM_FINISH ("_finish") and PARAM_CANCEL ("_cancel"), ignoring parameter values to allow for HTML buttons. The target page for page changes can be specified by PARAM_TARGET, appending the page number to the parameter name (e.g. "_target1"). The action parameters are recognized when triggered by image buttons too (via "_finish.x", "_abort.x", or "_target1.x").

For example:

<input value="Submit" name="_target1" type="submit"/>
This will request to change to page 2 of the form (remember Array base is 0). Because of the way forms work, you can have a number of these (either as clickable images or buttons) and only the one the user eventually selects will be submitted with the request.

Labels: , , , ,

Saturday, 5 January 2008

Making the most of Pandora.com

Pandora.com is pretty cool, it's been around for a while now but I just went back to it for some easy listening background music to work to. Supposedly they've begun to use IP filtering to limit the audience to the US. Either this is no longer in place or they've made a mistake in a regex somewhere, as this is definitely not the US. I'd forgotten about the limit to the unpaid service, which stops playback after so many songs, but it was quite a while before I actually encountered it. This may be a Mac OS X bug in the flash implementation, but it seems that if you keep the Firefox window containing the player minimised in the Dock, the music doesn't stop playing! Of course this does get in the way of the whole feedback system slightly, but I'm sure there are those who won't mind too much. Once I did encounter the limit I couldn't just refresh the page and go back to listening again as they're smart enough to stop you doing that. But not that smart. To completely stop this you would require either some heinous DRM-spawn system describable as cookies which you can't delete, or some kind of unique client ID, effectively voiding all browser privacy. So to be fair, from the technologies they had to work with, they've done the best they could. ;) So once you've been shut out of the Pandora player try the following:
  1. Delete your cookies from their domains.
  2. Delete any data stored within Adobe Flash for their domain.
The latter can be achieved by opening the Adobe Flash client settings and changing the data limit for the domain to 0KB, which will take effect upon refreshing the page, upon which the flash applet will request to store data in your browser again, and you're back listening, but without any of your stations.

Update:

It appears that the region filtering will go live on January 15th, not quite yet.

Labels: , , , ,