views:

300

answers:

2

Dear all,

I am trying to play some audio files with the CLI example on this site:

http://pygstdocs.berlios.de/pygst-tutorial/playbin.html http://pygstdocs.berlios.de/pygst-tutorial/playbin.html

I am on windows and it is giving error while reading the file. I specified the following path:

$ python cliplayer.py C:\\voice.mp3

0:00:00.125000000  3788   009DA010 ERROR                basesrc
gstbasesrc.c:2834:gst_base_src_activate_pull:<source> Failed to start in
pull mode
Error: Could not open resource for reading.
..\..\..\Source\gst-plugins-base\ext\gio\gstgiosrc.c(324):
gst_gio_src_get_stream ():
/GstPlayBin2:player/GstURIDecodeBin:uridecodebin0/GstGioSrc:source:
Could not open location file:///C:/file:/C:/voice.mp3 for reading: Error
opening file: Invalid argument

How should I specify the file path on windows??

Also, is there anything special I need to do in this line of code?

self.player.set_property("uri", "file://" + filepath)

Thank you!

+6  A: 

As you may have suspected, this code is rather badly written:

for filepath in sys.argv[1:]:
    # ...
    self.player.set_property("uri", "file://" + filepath)

Use something like this:

'file:' + urllib.pathname2url(filepath)

and (in the command line) specify the file path in normal Windows notation, e.g. C:\a\b.mp3.

Johannes Sasongko
urllib.pathname2url is a good suggestion... I haven't tried it but looks like it will work... btw there is another method filename_to_uri... didn't check what it does, but should convert the path to uri... . on the other hand, file:/// (triple slashes) fixed the issue for me on Windows.
cppb
+1  A: 

Did you notice the actual path you've got is file:///C:/file:/C:/voice.mp3?

The correct path should be: file:///C:/path/to/voice.mp3.

Tobu
yes. The key was file/// (notice the triple slashes!)
cppb