vlclibvlc

Why does my code crash when libvlc_media_new_path() is called?


after several days of trying myself to solve my problem I would like to kindly ask for your help:

I am trying to make the libvlc / SDL 2.0 tutorial working.

I am coding in Visual Studio 2022 in x86 C++ Console. I have linked the libvlc library path and include path and have added the libvlc.lib file in my project linker settings.

The program compiles without error and crashes when libvlc_media_new_path is called. You see all different formats of path I have used in my minimal reproducible example below:

My sources: I downloaded the vlc master from Github to get the headers / include directory. I downloaded the vlc-3.0.17.4-win32 release and from there took the libvlc.dll. From the libvlc.dll I created the lib file following a visual studio command prompt procedure.

What i noticed is that the function libvlc_media_new_path() only takes the path as an argument now. All examples i find in the internet are with the libvlc instance AND the path as arguments.

Thank you so much for your help!

#include <stdlib.h>
#include "vlc/vlc.h"

int main(int argc, char* argv[]) {

    libvlc_instance_t* libvlc;
    libvlc_media_t* m;
    libvlc_media_player_t* mp;
    
    libvlc = libvlc_new(0, NULL);

    if (NULL == libvlc) {
        printf("LibVLC initialization failure.\n");
        return EXIT_FAILURE;
    }
   
    m = libvlc_media_new_path("/1.mp4");

    //m = libvlc_media_new_path("C:\\Programmieren\\PACA\\1.mp4");
    //m = libvlc_media_new_path("C:/Programmieren/PACA/1.mp4");
    //m = libvlc_media_new_path("C://Programmieren//PACA//1.mp4");
    //m = libvlc_media_new_path("C:\Programmieren\PACA\1.mp4");
    //m = libvlc_media_new_path("file:///C:/Programmieren/PACA/1.mp4");
    
    
    mp = libvlc_media_player_new_from_media(libvlc, m);
   

    return 0;
}

Solution

  • If you go to Github and click on the Tags link, you can get the headers for version 3.0.17.4. In there you will see that libvlc_media_new_path takes an instance as an argument.

    The other option would be to get or build the 3.0.18 DLL.