Thursday, May 11, 2006

Flash-based MP3 players

This blog seems to be turning out to be dedicated to JavaScript. So I thought of adding something completely different. I've been looking for an MP3 player. More specifically, my requirement is to listen to music during my exercise (mostly). I already have a cheap Chinese MP3 player that I picked up while I was in Singapore, but it's battery is useless. It has an average battery life of about one hour, which is really annoying. So I've been reading reviews on what's available and trying to figure out the best value for money player out there. I of course love gadgets, so the new gadget should be flashy and packed with extra features that I may never use!!

After reading about hard-disk based players and learning about their problems with skipping I decided to focus on a flash memory based player. Another reason for focusing on a flash memory based player is the weight factor. Hard disk players are always heaver and would feel bulky in my pocket. Hopefully, the flash-based players also have a better battery life as they do not have any moving parts.

My research revealed that there are currently three top of the range flash-based players with over 4GB memory: iPod nano, Sandisk e200 series, Samsung YP Z5. Sandisk are the only company to have a 6GB flash player. The iPod is the thinnest player and then the other two are similar in size. The Sandisk is the thickest (slightly). While investigating the different features that each player offered, I realised that the features can be divided into hardware features and software. To me the extra software that the player comes with is irrelevant. I'm sure I will be able to find the necessary converters etc. So features that I've labelled as software are features offered by the player itself.

In terms of hardware features, all three come up with standard features expected from a portable music player. All three have colour screens; the screen of the ipod is smaller (1.5") compared to the others (1.8"). The ipod and samsung player both have very simillar features. The sandisk player has extras like an FM tuner and video playback. Ipod has a few neat extra software features like a calendar, contacts and games.

To me, battery life is paramount. In the end, I decided to go with the Sandisk player, because it had a battery rated 20 hours and was removable. I've heard so many horror stories about ipod batteries. I think most problems are because of its instant-on feature which keeps draining battery life by going into hibernation mode. The iPod can never be completely turned off, it always goes to hibernation mode. The Samsung player has a really good battery, but it doesn't have the extras such as radio and movie playback.

Now, only if I can buy a Sandisk sansa e260 or e270 in New Zealand!!

Syntax highlighting using Javascript

I've been looking around for a web-based source code editor. My search was for an editor embedded in a web page which would allow the modification of code stored in a server. This does not mean an editor for editing web-technology related source files. Searching the web mostly resulted in editors for JavaScript, html etc.

Currently About:Edit is a very good source code editor. It is commercial product that provides a lot of features including syntax highlighting. Its impossible to hide the source code of JavaScript apps, so my inquisitiveness got the better of me. I had a look at their source code. The code is very complicated and they have tried very very hard to make it as obfuscated as possible.

I came across some guy who had a post on their blog (I can’t acknowledge the source as I've lost it), a nice proof-of-concept of using JavaScript for syntax highlighting a static page. His idea was simple; use regular expressions to search for keywords in a document and then replace them with formatted text. Here’s an example,

var keywordPattern = /\band|not|null|equalp|match\b/g;

var text = document.getElementById("constraints").innerHTML;
document.getElementById("constraints").innerHTML =
text.replace(keywordPattern, function(text) {
return "" + text + ""

The code looks for a set of keywords (and, not etc) and adds a span tag around it. It works like a charm.

This is no solution to my intial problem of an code editor. However, it does provide a nice way of displaying code.