c# VLC.Dotnet 播放然后暂停问题

c# VLC.Dotnet play and then pause issue

我希望有人能够帮助我解决我的问题。我想在特定时间索引拍摄视频的屏幕截图,但是当我尝试更改时间时,我得到的只是一个空白的黑屏。我添加了播放和暂停按钮,它允许我播放和暂停视频,如果我这样做然后更改时间索引,我会得到一个图像。我对为什么它不能使用代码工作感到困惑。我什至预制 btnplay.PeformClick();播放视频,当我执行 btnpause.PerformClick() 暂停视频时它不会。

似乎只有当我必须实际点击播放然后在我的表单上暂停按钮时我才能获得视频图像,我正在尝试使用代码实现此目的

private void Form1_Load(object sender, EventArgs e)
        {
           


            ////////////////////LC4 VLC Settings///////////////////////////////////////////////////////////////////////////////////////////

            control = new VlcControl();
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
            control.BeginInit();
            control.VlcLibDirectory = libDirectory;
            control.Dock = DockStyle.Fill;
            control.EndInit();
            panel1.Controls.Add(control);
            
            main_form_LC4_data();
        }
        
         void main_form_LC4_data()
        {
        long vOut3 = 20;
        playfile("path to file");
        First_Frame(vOut3);
        }
        
          void playfile(string final)
        {
           control.SetMedia(new Uri(final).AbsoluteUri);
            control.Time = 0;
            control.Update();
            
        }
        
         void First_Frame(long vOut3)
        {
            control.Time = vOut3;

        }
        
          private void button9_Click(object sender, EventArgs e)
        {
            control.Play();
            Console.WriteLine("PLAY");
        }

        private void button8_Click(object sender, EventArgs e)
        {
           
            control.Pause();
            Console.WriteLine("PAUSE");
        }

以上是我的代码简述shell

我试过这样的事情

private void button10_Click(object sender, EventArgs e)
        {
           First_Frame(first_frame); // jump to index
        }

然后调用 button10.PerformClick(); 但它似乎不起作用。再一次,如果我实际点击我表单上的按钮,它会完美地工作,但不是以编码的方式。

举个例子:

  1. play.PeformClick();
  2. Pause.PeformClick();
  3. 时间 = vOut3;

我希望这不会让我感到困惑,我真的卡住了,我仍然希望有人能帮助我

谢谢

一些事情:

control.Update();

这没有任何作用。

设置时间后需要等待Playing事件引发,否则libvlc没有时间解码帧并显示(设置时间是异步的)