Media path is getting the application path inserted in front

This forum is about all development around libVLC.
Marc Kupper
New Cone
New Cone
Posts: 8
Joined: 27 Sep 2013 05:43
VLC version: 3.0.7.1
Operating System: Windows

Media path is getting the application path inserted in front

Postby Marc Kupper » 30 Sep 2013 09:51

I'm experimenting with LibVLC 2.1.0. I want to play a video that's in "dvd:///F:" It's failing with the error being that the path to the media I want to play is getting the current directory inserted in front of it. I've created a test app that shows just the failure point.

Code: Select all

int main(int argc, char **argv) { char * szMedia; libvlc_instance_t * vlcInstance; libvlc_media_t * vlcMedia; const char * cszMrl; szMedia = "dvd:///F:"; argv++; if (*argv) szMedia = *argv; vlcInstance = libvlc_new(0, NULL); if (vlcInstance != NULL) { vlcMedia = libvlc_media_new_path (vlcInstance, szMedia); if (vlcMedia != NULL) { cszMrl = libvlc_media_get_mrl (vlcMedia); if (cszMrl != NULL) printf ("media resource locator: %s\n", cszMrl); else fprintf(stderr, "Error, libvlc_media_get_mrl() returns NULL: %s\n", libvlc_errmsg ()); libvlc_media_release (vlcMedia); } else { fprintf(stderr, "Error, libvlc_media_new_path() failed: %s\n", libvlc_errmsg ()); } libvlc_release (vlcInstance); vlcInstance = NULL; } else { fprintf(stderr, "Error, libvlc_new() failed: %s\n", libvlc_errmsg ()); } return 0; }
The output from that program is "media resource locator: file:///C:/tmp/dvd%3A%2F%2F%2FF%3A"

"file:///C:/tmp/" is the current directory. If I 'cd' somewhere else then the "file:///C:/tmp/" part changes to whatever directory I'm in. Why is the current directory getting inserted like this?

On the theory I was dealing with compiler weirdness I made the media name configurable and have that in the code above. If I run "test-vlclib test" then the output is: "media resource locator: file:///C:/tmp/test"

I have VLC 2.1.0 installed and am I'm compiling with Visual Studio 2010 Express. It's running on Windows Vista.

Marc

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Media path is getting the application path inserted in f

Postby sherington » 30 Sep 2013 09:59

Did you try libvlc_media_new_location() ?

Marc Kupper
New Cone
New Cone
Posts: 8
Joined: 27 Sep 2013 05:43
VLC version: 3.0.7.1
Operating System: Windows

Re: Media path is getting the application path inserted in f

Postby Marc Kupper » 30 Sep 2013 18:50

Did you try libvlc_media_new_location() ?
Not yet - I got the test application I posted above to work by downgrading VLC from 2.1.0 to 2.0.8. I also ran the the same test application on a Windows 7 machine and had the same results. With VLC 2.0.7 the MRL returned is "dvd:///F:." I updated VLC on the win7 to 2.1.0 and the MRL is reported as "file:///Z:/test-LibVLC/dvd%3A%2F%2F%2FF%3A"

I don't know if it's a bug with VLC 2.1.0 or an intended behavioral change. I'll test with libvlc_media_new_location().

Marc

Marc Kupper
New Cone
New Cone
Posts: 8
Joined: 27 Sep 2013 05:43
VLC version: 3.0.7.1
Operating System: Windows

Re: Media path is getting the application path inserted in f

Postby Marc Kupper » 30 Sep 2013 19:27

libvlc_media_new_location() works fine and the MRL gets set to "dvd:///F:" Thank you.

It appears I got caught by a "gotcha" behavioral change with libvlc_media_new_path() where starting with VLC 2.1.0 it forces prefixing the string you pass to it with the current directory. It used to be that media_new_path() inspected the string and if it was an absolute path it would use it otherwise it would prefix.

At present if you do a "check for updates" from VLC 2.0.8 or older it brings people up to VLC 2.0.8 meaning not many people are on VLC 2.1.0 yet. It'll be interesting to see if people have been using libvlc_media_new_path() with an absolute path. For example, the LibVLC_Tutorial article offers a sample application that uses

Code: Select all

libvlc_media_new_path (inst, "http://mycool.movie.com/test.mov");
Installing VLC 2.1.0 breaks that sample code and the resulting MRL is "file:///C:/current-directory/http%3A%2F%2Fmycool.movie.com%2Ftest.mov"

Marc

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Media path is getting the application path inserted in f

Postby Rémi Denis-Courmont » 30 Sep 2013 21:53

I think the official Doxygen documentation is clear about the fact that ..._location() takes a URL and ..._path() a file path - and the current wording is three years old.

Certainly a lot of LibVLC samples are badly written. Many of them convey useless cargo cult, and the worst ones are just plain wrong. You should not copy sample code from random places, and this is not just about LibVLC.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 26 guests