Older blog entries for pycage (starting at number 79)

Mediabox Walkthrough: Playlist Editing

In a few days the new version 0.95 of the MediaBox Media Center will be released for the Nokia internet tablets. Let me introduce a few of the new features until then. Today I'm showing you a bit about the new playlist feature.

Enter the music viewer

You can edit the playlist in the music viewer. To get there, press on the tiny arrow button in the bottom left corner once.

The screen will slide up to reveal the viewer menu where you can switch between the different viewers of MediaBox.

Tap on the music viewer icon to select it. You're in the music viewer now.

Choose an album

On the left-hand side of the screen you can see a strip of images representing your album folders which MediaBox has found on your device.

You can drag the strip with your thumb to scroll through it.

When you've found the album you're looking for, press on the little arrow button on the album image to open it.

Add tracks to the playlist
After opening an album, you can see all its tracks on the screen. Again, you can use your thumb to scroll through this list.

The top item of this list represents the album itself and shows you the album cover (if available) and the number of tracks in the album. The other items represent the tracks in the album.

On each track there is a menu button to the right. Tap on it to reveal the track menu, where you can choose between [play] and [add to playlist]. The album item does not (yet) have a menu button. Instead it has the [add to playlist] button there.

That way you can either add particular tracks or complete albums at once to the playlist.

Switch to the playlist view

There is a button in the toolbar where you can switch between album view and playlist view. Press it once to get to the playlist view.

The playlist view shows all your playlist items in a list. Use your thumb to scroll through this list.

The album cover on the left side of each playlist item shows you where this particular track comes from.

Play or remove tracks

Each playlist item has a menu item on the right-hand side.
Press it once to reveal the item menu, where you will find buttons for [play], [remove from playlist], [remove succeeding], and [remove preceeding].

The [remove succeeding] and [remove preceeding] buttons are special because they do not only remove the selected item, but also all items preceeding or succeeding it.
That way you can quickly clean up large portions of the playlist.

Reorder the playlist

You can use your thumb to drag playlist items in order to reorder them.

Use the tiny dragging area at the left of an item to drag it around.

Syndicated 2008-05-01 16:07:00 (Updated 2008-05-01 16:27:26) from Martin Grimme

Laptop, External Monitor, and xrandr to the Rescue

I have just upgraded to Ubuntu Gutsy (I know I'm very very late) on my laptop. The installation went fine but when I connected an external monitor with a higher resolution than my laptop has, gdm and GNOME were not able to detect this, and instead displayed the picture in the upper left corner of the screen.

This was especially funny with GNOME, because the desktop actually used the full resolution, and I could move windows over the whole screen. Only the panels were stuck in the middle of the screen.

Apparently I'm not the only one with this problem, so let me tell you what I found out and how to fix this.

Everything was fine with Ubuntu Feisty. When I connected an external monitor, the laptop screen switched off and the higher resolution was used. But now when I connect an external monitor, the laptop screen doesn't switch off automatically.

Because the laptop screen is still on, the system now has two screens and GNOME will automatically adapt to the screen with the lower resolution.

The moment I manually switched off the laptop screen with the tool xrandr


$ xrandr --output LVDS --off

the GNOME panels jumped to their correct position. So let's investigate this xrandr a bit more.

xrandr is a powerful tool for managing multiple video outputs, rotating the screen, and setting up multihead displays.

You can get a list of what the graphics driver thinks it has connected by invoking

$ xrandr -q

This will give you something like this:

Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 1680 x 1200
VGA-0 connected 1680x1050+0+0 (normal left inverted right) 433mm x 271mm
1680x1050 60.0*+ 60.0
1280x1024 75.0 59.9
1440x900 75.0 59.9
1280x960 59.9
1152x864 74.8
1280x720 59.9
1024x768 75.1 60.0
800x600 75.0 60.3
640x480 75.0 60.0
720x400 70.1
LVDS connected (normal left inverted right)
1024x768 60.0 + 60.0
800x600 60.3
640x480 59.9
S-video disconnected (normal left inverted right)

The interesting entries are LVDS (the laptop screen) and VGA-0 (the external monitor). Both are connected. VGA-0 might be called VGA or similar on your system, as this name is driver-dependent.

If I wanted to check if an external monitor was connected, I'd just run

$ xrandr -q | grep "^VGA.* connected"

VGA-0 connected 1280x1024+0+0 (normal left inverted right) 338mm x 270mm

I want the system to switch off the laptop screen whenever an external monitor is connected, so that GNOME will use the higher resolution. This easily can be done by adding the following lines to /etc/gdm/Init/Default just before the

exit 0

line:

xrandr -q | grep "^VGA.* connected" >/dev/null
RC=$?
if [ $RC = 0 ]; then
xrandr --output LVDS --off
fi

It will also make gdm use the full resolution.

Syndicated 2008-03-26 09:14:00 (Updated 2008-03-26 09:21:24) from Martin Grimme

"Native" PAN support for maemo

maemo in a PAN
The waiting is finally over. There is now support for phone-tethering via the PAN Bluetooth profile, which is so popular on Windows Mobile smartphones.

By "native" I mean that it's quite well built into the system and does not appear as a separate application. And you no longer need a command line or root access for making PAN connections.

After you have installed the maemo-pan add-on (sorry, only OS 2008 supported so far), you can get online with just a few simple steps:
  • Go to the system preferences and add your phone in the phone settings. Do not enter the wizard for configuring the dialup settings. PAN does not use them.

  • Start internet sharing on your phone. It depends on your phone how and where to do this. On Windows Mobile 5, open the Start menu and select "internet connection sharing" from there.

  • Make sure that Bluetooth is enabled on your internet tablet. Now open the connection dialog and you will see that there is a new connection called "Bluetooth-PAN". Select it and you will be connected to the internet via PAN.

  • When you're finished, just close the connection the usual way. Wasn't this easy? :)

