Page 1 of 1

C# Wrapper declaration libvlc_media_player_set_hwnd

Posted: 12 Nov 2010 16:28
by LogainStark
Hello,

I am trying to use VLC player (1.1.4) in a C# Win Form Application

I have stopped using ActiveX version because I encountered many issues : Blue screen when disposing vlc object, some VLC options not available, etc... all of those issues are described in other topics of this forum,

So now I am trying to use a C# wrapper on the libvlc.dll :

many topics on this subject on VideoLan.org are outdated so I started from scratch and made my own DllImports commands from the doxygen documentation
(http://www.videolan.org/developers/vlc/doc/doxygen/html)

But now I am stuck with one of the most basic command :

libvlc_media_player_set_hwnd

which, still from the documentation should work with only 2 parameters : media_player object handle and a window handle

So I tried several syntaxes but this simple one should work:
[DllImport("libvlc")]
static extern void libvlc_media_player_set_hwnd(IntPtr vlcHandle, IntPtr windowHandle);

My problem is that when I compile my project with Visual Studio Express 2008, I get an error message basically saying it does not find this method inside the libvlc.dll, while my other calls to the imported methods seems at least to compile..

Does any one here know the correct and UP TO DATE syntax for this Dllimport command?

thanks in advance

Re: C# Wrapper declaration libvlc_media_player_set_hwnd

Posted: 13 Nov 2010 01:49
by XilasZ
it should work, i use this in my wrapper (fully updated to v1.1.4) :

Code: Select all

[DllImport("libvlc")] internal static extern void libvlc_media_player_set_hwnd(IntPtr p_mi, IntPtr drawable);

Re: C# Wrapper declaration libvlc_media_player_set_hwnd

Posted: 13 Nov 2010 09:44
by LogainStark
I know that it should work... :-(

I clearly miss something obvious, perhaps in my project declaration or in the way I include libvlc.dll...

Can you send me a concrete simple example, or can I send you mine?

Re: C# Wrapper declaration libvlc_media_player_set_hwnd

Posted: 14 Nov 2010 13:30
by XilasZ
Even if it's far from a simple example, you can take a look at my sources here : http://fritivi.git.sourceforge.net/git/ ... ivi;a=tree

Upload your project somewhere, i'll take a look.
libvlc.dll doesn't need to be added directly in the project as a reference or anything else, just put the dll in the same folder as your exe.

Re: C# Wrapper declaration libvlc_media_player_set_hwnd

Posted: 15 Nov 2010 10:06
by LogainStark
Thank you very much for your example :

I tried the VideoLan.Interop part from my office with a VisualStudio 2008 professional edition and Windows XP 32 bits and it worked fine....

As I still did not understood the difference with my declaration of the DllImport, I tried also my project and then "Miracle!", it worked fine also.... (even if the result is less complete on my version...)

There must be a small difference between the 2 Visual Studio editions or in the OS (at home I use Windows 7 64 bits)


Thank you again !