簡體   English   中英

本地文件uri中的GStreamer#符號

[英]GStreamer # symbol in uri of local file

當我嘗試在Linux機器上播放文件名中帶有“#”的本地文件時,它顯示:

Error: message about my installation of GStreamer missing plugin /var/tmp/portage/media-libs/gst-plugins-base-0.10.36-r1/work/gst-plugins-base-0.10.36/gst/playback/gstplaybasebin.c(1686): gen_source_element (): /GstPlayBin:player:
No URI handler for file

我用它來設置URI:

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

其中,filepath是MP3文件“ / home / me / untitled#1.mp3”的絕對路徑

是否有某種逃脫或解決方法?

filepath應使用URL引用。

使用urllib.parse.quote() (Python 3)或urllib.quote() (Python 2)

這就是我使用的(Python 3),它也應該在Windows上運行:

def file_to_uri(filename):
    filepath = os.path.abspath(filename) 
    drive, filepath = os.path.splitdrive(filepath)
    filepath = urllib.parse.quote(filepath.replace(os.sep, '/'))
    return 'file://%s%s' % (drive, filepath)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM