Friday, January 25, 2008

MediaBox 0.93 with support for embedded ID3 album art and more

Maybe you have already noticed that there's now MediaBox 0.93 available in the maemo-extras repositories for OS 2007 and OS 2008.

So what's new in this release?

First of all, rendering became a bit faster. Many rendering operations are now directly performed on the X server where they run 2D-hardware-accelerated. Previously, only the kinetic scrolling was done like this. Especially the Nokia 770 gives very smooth results that way.

But much more important, the media scanner became a lot quicker. So if there are no new thumbnails to generate, it will scan your media in almost no time. Together with deferred thumbnail assembling, this greatly speeds up startup time.
The scanner is now also much more robust and knows how to get past bad media files that make mplayer hang during thumbnailing. Oh, and you can now watch the new thumbnails while they are being created.

I have improved the ID3 tag parser as well and it supports ID3 v1, v2.2, v2.3, v2.4 now. If you have album art embedded in your ID3 tags, then chances are good that MediaBox will be able to show it.

MediaBox also runs on the Nokia 770 with OS 2006, but video still does not work reliably there, and there are still some memory issues to be solved. But it's perfectly usable as a photo viewer or for playing music. Of course I'll keep testing MediaBox on the 770 and try to make it work even better.

See the release notes for more.

Sunday, January 20, 2008

N810 - What's good, what's bad

It's been one and a half weeks since I got my N810 and I had some time to play around with most of its features.

What I like

The N810 is a bit smaller than the N800 and 770 and easily fits a jeans pocket. The size is just perfect for an internet tablet. It's tiny, reasonably thin, but still features a screen big enough for enjoying multimedia and the web.

For the first time, Nokia included a usable carrying case with an internet tablet. If you remember the "sock" that came with the 770 and the "shades sleeve" of the N800 (where the device slipped out easily), you know what's unusable. The N810 case is still a soft case, but the device won't slip out and the upper hardware keys are still accessible.
The surface and back of the device are made of brushed metal and look very noble compared to the toy-look of the N800. No other internet tablet can beat the speakers of the N800 but the tiny speakers to the left and right side of the N810 produce surprisingly good sound. The builtin stand is solid and has three positions. That's one more than the N800 has.

There is finally a hardware keyboard which can be slid out. Of course, it's not a full-size keyboard, but the keys are good to press with your thumbs. I especially like the fact that it has backlight and is thus usable in the dark. I always hate it when I can't properly see my laptop keyboard in the dark. The stickiness of the shift and Chr keys was a good idea and it makes typing reasonbly fast.
The stickiness is important because you usually don't want to hold down the shift key while pressing a letter when typing with only two thumbs. There is also a builtin GPS receiver together with preinstalled map software.

The map software is simply a light version of the Navicore / Wayfinder navigation software. If you have a valid Navicore or Wayfinder license, you can unlock the navigation functions of the map software. As a 770-Navicore user I simply entered my key and, hey presto, I had the current Navicore (which is now called Wayfinder, since they bought Navicore) installed on the N810.
Luckily, the N810 comes with the appropriate car holder. When I got the N800 I was annoyed by the fact that it didn't fit the car holder from my 770-Navicore.
Some people reported problems with the GPS receiver, but I got a GPS fix rather quickly even on a totally foggy dark winter morning.

I also want to point out that the new OS 2008 seems to be very stable and I didn't experience a single crash so far! It's also nice that you can now lock the screen and keys with a hardware key. Very handy!

What I don't like

Of course the N810 isn't perfect. Here's my rant.

Who designed the carrying case? It looks as if I was carrying a medical device around. The look just does not fit a high-tech internet device! I hate the size of miniSD cards (and even more so the size of microSD!).
My card readers and the N800 take full-size SD cards. Whenever I want to put a miniSD card into my N800 or the card reader, I have to fiddle with an awkward adapter. Totally annoying! The micro-USB port is also annoying because now I have an extra cable attached to my computer.

The car holder has a big bulk of plastic on the top. This was totally unnecessary and I might eventually cut off this part. While I understand that the device leaves no place for cursor keys anymore, I find it bothersome to pull out the keyboard everytime I want to use the cursor keys or the center button.

