First I looked about for a nice C# wrapper, and for 1.1.x, there is only libvlcnet. A nice and nifty project that, allthough a bit too complex for my needs, but I tried it anyway.
They have a readymade VlcControl, just drag and drop, so that's what I did and hit Debug. And BAM vshost32.exe crashes, and it's really hard to debug something when it's the debugger who has crashed. (running it without debugger just makes it crash).
Well so I gave up instantly and decided to just make my own wrapper. I put in all the basic stuff and had a crude but working vlc clone. Then I came to the point where it was time to attach event handlers, and thats where I encountered the very same problem. Attaching events works fine, but as soon as an event is triggered, vshost32 crashes, even if the callback method is empty so it shouldn't be thread related, which was my first guess.
Vlc version 1.1.1 The luggage
Invokes:
Code: Select all
public delegate void EventCallbackDelegate(IntPtr userdata);
[DllImport("libvlc")]
public static extern IntPtr libvlc_media_player_event_manager(IntPtr player);
[DllImport("libvlc")]
public static extern int libvlc_event_attach(IntPtr p_event_manager, libvlc_event_type_t i_event_type,
EventCallbackDelegate f_callback, IntPtr userdata);
Code: Select all
internal enum libvlc_event_type_t
{
libvlc_MediaMetaChanged = 0,
libvlc_MediaSubItemAdded,
libvlc_MediaDurationChanged,
libvlc_MediaParsedChanged,
libvlc_MediaFreed,
libvlc_MediaStateChanged,
libvlc_MediaPlayerMediaChanged = 0x100,
libvlc_MediaPlayerNothingSpecial,
// and so on, you get the idea
}
Code: Select all
IntPtr instance, player;
private void Init()
{
string[] args = new[] {
"-I", "dummy", "--ignore-config",
@"--plugin-path=C:\Program Files (x86)\VideoLAN\VLC\plugins",
"--vout-filter=deinterlace", "--deinterlace-mode=blend"
};
instance = LibVlc.libvlc_new(args.Length, args);
IntPtr media = LibVlc.libvlc_media_new_path(instance, @"somefile");
IntPtr eventManager = LibVlc.libvlc_media_player_event_manager(player);
LibVlc.libvlc_event_attach(eventManager, LibVlc.libvlc_event_type_t.libvlc_MediaPlayerPaused, MediaPlayerPaused, IntPtr.Zero);
}
private void MediaPlayerPaused(IntPtr userdata)
{
//listBox1.Items.Add("Player paused");
}
I realise that it's hard for anyone to come with a magic answer, but any pointer would be appreciated, because I am completely lost right now.