Satyr handles paths. There are some problems with
paths and (sigh) encondings. Of those, here are two:
there's no way to know in which encoding the filenames in a
filesystem are enconded (f.i., there's no way to ask the
filesystem), and even if that were possible, the filenames might
not even be enconded in that enconding. In these (still!)
transitioning times, lots and lots and shitloads of filesystems are
used in UTF-8 environments, but some filenames are still in old
ISO-8859-1 or whatever the system was using before.
Then comes QString. I'm taking a path from the
command line; this path is the location of the (right now only)
Collection for the player. I'm handling the command
line using KCmdLineOptions, which returns
QStrings. As we all know, QString, just
like the unicode type in Python, handles
all the data internally as Unicode, which is The Right Thing™. If
you really need the internal data, say as bytes, you can always
call the constData() method and be happy with it[1].
This would be the case for paths; you need the
bytes.
Then comes PyQt4. For some reason, which maybe I
will ask in the
pyqt devel ML[2], constData() is not available.
What to do? Well, that's what this post is about. What you're about
to read is hacky as it can be, but then it works. I might feel
dirty, but I can live with it. As long as I mark it as a utter/über
hack and promise to revert it once that's possible...
# path is a QString
qba= QByteArray ()
qba.append (path)
path= str (qba)
# now path is a list of bytes/string.
Even if this part of the bug is fixed, then
Phonon.MediaSource or
Phonon.MediaObject.play() fails when feeded that same
path with this message:
ERROR: backend MediaObject reached ErrorState after 1 . It seems a KioMediaStream will not help here, trying anyway.
or simply refusing to continue. Sure, in my case I should simply ignore the filename and inform the user what's going on, but sometimes you can't be so gentle.
[1] blah.
[2] but then it doesn't make much sense now since Phil wants to get rid of QString (for several reasons, which might most possibly include this one).