The map software lets you download new maps off the internet, but this never worked for me. Not on my N800 and not on my N810. The Wayfinder download server must be seriously broken as many users report problems downloading maps. The included map of Germany & Alps (2008) shows no difference to the map update of Navicore (2007) or the map included with Navicore (2006). And even the 2006 map wasn't up to date then. I still miss major roads built in 2006 on the 2008 map! For example, look at the B2 between Donauwoerth and Augsburg. The parts built in 2006 are still missing!
And the map has bugs, too. For example, it shows Technische Universitaet Munich in a totally different town. Not to mention some POIs to be placed wrongly. I have no navi to compare, but I suspect that all navis using Teleatlas maps have the same problems.

The new MicroB web browser shows very buggy behaviour when panning with the stylus. Sometimes it works, sometimes it jumps nervously around, sometimes it just selects text. The browser is also a bit slower than Opera on the N800 used to be.

The position of the light sensor is also not optimal as it's too easy to cover it with your fingers while holding the tablet.

Tuesday, January 1, 2008

Tablet Python #3 - List Comprehension

A Happy New Year to everyone! In today's episode of Tablet Python I'm going to tell you more about list comprehension which we were already using in the last episode.

Introduction

List comprehension is a unique feature of the Python language (correct me if I'm wrong). It might look intimidating at first, but believe me, it can soon become one of your best friends in Python. It's so elegant and simple!

But let's approach this step by step.

Step 1: You can copy lists

Let's define a list
a = [1, 2, 3]

You can make a copy of a by iterating through the elements in a, like this:
copy_of_a = []
for element in a:
copy_of_a.append(element)

This is about the way you would do it in any other language. But with list comprehension, you would simply write:
copy_of_a = [ element for element in a ]

This simply says, build a list and for every element in a, put element into this list. Then assign the new list to the variable copy_of_a.

For completeness, I want to tell you, however, that the easiest way to copy a list in Python goes by "slicing":copy_of_a = a[:]

Step 2: You can build modified copies

Let's assume you have a list of filesystem paths and would like to strip off the path so that only the filename remains.

This is our list:
a = ["/home/user/file1", "/media/mmc1/file2", "/media/mmc2/file3"]

And this is what we want to get:
["file1", "file2", "file3"]

The classic way goes like this:
b = []
for element in a:
b.append(os.path.basename(element))

But with list comprehension, you'd do it like this:
b = [ os.path.basename(element) for element in a ]

Or in words: build a list, and for every element in a, apply os.path.basename() on element and put the result into the new list. Then assign the new list to the variable b.

Step 3: You can filter lists

Now let's take a look at the list comprehension construct from the last episode:
resources = [ f for f in os.listdir(_RESOURCE_PATH) if f.endswith(".png") ]

Can you guess what it does?
Build a list, and for every f in the result of os.listdir(_RESOURCE_PATH), put f into the new list if f.endswith(".png") returns True. Then assign the new list to the variable resources.
It's the same as:
resources = []
for f in os.listdir(_RESOURCE_PATH):
if f.endswith(".png"):
resources.append(f)

... but way shorter, less error-prone, and easier to read!

Step 4: You can combine modifying and filtering

Let's take this to the extreme by modifying and filtering a list at the same time:
a = [ str(c) for c in range(100) if (c % 5 == 0) ]

This builds a list a which contains as strings those numbers in the range between 0 and 99, which can be divided by 5.
This would be
a = []
for c in range(100):
if (c % 5 == 0):
a.append(str(c))

for all those poor people who cannot use list comprehension.

Step 5: Still confused? It's simply a mathematical set notation!

Do you remember this notation?

List comprehension in Python is just the same!
B = [ x*x for x in A if (x % 5 == 0) ]

And that's the secret key which helps you understand it.

Conclusion

Generally, list comprehension helps you write cleaner code. It expresses how you think about solving the problem instead of describing every step necessary to solve the problem. Once you get used to it, it's a much more intuitive way of working with lists.
A feature of higher-level (functional) languages is that you can make the computer solve problems by describing what you want, instead of giving step-by-step instructions on how to solve it.
However, as with every powerful tool, use it wisely. It's e.g. generally not a good idea to use list comprehension to shorten code with side-effects. Don't use list comprehension to make your code shorter, but to make it understandable.