Wednesday, April 9, 2008

MPlayer, Nautilus and File Names with Spaces

The GNOME file manager - Nautilus - lets you specify alternative actions for known file types. This is rather convenient if you don't happen to like the default application that GNOME assigns for the job.

Case in point: multimedia files. I happen to prefer MPlayer, from the Debian multimedia package repository, over Totem - the default multimedia player in GNOME:
  1. open Nautilus, find the file you want to open with MPlayer
  2. right-click on the file
  3. from the pop-up menu select "Open with Other Application..."
  4. wait for the "Installed Aplications" list to be populated and then select "MPlayer"
Note that you may, instead, have on step 3 a menu item "Open With ->", with a sub-menu that may already include MPlayer and also the entry "Open with Other Application...".

This should open the file with gmplayer (MPlayer with a graphical user interface), and add an MPlayer entry to the pop-up menu.

The only problem with this is that MPlayer fails to open the file if its name happens to contain spaces. It issues an error message like this: "Failed to open file file:///home/zungbang/test%20clip.avi." The problem is rather obvious: the spaces are translated to %20, which is usual in URIs, but apparently MPlayer doesn't expect this.

The issue seems to be well known (see Debian bug report #471924 and the following Ubuntu Forums threads: Opening files with MPlayer and mplayer can't play file with space in file name). And the proposed solution is to replace the string gmplayer %U with gmplayer %F in /usr/share/applications/mplayer.desktop and/or ~/.local/share/applications/mplayer.desktop.

Well, I modified the first file and nothing happened, I then tried modifying the latter file, only to find out that there was no such file. Damn. But I did spot files named mplayer-usercustom.desktop and mplayer-usercreated.desktop. After examining their contents and comparing with the first file, I removed them, copied the first file to ~/.local/share/applications and restarted Nautilus. This did the trick. Hooray.

To make MPlayer the default player, so that it's launched directly by double-clicking the file in Nautilus:
  1. right-click a multimedia file, select "Properties"
  2. select the "Open With" tab
  3. mark the open circle next to "MPlayer"
  4. press "Close"

1 comment: