ActiveX VLC Player events are not working ActiveX VLC Player events are not working wpf wpf

ActiveX VLC Player events are not working


I don't think you are doing anything wrong. It seems; those events are not implemented (or unimplemented) for some reason (even in the latest version of the activeX). I've read that those events are either too buggy or not firing at all in some browser plugin versions too.

However, it still has 3 useful and working events you can count on.
Events Firing: playEvent, pauseEvent and stopEvent
Events Not Firing: all events starting with MediaPlayer...

Anyway, code below works with the events I mentioned:

    AxVLCPlugin vlc;    public MainWindow()    {        InitializeComponent();        vlc = new AxVLCPlugin();        windowsFormsHost1.Child = vlc;        vlc.pauseEvent += new EventHandler(vlc_pauseEvent);        vlc.playEvent += new EventHandler(vlc_playEvent);        vlc.stopEvent += new EventHandler(vlc_stopEvent);    }    void vlc_playEvent(object sender, EventArgs e)    {        Debug.WriteLine("playEvent fired!");    }    void vlc_pauseEvent(object sender, EventArgs e)    {        Debug.WriteLine("pauseEvent fired!");    }    void vlc_stopEvent(object sender, EventArgs e)    {        Debug.WriteLine("stopEvent fired!");    }    private void button1_Click(object sender, RoutedEventArgs e)    {        OpenFileDialog ofd = new OpenFileDialog();        ofd.ShowDialog();        if (ofd.FileName != "")        {            Debug.WriteLine(ofd.FileName);            vlc.addTarget("file:///" + ofd.FileName, null, AXVLC.VLCPlaylistMode.VLCPlayListReplaceAndGo, 0);            vlc.play();        }    }

Still, these events will not inform you about any streaming errors. IMO, only thing you can do is; try-catch where you execute vlc.addTarget(...) and vlc.play(). Check whether the URL is valid beforehand (also don't forget to include "file:///" infront of the file path with the recent versions of the plugin). And re-apply the videoURL (as you like) only if the caught error is not about non-existing file or invalid path, etc.

OR you could try some other wrappers/custom libs:


Shouldn't it be something like this:

vlc.MediaPlayerEncounteredError += new MediaPlayerEncounteredErrorEventHandler(vlc_MediaPlayerEncounteredError);


Right Click on VLC from Design → Properties → Event (Thunder Icon) → Select axVLCPlugin21_MediaPlayerend at MediaPlayerEndReached.

See an image for more details: