libvlc media player in C# (part 2)

I gave some simplified VLC media player code in part 1 to show how easy it was to do and how most wrapper libraries make a mountain out of a mole hill. In that entry, I briefly touched on using some classes to make it easier and safer to implement actual programs with this.

The first thing to do is write a wrapper for the exceptions, so that they are handled nicely in C#. For a program using the library, exceptions should be completely transparent and should be handled in the normal try/catch blocks without having to do anything like initialise them or check them.

Another thing to do is to move all of the initialisation functions into constructors and all of the release functions into destuctors or use the System.IDisposable interface.

Here is the code listing for the 4 classes used (VlcInstance, VlcMedia, VlcMediaPlayer and VlcException). Note that the first 3 of these are very similar and that the main difference is that the media player class has some extra functions for doing things like playing and pausing the content.

class VlcInstance : IDisposable
{
    internal IntPtr Handle;
 
    public VlcInstance(string[] args)
    {
        VlcException ex = new VlcException();
        Handle = LibVlc.libvlc_new(args.Length, args, ref ex.Ex);
        if (ex.IsRaised) throw ex;
    }
 
    public void Dispose()
    {
        LibVlc.libvlc_release(Handle);
    }
}
 
class VlcMedia : IDisposable
{
    internal IntPtr Handle;
 
    public VlcMedia(VlcInstance instance, string url)
    {
        VlcException ex = new VlcException();
        Handle = LibVlc.libvlc_media_new(instance.Handle, url, ref ex.Ex);
        if (ex.IsRaised) throw ex;
    }
 
    public void Dispose()
    {
        LibVlc.libvlc_media_release(Handle);
    }
}
 
class VlcMediaPlayer : IDisposable
{
    internal IntPtr Handle;
    private IntPtr drawable;
    private bool playing, paused;
 
    public VlcMediaPlayer(VlcMedia media)
    {
        VlcException ex = new VlcException();
        Handle = LibVlc.libvlc_media_player_new_from_media(media.Handle, ref ex.Ex);
        if (ex.IsRaised) throw ex;
    }
 
    public void Dispose()
    {
        LibVlc.libvlc_media_player_release(Handle);
    }
 
    public IntPtr Drawable
    {
        get
        {
            return drawable;
        }
        set
        {
            VlcException ex = new VlcException();
            LibVlc.libvlc_media_player_set_drawable(Handle, value, ref ex.Ex);
            if (ex.IsRaised) throw ex;
            drawable = value;
        }
    }
 
    public bool IsPlaying { get { return playing && !paused; } }
 
    public bool IsPaused { get { return playing && paused; } }
 
    public bool IsStopped { get { return !playing; } }
 
    public void Play()
    {
        VlcException ex = new VlcException();
        LibVlc.libvlc_media_player_play(Handle, ref ex.Ex);
        if (ex.IsRaised) throw ex;
 
        playing = true;
        paused = false;
    }
 
    public void Pause()
    {
        VlcException ex = new VlcException();
        LibVlc.libvlc_media_player_pause(Handle, ref ex.Ex);
        if (ex.IsRaised) throw ex;
 
        if (playing)
            paused ^= true;
    }
 
    public void Stop()
    {
        VlcException ex = new VlcException();
        LibVlc.libvlc_media_player_stop(Handle, ref ex.Ex);
        if (ex.IsRaised) throw ex;
 
        playing = false;
        paused = false;
    }
}
 
class VlcException : Exception
{
    internal libvlc_exception_t Ex;
 
    public VlcException() : base()
    {
        Ex = new libvlc_exception_t();
        LibVlc.libvlc_exception_init(ref Ex);
    }
 
    public bool IsRaised { get { return LibVlc.libvlc_exception_raised(ref Ex) != 0; } }
 
    public override string Message { get { return LibVlc.libvlc_exception_get_message(ref Ex); } }
}

