Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling VLC via c#

Tags:

c#

vlc

I am writing an application that will open vlc, add a file to its playlist, and play it. I am having a few issues on the last 2.

 AXVLC.VLCPlugin alxplugin1 = new AXVLC.VLCPlugin();

                alxplugin1.addTarget("C:\\test.avi", null, AXVLC.VLCPlaylistMode.VLCPlayListInsert, 0);
                alxplugin1.play();

This isn't working... Any ideas?

Thanks

like image 998
Dandrews Avatar asked Apr 06 '12 13:04

Dandrews


2 Answers

The newer version of VLC needs "file:///" in beginning of the file name. It should work if you add this. Please try the following and see if it solves your problem. use: alxplugin1.addTarget("file:///" + "C:\\test.avi", null, AXVLC.VLCPlaylistMode.VLCPlayL­istReplaceAndGo,0);

like image 110
Sblb Avatar answered Oct 10 '22 03:10

Sblb


C# can access VLC through it's COM layer. First thing to do is to register the axvlc.dll. Open a cmd window and type:

C:\Windows\System32\regsvr32.exe C:\Program Files (x86)\VideoLAN\VLC\axvlc.dll

You should receive a dialog confirming that your dll was registered successfully. Open VisualStudio and create a new WinForms project and add a reference to the COM VLC COM object. Go to the Form cs file

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
          public Form1()
          {
               InitializeComponent();

               AXVLC.VLCPlugin2Class p = new AXVLC.VLCPlugin2Class();
               p.addTarget("C:\\zk.m4a", null, VLCPlaylistMode.VLCPlayListInsert, 0);
               p.play();
           }
     }
 }

Note: The VLCPluginClass was deprecated, use VLCPlugin2Class

like image 42
Dan Busha Avatar answered Oct 10 '22 03:10

Dan Busha