Controlling VLC via c#

独自空忆成欢 提交于 2019-12-28 13:57:07

问题


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


回答1:


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);




回答2:


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



来源:https://stackoverflow.com/questions/10043922/controlling-vlc-via-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!