Using these classes is even easier than before, can use proper exception handling (removed for brevity) and cleans up better at the end. In this example, I have added an OpenFileDialog, which is where the file is loaded.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace MyLibVLC
{
    public partial class Form1 : Form
    {
        VlcInstance instance;
        VlcMediaPlayer player;
 
        public Form1()
        {
            InitializeComponent();
 
            openFileDialog1.FileName = "";
            openFileDialog1.Filter = "MPEG|*.mpg|AVI|*.avi|All|*.*";
 
            string[] args = new string[] {
                "-I", "dummy", "--ignore-config",
                @"--plugin-path=C:\Program Files (x86)\VideoLAN\VLC\plugins",
                "--vout-filter=deinterlace", "--deinterlace-mode=blend"
            };
 
            instance = new VlcInstance(args);
            player = null;
        }
 
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            if(player != null) player.Dispose();
            instance.Dispose();
        }
 
        private void Open_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
                return;
 
            using (VlcMedia media = new VlcMedia(instance, openFileDialog1.FileName))
            {
                if (player != null) player.Dispose();
                player = new VlcMediaPlayer(media);
            }
 
            player.Drawable = panel1.Handle;
        }
 
        private void Play_Click(object sender, EventArgs e)
        {
            player.Play();
        }
 
        private void Pause_Click(object sender, EventArgs e)
        {
            player.Pause();
        }
 
        private void Stop_Click(object sender, EventArgs e)
        {
            player.Stop();
        }
    }
}

Update:

I have just corrected a minor bug (the wrong release function being called on the player handle) and uploaded the full Visual Studio 2005 project. You can download the full project here (or see 1.1.2 version below). It comes with the libvlc.dll and libvlccore.dll for VLC 1.0.1 in the bin\x86\Debug directory so if you have a version other than this, just overwrite those files.

Update for VLC 1.1.2:

You can now download the VLC 1.1.2 compatible version. There were some changes to the way libvlc handles exceptions that needed to be corrected. Other than that, there were a couple of minor function name changes.

Please use these posts as a starting point to use your own code though. These posts are intended to stop people from being reliant on the already existing, large, overcomplicated and quickly outdated libraries. They are not intended to be just another library for people to blindly use without understanding how it works. You can use this to learn how to write your own native interop code on a well designed library then adapt it for your own changes and keep it up to date with whichever version of VLC you want. This also means you never have to use the terrible code on pinvoke.net for other libraries, as you can write your own from the original documentation and it will almost always be better.

Tags: , ,

