Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveX VLC Player events are not working

I have incorporated ActiveX VLC pligin to WPF application. And VLC Plugin is working fine.

AxVLCPlugin   vlc = new AxVLCPlugin();
vlc.MediaPlayerEncounteredError += vlc_MediaPlayerEncounteredError;
vlc.MediaPlayerOpening += vlc_MediaPlayerOpening;
vlc.MediaPlayerBuffering += vlc_MediaPlayerBuffering;
vlc.MediaPlayerEndReached += vlc_MediaPlayerEndReached;
 //
// Other code 
// like    windowsFormsHost1.Child = vlc; and etc
vlc.addTarget(videoURL, null, AXVLC.VLCPlaylistMode.VLCPlayListReplace, 1);
vlc.play();

But some how all events of VLC are not working at all.

I mean these events:

vlc.MediaPlayerEncounteredError += vlc_MediaPlayerEncounteredError;
vlc.MediaPlayerOpening += vlc_MediaPlayerOpening;
vlc.MediaPlayerBuffering += vlc_MediaPlayerBuffering;
vlc.MediaPlayerEndReached += vlc_MediaPlayerEndReached;

 void vlc_MediaPlayerEndReached(object sender, EventArgs e)
        {
            Debug.WriteLine("[P] - StreamingVideo -  END REACHED + " + DateTime.Now);
        }

        void vlc_MediaPlayerBuffering(object sender, DVLCEvents_MediaPlayerBufferingEvent e)
        {
            Debug.WriteLine("[P] - StreamingVideo -  BUFFERING + " + DateTime.Now);
        }

        void vlc_MediaPlayerOpening(object sender, EventArgs e)
        {
            Debug.WriteLine("[P] - StreamingVideo -  OPENING + " + DateTime.Now);
        }

        void vlc_MediaPlayerEncounteredError(object sender, EventArgs e)
        {
            Debug.WriteLine("[P] - StreamingVideo -  ERROR + " + DateTime.Now);
        }

They are not firing. (Sure, I put breakpoints in those methods.)

What I really need is catch the streaming errors and re-apply videoURL another time. So I am experimenting with events to see which of them I can use to reach that goal.

Any clue why is it?

P.S. This link doesn't help also VLC player event catch

like image 503
Friend Avatar asked Jan 29 '13 15:01

Friend


People also ask

Does VLC need ActiveX plugin?

The Windows build of VLC includes an (optionaly installed) ActiveX control. The ActiveX control enables VLC to be embedded in web browsers and third-party applications.

How do I enable plugins on VLC?

Launch VLC Media Player and go to the Tools Plugins & Extensions menu. Select the Addons Manager tab in the Plugins and Extensions window and uncheck Only Installed. Go through the list of available plugins and choose the one you want to install. Simply click the Install button to install the selected plugins.


1 Answers

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:

  • VLC DotNet for WinForm & WPF
  • More at this page
like image 176
Onur Yıldırım Avatar answered Sep 26 '22 02:09

Onur Yıldırım