GNOME Bugzilla – Bug 673565
[playbin2] File URI containing % is not played
Last modified: 2012-04-06 11:28:04 UTC
It is not possible to play a file containing % character... self.player = gst.element_factory_make('playbin2', 'player') fakesink = gst.element_factory_make('fakesink', 'fakesink') self.player.set_property('video-sink', fakesink) self.player.set_property('uri', 'file:///home/xxx/100%.flac') self.player.set_state(gst.STATE_PLAYING) Player does not start. I've filed the bug under "gst-python" category, although I'm not quite sure it is related to python bindings... but: - in my own code, written in python, I can't play this file. - decibel-audio-player, written in python, can't play this file. - banshee, written in C#, can play this file.
That's probably because Python handles the % character in a special way (it's used as a placeholder for formatting strings). URIs also are not allowed to contain %, you have to escape that too. Use whatever Python provides to escape URIs or generate URIs from filenames. GLib has g_filename_to_uri() for this for example.
Thank you. I've tried this and it works fine: from urllib import pathname2url self.player.set_property('uri', 'file://' + pathname2url(filename)) I don't know if this is the better way to do it (URL vs URI), but it seems that g_filename_to_uri has no python binding...