Search code examples
c++qtlibvlc

libvlc path to file in libvlc_media_new_path


I'm writing my own music player on Win7 using libvlc. After some struggle getting it to work properly with Qt5.5 I could successfully run my code. It plays the desired files as expected. BUT:

It seems that only files that are located in the projects root directory are played. So whenever I want use a path to file that's located somewhere else it wouldn't work.

libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;

/* Load the VLC engine */
inst = libvlc_new (0, NULL);
qDebug() << "Instance: " << inst;

/* this is what does not work. The programme crashes with a segmentation fault */
//m = libvlc_media_new_path(inst, "D:/path/to/some/external/file");
//m = libvlc_media_new_path(inst, "C:/path/to/some/external/file");
//m = libvlc_media_new_path(inst, "D:\Path\to\some\external\file");
//m = libvlc_media_new_path(inst, "file:///C:/path/to/some/external/file");

/* this works if track.flac is in the project's root director */       
m = libvlc_media_new_path(inst, "track.flac");
qDebug() << "Item: " << m << " " <<  libvlc_media_get_mrl(m);

/* no problems here */
/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);
qDebug() << "Player: " << mp;

I tried files with and without whitespaces in their names so I don't think that's the cause. Would be great if you can help me out here.


Solution

  • Did you try "d:\\path\\to\\some\\external\\file"?