40 Responses to “libvlc media player in C# (part 2)”

  1. Charlie says:

    Thanks for the great info!
    Not sure if you could point me in the correct direction but I’m trying to hook into some media change events from the vlc event manager in C#, something like..

    LibVlc.libvlc_event_attach(eventManager, 5, new EventHandler(media_Change), void, ref ex.Ex);

    But I cant pass in an eventhandler, and I’m not sure how to create a callback that will be passed into the libvlc_event_attach method?

    anyway, thanks again for the great example.

  2. George Helyar says:

    I will look into this for you but for now I can say that if it is a function pointer in C (e.g. a void*), you can use a delegate in C# with little to no marshalling.

    The docs define the function as

    libvlc_event_attach (libvlc_event_manager_t *p_event_manager, libvlc_event_type_t i_event_type, libvlc_callback_t f_callback, void *user_data, libvlc_exception_t *p_e)

    which uses

    typedef void * libvlc_callback_t
  3. Prasad says:

    Thanks for lucid Explanation.

    I tried attaching a Callback event in the above sample but guess doing something wrong.

    Here is what i tried:

    1. Get a event manager object of media player.
    2. Creating Delegate from function pointer for callback event (libvlc_callback_t) – probably i’m wrong in this step only
    3. Attach the event manager object to listen to particular event type

    ——————VLC.cs————————-

    [DllImport("libvlc")]
    public static extern uint libvlc_event_attach(ref IntPtr p_event_manager,                                  uint i_event_type,
    libvlc_callback_t f_callback,
    IntPtr user_data,
    ref libvlc_exception_t p_e );
     
    [DllImport("libvlc")]
    public static extern IntPtr libvlc_media_player_event_manager(ref IntPtr player, ref libvlc_exception_t p_exception);
     
       [StructLayout(LayoutKind.Sequential)]
        public struct libvlc_event_t
        {
            libvlc_event_type_t type;
        }
     
        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        public delegate void libvlc_callback_t(ref libvlc_event_t vlc_event, IntPtr junk);
     
    enum libvlc_event_type_t
    {
    //all events
    }

    —————————————————-

    ———————-MyVLC.cs————————

    class EventManager 
        {
            internal IntPtr Handle;
            VlcException ex;
     
            public EventManager(VlcMedia media, VlcException ex)
            {
                Handle = LibVlc.libvlc_media_player_event_manager(ref Handle, ref ex.Ex);
                this.ex = ex;
            }
     
            public uint AttachEvent(libvlc_event_type_t event_type)
            {
              return  LibVlc.libvlc_event_attach(ref Handle, (uint)event_type, CallBackEvent, IntPtr.Zero, ref ex.Ex);
     
            }
     
            static void CallBackEvent(ref libvlc_event_t vlc_event, IntPtr junk)
            {
     
            }
        }

    ————————————————–

    Any solution to this would be of great help.

    Thanks
    Prasad

  4. George Helyar says:

    On the blog you can use <pre lang=”csharp”>…</pre> (type this yourself to avoid copy/paste conversions) for code blocks and quite a few languages are supported, thanks to wp-syntax.

    libvlc_event_manager_t* libvlc_media_player_event_manager(libvlc_media_player_t*, libvlc_exception_t*)

    As you can see, it takes a pointer to a media player. In this case, it is a VlcMediaPlayer.Handle, not a reference to the handle that you get in the return value.

    You probably never want to use ref and an IntPtr at the same time. Ref gets a pointer (see references in C++) to the object so when you ref an IntPtr, you are getting a pointer to a pointer. Ref is used for exceptions here because libvlc gives us the struct for them but IntPtr is used everywhere else because libvlc stores them internally and just gives us a pointer.

    You should also follow my template for the exceptions, which probably would have caught this for you.

    As for C callbacks invoked from C#, here is a working example.

    C:

    int callback_test(int (*func)(int a, int b), int a, int b);

    C#:

    [DllImport("mydll")]
    static extern int callback_test(CallBackDelegate mycallback, int a, int b);
     
    public delegate int CallBackDelegate(int a, int b);
     
    public static int CallBackFunction(int a, int b)
    {
        return a * b;
    }
     
    // Usage (returns 15):
    callback_test(new CallBackDelegate(CallBackFunction), 5, 3);

    From this, I would define the two as:

    [DllImport("libvlc")]
    public static extern IntPtr libvlc_media_player_event_manager(IntPtr player, ref libvlc_exception_t ex)
     
    [DllImport("libvlc")]
    public static extern void libvlc_event_attach(IntPtr eventManager, uint i_event_type,
      CallBackDelegate f_callback, IntPtr user_data, ref libvlc_exception_t ex)
     
    public delegate void CallBackDelegate(IntPtr userData);

    You may be able to use ref object for user_data, so that it is easier to use back in C# when the callback is called, but I have not tested it. You can obviously rename CallBackDelegate to whatever you want.

    You should probably also marshal libvlc_event_detach and any release function for event_manager if there is one. These things will not clean themselves up.

  5. yun says:

    Thankyou for your vlc information.

    How can i get your C# all original code(part 1 sample code)

  6. George Helyar says:

    Hi Yun,

    All the code is posted in the entries. You just need to copy and paste. Ideally you want the first code block from part 1 and both code blocks from part 2.

    The only thing missing is the form code generated by Visual Studio but you can reproduce that just by dragging a couple of buttons and a panel on. In the example from part 2, the only thing which uses a name is “panel1″. Other than that they can be any 3 buttons, just link their “Click” event to the “Play_Click” function and the same with Stop and Pause if you want those.

    There’s also an OpenFileDialog called openFileDialog1 in the example from part 2, which has a corresponding “Open” button that fires “Open_Click”.

    Form1_FormClosed is also an event handler that you should assign to your form’s FormClosed event.

    I have updated the entry to link to the source code for this project.

  7. Denis says:

    First off all, thank you for this code sample, it was a life saver :) I have one question tho. How to show thrown exceptions in MessageBox ? In code 1 you have Raised function but here in sample 2 i haven’t see any functions or controls to show exception messeges.

    Thank you.

  8. George Helyar says:

    At the moment, they would just crash the application or cause Visual Studio’s debugger to run. This is far from ideal but is better than just ignoring them and continuing anyway, which is what happens if you try to run unmanaged code without checking for the exceptions.

    I have never managed to actually throw any exceptions when using this code anyway and, as I said, exception handling has been removed for brevity.

    The process of showing exceptions in message boxes is very easy and the same in just about every Windows application.

    try
    {
      // your code here
    }
    catch(Exception error)
    {
      MessageBox.Show(error.ToString(), error.Message);
    }

    This will show a message box with the stack trace as its text and the error message as its caption. As with all try/catch blocks you should wrap it around as much as possible, not single calls. When the exception is raised it will jump out of the try block and into the catch block, ignoring anything after that line. It will then continue underneath the catch block.

  9. shirley says:

    hi, thanks for code, It helped me.
    My problem now is how to record video from a webcam in C#?
    please help me, is life or death .Thanks

  10. George Helyar says:

    shirley:
    Please do not spam. On WordPress blogs, the first comment from a particular author needs approval before it shows up.

    This code has nothing to do with recording video from a webcam at all. These two entries are all about getting people to write their own code to integrate with the VLC media player library (libvlc) rather than relying on some of the poorly written libraries out there and shows them how simple it is to achieve what they want.

    If you want to record video from a webcam into C#, I suggest googling for “C# webcam”. There are plenty of results. If you need to marshal unmanaged dlls into your C# code, you can use some of the guidelines here but that is as close as this gets to what you need. You can also try looking on MSDN for vfw and winmm.

    VLC allows you to “Capture Device” but I don’t know if libvlc offers this functionality and even if it does, there are far better ways of doing it directly.

  11. Tackmar says:

    Hello George,

    I love your wrapper. Very easy!!
    But does anyone know how to do the adjustments (brightness/hue etc) during playback. I’ve been trying to figure out if its possible, and I noticed this blog had info on callback routines.

    Thanks for your help.

  12. George Helyar says:

    According to a developer post here, you can change the brightness, hue etc by supplying the text argument to libvlc_new (the argument passed to new VlcInstance() in the example wrapper above) when you create the instance but I could not find how to change it on an existing instance.

  13. Tackmar says:

    Hi George

    Thanks for the reply. How can I tell the playstate, especially when the media has ended (stopped)?

    I’ve tried using the getposition function but that gives values ranging between 0.94 – .97 when playback has stopped.

    My other question is when playing DVD’s how can I send the command to go back to Menu, or Next/previous chapters?

    I feel like I’m soooo close. Thanks for your help.

  14. George Helyar says:

    When it comes to the advanced features of libvlc, I am no expert. This blog entry is simply intended to show people that they can easily use the library directly rather than relying on a 3rd party wrapper that usually doesn’t work properly and is harder to use than the library itself.

    From the documentation on libvlc_media_player, libvlc_media_player_get_state seems to be what you want regarding states. Example states (libvlc_state_t) include libvlc_Buffering and libvlc_Ended.

    From a quick search it seems that __var_Set is what you want to navigate the DVD menus programmatically but I could not find any examples of this.

  15. rarao says:

    Hi Helyar

    I have been using VLC under C# for quite sometime now. I am facing one problem regarding multiple instances of VLC (using libvlc.dll & libvlccore.dll, version 1.0.2 of VLC) in a single application.

    I was trying with 6 instances of VLC, under windows XP, Windows Vista and Windows 7. I found that application under XP is very stable (for atleast 1.5 hrs) but under Vista and Windows 7, it crashes within first few minutes.

    I have seen people reporting this problem under the VideoLAN forum, but no solutions so far….

    Do u have any suggestions on this behaviour?

    Thanks for your help in advance.

    —-Rao

  16. tackmar says:

    Hello Again George,

    Using your wrapper I’m getting an error when using a 64bit Win Vista system. Or any 64 bit OS. The message is
    “System.BadImageFormatException was unhandled”
    Tracing it, it throws the error when trying to make the Libvlc call (like to create the exception/start new instance)

    HELP!!!! Please

  17. George Helyar says:

    Hi tackmar, please read paragraph 4 of part 1. “The first thing to note …”

  18. Andrew says:

    Hi,

    I’ve just downloaded your project and tried running it. When I try a command window opens displaying: -

    ‘The command line options couldn’t be loaded, check that they are valid. – Press the RETURN key to continue…’

    What have I missed?

    Thank You & Regards,

    Andrew

  19. George Helyar says:

    This may be an incompatibility with your version of VLC or libvlc. You must have VLC installed on the system and provide an accurate plugin path etc. The plugin path will vary depending on where you installed VLC to and seems to be the most important command line argument.

  20. Andrew says:

    Hi,

    Sorry, I found the problem and it’s now working.

    Sorry to bother you :-)

  21. Andrew says:

    George,

    Thank you for your previous reply.

    I’ve got the following code: -

    VlcMedia media = new VlcMedia(instance, “..\\..\\Movies\\Wildlife.wmv”);
    vlcplayer = new VlcMediaPlayer(media);
    vlcplayer.Drawable = pnlVLC.Handle;
    vlcplayer.Play();

    I wonder if you know how to acheive the following?

    1) Play all files in a directory and repeat once the last file has been played?

    2) Play all files in a directory from a network location, if not the same as 1?

    3) Stream media from a central location, again repeating once last file has been played?

    I appreciate it’s a lot to ask, but I can’t seem to find any examples of doing this with VLC in C# on the web.

    Your code and post has so far been a life saver!!

    Best Regards,

    Andrew

  22. Ole jak says:

    So… I try to play live FLV video stream (Vhich I creat with other instance of VLC (real vlc.exe=)) with your app… but it plays something like 30 seconds and stups then it waits something like a minut (like it were buffering) and starts playing ferther. like for a minut. then freases again… What can be a problem here? How can I transcode incoming (or selected by user) Video Stream to something lighter for decoding?

  23. Ama says:

    Hi,

    Thanks for this. This is really great.
    Have you played with the volume/audio part? I kept having problems with those.
    I always encounter the AccessViolationException. Help! Thanks

  24. Rao says:

    I am using 1.0.2 golden eye version of libvlc
    I am using VS 2008 C# application
    I used the switch “–deinterlace-mode=blend” as you had suggested , but the entire IDE is hanging in design time itself and displays the DOS command window with a hint that the “Command line options cannot be loaded…” . In fact i have to close the VS 2008 IDE in task manager and when i open that project again, i get the same problem.

    When i comment this switch there is no issues?

    Below is the code i used…

    static String myarg0 = “-I”;
    static String myarg1 = “dummy”;
    static String myarg2 = “–plugin-path=.\\plugins”;
    static String myarg3 = “–ignore-config”;
    static String myarg4 = “–vout-filter=deinterlace”;
    static String myarg5 = “–deinterlace-mode=blend”;
    static String myarg6 = “–aspect-ratio=4:3″;

    static String[] myargs = { myarg0, myarg1, myarg3, myarg4,myarg5, myarg6};

    public static VideoLanClient vlc = new VideoLanClient(“c:\\program files\\videolan\\vlc”, myargs);

  25. George Helyar says:

    You must use the dlls (libvlc.dll and libvlccore.dll) for the correct version of VLC. The ones shipped with this project are now outdated.

    Also, some of the newer versions of VLC may change the deinterlace options (certainly in 1.1.0 and above, maybe earlier, there is an “automatic” option in the GUI).

    More likely the problem is your plugin-path argument, where “.\plugins” would be relative to your current working directory. Unless you have changed the working directory earlier then this would be the same place as your .net executable, not the VLC executable. If you are going to use an absolute path for “VideoLanClient” use an absolute path for the plugin-path argument too. You should definitely at least check that your plugin-path is pointing to exactly the right directory, as this is by far the most common cause of this error. The fact that it only appears on deinterlacing may be because it cannot find the deinterlace plugin if the plugin directory is not correct.

  26. cslee says:

    what is the correct version to use? I encounter the similar problem as Rao

  27. claudiofrk says:

    Hi All,
    Anyone know how to re-stream video for MMSH format?
    I’m trying to re-stream in Windows Media Player (“mms: / / 192.168.0.24:8888″) but does not work.
    Does anyone have a solution?

    ...
    string[] args = new string[] {
    "-I", "dummy", "--ignore-config",
    @"--plugin-path=C:\Arquivos de programas\VideoLAN\VLC\plugins",
    "--vout-filter=deinterlace", "--deinterlace-mode=blend",
    ":sout=#transcode{vcodec=WMV2,vb=800,scale=1,acodec=wma2,ab=128,channels=2,samplerate=44100}",":std{access=mmsh,mux=asfh,dst=0.0.0.0:8888}"
    };

    instance = LibVlc.libvlc_new(args.Length, args, ref ex);
    Raise(ref ex);

    IntPtr media = LibVlc.libvlc_media_new(instance, @"http://192.168.1.33:8118/ALTOREDIR:149995", ref ex);
    Raise(ref ex);
    ...

    Urgent!!!!
    Thank“s

  28. seb.49 says:

    Hello,

    I cannot see any video. Wich version of VLC do you recommand ?

    Thanks

  29. George Helyar says:

    I have updated the project for compatibility with VLC 1.1.2. There were some changes from 1.0 to 1.1.

    Please see the footnote at the bottom of the post.

    Judging by the 1.2 source and docs this should work with 1.2.0 in when released but does not seem to play on the current nightly build.

  30. seb.49 says:

    Hello,

    I download the version for 1.1.2 but it’s not good, always in VlcInstance(string[] args) Handle value is always 0.

    I add this in LibVlc Core region ” [DllImport("libvlc")]
    public static extern string libvlc_get_version();”
    and the version is 1.1.2 The Luggage.

  31. George Helyar says:

    You must use it with the correct version of VLC. If you use it with the wrong version (1.0.x, 1.2.x, possibly even 1.1.0) it will fail to create an instance.

    The DLLs that I packaged in there are only for VLC 1.1.2

    If you have some other version of 1.1.x, try just using your own libvlc.dll and libvlccore.dll from your installation of VLC so that it matches correctly. If you have 1.0.x, use the old files.

    These have been tested against the actual releases. Some nightly builds may not work anyway.

    All of these require you to have VLC installed on the system, and your “–plugin-path” in “args” must point to the plugins directory for the correct version of VLC. This is the same with any library that uses libvlc, because almost all of VLC is just in the plugins.

    Also, make sure your plugin path is absolutely correct. If you use a 32bit version of windows, for example, it will be different (I run 64 bit, so my 32 bit program files is in “Program Files (x86)”). It will also be different if you don’t use an English version of Windows, etc. This is all up to you to check.

    Like I said though, these posts are to free you from having to use other peoples libraries and to teach you how to make your own. If it doesn’t work for you, make your own. You shouldn’t be dependant on mine because I will *not* support it in the future.

  32. seb.49 says:

    Thank you, it’s exactly my problem, I have VLC 0.9 install on my computer so, the plugins are not the good

  33. korkos says:

    Hi George,

    I’ve download 1.1.2 and I have a question, is this version compatible with .flv? I can use it without any problem with .avi but it is not working with flv

  34. George Helyar says:

    If you’re talking about my particular example GUI here, it uses “MPEG, AVI|*.mpg;*.avi|All|*.*” for the open dialogue, so you would select .flv from the “All” dropdown.

    If you’re actually talking about playback, this is something you will have to discuss with the VLC community and/or developers.

    All I am doing here is showing how easy it is to use the freely available libvlc documentation to write your own interop code, so that you can avoid using a bloated, unreliable library written by someone else.

  35. e-tobi says:

    George – Thanks a lot! This helped me a lot to get started with VLC.

    And it nearly works out of the box with Mono + GTK# + Linux. All I needed to add was:

    [DllImport("libvlc")]
    public static extern void libvlc_media_player_set_xwindow(IntPtr player, IntPtr drawable);
            LibVlc.libvlc_media_player_set_xwindow(Handle, value);

    and to VlcMediaPlayer:

    public IntPtr XWindowDrawable
    {
        get
        {
             return drawable;
        }
        set
        {
            LibVlc.libvlc_media_player_set_xwindow(Handle, value);
            drawable = value;
         }
     }
  36. George Helyar says:

    In that case, you should be able to just change it to something like this:

    set
    {
        if (Environment.OSVersion.Platform == PlatformID.Unix)
            LibVlc.libvlc_media_player_set_xwindow(Handle, value);
        else
            LibVlc.libvlc_media_player_set_hwnd(Handle, value);
        drawable = value;
    }

    However, beware that the documentation uses the following definition for xwindow:

    libvlc_media_player_set_xwindow (libvlc_media_player_t *p_mi, uint32_t drawable)

    This means that the definition should really use “uint drawable” rather than “IntPtr drawable”.

    This means it is using a 32 bit integer for X, but a pointer for Windows. If libvlc worked on 64 bit, this would break 64 bit compatibility.

  37. Afnan says:

    I got an error while initializaing the VLC instance
    string[] args = new string[] {
    “-I”, “dummy”, “–ignore-config”,
    @”–plugin-path=.\\plugins”,
    “–vout-filter=deinterlace”, “–deinterlace-mode=blend”
    };
    public VlcInstance(string[] args)
    {
    VlcException ex = new VlcException();
    Handle = LibVlc.libvlc_new(args.Length, args, ref ex.Ex);
    ===>>> if (ex.IsRaised) throw ex; ///Initialization Fails
    }

  38. George Helyar says:

    Check your plugins path (“.\\plugins” is probably wrong) and that you have the correct version of VLC and the two DLLs for that exact version. If either of these are incorrect, it won’t initialise.

  39. Afnan says:

    Which VLC version it requires ????

  40. George Helyar says:

    It is clearly labelled throughout the blog. The downloads even have the version of libvlc they were compiled against in their name.

    If you don’t know how to read, don’t know how to use a DLL, don’t know what an API is, etc then give up now. I will not spoon feed idiots.

Leave a Reply