的ActiveX VLC播放器事件会不工作 [英] ActiveX VLC Player events are not working

查看:1360
本文介绍了的ActiveX VLC播放器事件会不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把的ActiveX VLC pligin到WPF应用程序以及VLC插件工作正常。

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();

但一些如何VLC的所有事件都不能工作的。

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

我的意思是这些事件:

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.)

我真正需要的是抓住流错误并重新申请的 videoURL 的另一个时间。所以我尝试用事件,看看其中哪些我可以用它来实现这一目标。

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.

任何线索,为什么呢?

P.S。该链接不还有助于 VLC播放器事件捕获

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

推荐答案

我不认为你正在做的任何事。看起来;这些事件未实现(或者未实现)由于某种原因(甚至在ActiveX的最新版本)。我已经 ,这些事件要么太越野车或没有发射都在一些浏览器插件的版本了。

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.

不过,仍然有3有用和工作事件,你可以指望。
事件触发: playEvent pauseEvent stopEvent
活动不费一枪:开始 MediaPlayer的所有事件 ...

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...

总之,code下面我提到的事件如下:

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();
        }
    }

不过,这些事件不会告诉你任何的流错误。海事组织,你能做的唯一一件事就是,的try-catch,你执行 vlc.addTarget(...) vlc.play()。检查URL是否是有效的事前(也不要忘了包括文件:///盈与插件的最新版本的文件路径)。而重新申请的videoURL(只要你喜欢)只有在抓到错误是不是不存在的文件或无效的路径等。

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

这篇关于的ActiveX VLC播放器事件会不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