9

I added the VLC plugin from COM Component, dragged it to my form, added two buttons to the form ("Play" and "Stop"), and wrote the following code:

private void Form1_Load(object sender, EventArgs e)
{
    axVLC.AutoPlay = false;
    axVLC.playlist.add(@"C:\Users\Hanif\Documents\Visual Studio 2010\Projects\Education Visualization\Vlc\Resources\Video1.wmv");
}

private void btnPlay_Click(object sender, EventArgs e)
{
    axVLC.playlist.play();
}

private void btnStop_Click(object sender, EventArgs e)
{
    axVLC.playlist.stop();
}

But when I click on "Play", nothing happens.

What am I doing wrong?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
HanifCs
  • 119
  • 3
  • 9
  • related: [Controlling VLC via c#](http://stackoverflow.com/questions/10043922/controlling-vlc-via-c-sharp) – metadings Apr 18 '14 at 17:03
  • Breaking on thrown exceptions is enabled? x32 build with x32 ActiveX component? ActiveX control is sized correctly? Any audio coming out? – Brannon May 07 '14 at 12:55

3 Answers3

16

Is the VLC plugin of type AxAXVLC.AxVLCPlugin2? If yes, then try these:

1) try playing video of other formats, e.g. .avi, .mkv, etc.

2) try adding file:/// in the beginning of URI:

@"file:///C:\Users\Hanif\Documents\Visual Studio 2010\Projects\Education Visualization\Vlc\Resources\Video1.wmv"

3) try adding 2 more arguments in the add command:

axVLC.playlist.add(@"C:\Users\Hanif\Documents\Visual Studio 2010\Projects\Education Visualization\Vlc\Resources\Video1.wmv", null, null);
Andrew T.
  • 4,701
  • 8
  • 43
  • 62
Bhaskar
  • 1,028
  • 12
  • 16
  • I have been looking for this solution for eons! Your answer is the only one that worked! I can't express my gratitude enough for your help! GOD BLESS YOU! – PiggyChu001 Mar 05 '20 at 07:24
1

Playing a local file works only if its path is preceded by "file:///", not otherwise. Discovered this after much fight. Here is the code:

string f = @"file:///D:\abc.mp4";
string f2 = @"file:///D:\def.avi";
int i = VLCPlayer.playlist.add(f);
int j = VLCPlayer.playlist.add(f2);

VLCPlayer.playlist.playItem(j);  // to play def.avi
//VLCPlayer.playlist.play();  // to play abc.mp4
0

Try this:

private void btnPlay_Click(object sender, EventArgs e)
{
    axVLC.playlist.playNext();
}
fabian
  • 6
  • 2