Search code examples
c#vlclibvlc

VLC on WindowForm


Im using VLC on Windows Form, coding in C# under VS 2017. I installed the 4 plugins through nuGet, added vlcControl1 to the form, set the vlcLibDirectory and, on form loads, I wrote:

vlcControl1.SetMedia(curFolder + @"\media\1.mp4");
vlcControl1.Play();

Even if I have no error, no file is displayed. The path to file is ok, but I don't know if the way to add it is right.


Solution

  • You need to provide the full MRL which requires the file:/// prefix in this case.

    vlcControl1.SetMedia("file:///" + curFolder + @"\media\1.mp4");
    

    Or you could just convert to a FileInfo object instead:

    vlcControl1.SetMedia(new FileInfo(curFolder + @"\media\1.mp4"));
    vlcControl1.Play();
    

    You could also just overload the play() call:

    vlcControl1.Play(new FileInfo(curFolder + @"\media\1.mp4"));
    

    Also: if you're using Win Forms you only need 3 plugins, you can exclude Vlc.DotNet.Wpf