Thanks go to aleksandyr for figuring out stuff and to Frantisek Dufka for writing the initial PAN connection shell script for OS 2008. Without you guys maemo-pan wouldn't have happened!

Syndicated 2008-02-26 21:56:00 (Updated 2008-02-26 22:08:09) from Martin Grimme

26 Feb 2008 (updated 11 Dec 2008 at 06:08 UTC) »

No, MediaBox Media Center is NOT developed by Nokia


Somebody at maemo.org must have thought MediaBox was a Nokia application while tagging some pages. The MediaBox entry on maemo.org/downloads is tagged with "Application developed by NOKIA". This is plain wrong!

No, I am not working for Nokia, and MediaBox Media Center is not related to Nokia in any way.

Syndicated 2008-02-26 21:11:00 (Updated 2008-12-11 05:06:13) from Martin Grimme

MediaBox once again - 0.94.2 this time

Maybe I was too quick releasing MediaBox 0.94.1 yesterday. The config reader bug which could cause hanging during startup was only partially fixed in 0.94.1. So here's release 0.94.2 with even more bug fixes hitting the maemo download servers.

Syndicated 2008-02-21 20:03:00 (Updated 2008-02-21 20:09:56) from Martin Grimme

MediaBox 0.94.1 fixing a few things

I have just released Version 0.94.1 of the MediaBox Media Center. This is a bugfix release and will help you if you experienced MediaBox 0.94 hanging on startup.

The new version also adds support for non-UTF-8 character encodings in ID3 tags, such as ISO-8859-1 and UTF-16.

Thanks to all users who reported bugs and made suggestions!

Syndicated 2008-02-20 20:15:00 (Updated 2008-02-20 20:18:08) from Martin Grimme

MediaBox 0.94 - the New Enhancements and a Big Thank You!

Thank you all for reporting bugs and giving new suggestions for MediaBox Media Center! You help me a lot making this the best and friendliest media center for the tablets! Keep on reporting; you decide what's important!

MediaBox Track Info

So here is release 0.94 with a lot of small improvements.

The media scanner will now cache already loaded thumbnails so it will be quicker after you add or remove a media folder. You can also specify for each folder which kind of media you have in there. Thus you will be able to avoid getting all your album cover art listed in the image viewer, for example.

Configuring the media collection

If you've always wanted to play the FM radio through the loudspeakers, you can do so now. MediaBox can finally switch from headphones to loudspeakers when the headphones are plugged in as FM radio antenna. The FM radio is only available on the N800, though.

The button on the Nokia headset is now also supported and you can press it to pause and resume playback.

I have also added a tag parser for FLAC tags and fixed some flaws regarding FLAC playback. FLAC is a free and lossless audio codec for high quality audio.

MediaBox is now powered by player backends for mplayer and the native osso-media-server. By selecting between two backends, more media formats can be played back. This especially adds support for real media and real internet radio streams (.ram), as well as MP4 and 3GP videos.

The new MediaBox release is available from the website as well as through the application manager in the Maemo extras catalogue. The package installs on OS 2006 (video playback not yet supported on the 770), OS 2007, and OS 2008.

Syndicated 2008-02-11 19:50:00 (Updated 2008-02-11 19:58:55) from Martin Grimme

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.

Syndicated 2008-01-25 18:02:00 (Updated 2008-01-25 18:13:36) from Martin Grimme

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.

Syndicated 2008-01-20 21:32:00 (Updated 2008-01-20 21:46:19) from Martin Grimme

1 Jan 2008 (updated 11 Dec 2008 at 06:08 UTC) »

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.

Syndicated 2008-01-01 15:14:00 (Updated 2008-12-11 05:06:13) from Martin Grimme

70 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!