0

I'm trying to understand what song names can I use in my gstreamer python based audioplayer. Can't find any docs about it. For example song with name test%.mp3 produce the error:

Error: [<GError at 0x7f8a8c001620>, 'gstgiosrc.c(324): gst_gio_src_get_stream (): /GstPlayBin:playbin0/GstGioSrc:source:\nCould not open location file:///home/austinnikov/work/daemon_player/program_root/test%.mp3 for reading: Operation not supported'], 

Songs without % are played. And of cause I have test%.mp3 on the hard drive in that directory.

Alexey
  • 1,366
  • 1
  • 13
  • 33

2 Answers2

1

See the following SO answer:[Solved]gstreamer uri format on windows
specifically the 'file:' + urllib.pathname2url(filepath) part.
While this does not answer your more general question, it does permit you to play files which include certain characters like %

Community
  • 1
  • 1
Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60
0

Rolf's answer is great, but I wanted to add that if your songs_names are in unicode as mine then pathname2url will fail with KeyError. So I did it in slightly another way, note also Convert a filename to a file:// URL. This function is a part of Player class. Player instance has player variable self.player = gst.element_factory_make("playbin"):

def set_song(self, song_name):
    song_name = song_name.encode('utf8')
    path = urlparse.urljoin("file://", urllib.pathname2url(song_name))
    path = path.decode('utf8')
    self.player.set_property("uri", path))

And now I'm pretty happy cause my song names can be in unicode and contain any weird symbols.

Community
  • 1
  • 1
Alexey
  • 1,366
  • 1
  • 13
  • 33