我在Visual Studio 2012中创建了一个C#Windows窗体应用程序,并在此网页中添加了dll:http://vlcdotnet.codeplex.com/ 我已经获得了使用此代码的视频:
VlcControl player = new VlcControl();
Vlc.DotNet.Core.Medias.MediaBase media = new
Vlc.DotNet.Core.Medias.PathMedia(@"path\movie.avi");
player.Media = media;
player.Play();
但是在另一个窗口显示它,我无法控制它。我如何在我的表单中嵌入视频?
我没有找到任何关于如何以编程方式执行此操作的文档。教程中的大多数人都在他们的工具箱中列出了某种vlc控件,但我还没有,所以我需要用代码来实现。
我尝试将面板用作VlcControl的父级:
player.Parent=panel1;
电影仍在播放,但没有视频,只有声音。 我应该使用什么样的容器以及如何让它显示视频?
更多信息: 这里:VLC.DotNet Control Hosted in WPF据说可以在WPF中的WindowsFormsHost元素中嵌入视频。但是,在Windows窗体应用程序中,只有ElementHost可供我使用。我可以使用它来嵌入视频吗?如果是的话,我该怎么做?
答案 0 :(得分:5)
我找到了解决方案。我需要将player
添加到面板的控件中并设置播放器大小。在这里,如果有人需要它:
player = new VlcControl();
panel1.Controls.Add(player);
player.BackColor = System.Drawing.Color.Black;
player.ImeMode = System.Windows.Forms.ImeMode.NoControl;
player.Location = new System.Drawing.Point(0, 0);
player.Name = "test";
player.Rate = 0.0F;
player.Size = new System.Drawing.Size(1024, 768);
Vlc.DotNet.Core.Medias.MediaBase media = new
Vlc.DotNet.Core.Medias.PathMedia(@"path\movie.avi");
player.Media = media;
player.Play();