VLC Filename convert to file:// URL

Passing a filename with spaces in it causes some issues
on WinXP/2003, this patch converts all filenames to valid
URLs (which is the preferred way to reference media in VLC).

Specifically;

* The file path is prepended with file://
* backslashes in filenames are converted to forward slashes in URLs
* Spaces are converted to %20
This commit is contained in:
Mark Liversedge
2011-11-27 15:03:31 +00:00
parent fc08878725
commit e7a57ed957

View File

@@ -160,8 +160,11 @@ void VideoWindow::mediaSelected(QString filename)
if (filename.endsWith("/DVD") || (filename != "" && QFile(filename).exists())) {
QString fileURL = "file://" + filename.replace(" ","%20").replace("\\", "/");
//qDebug()<<"file url="<<fileURL;
/* open media */
m = libvlc_media_new_path(inst, filename.endsWith("/DVD") ? "dvd://" : filename.toLatin1());
m = libvlc_media_new_path(inst, filename.endsWith("/DVD") ? "dvd://" : fileURL.toLatin1());
/* set the media to playback */
if (m) libvlc_media_player_set_media (mp, m);