从Win7开始,Windows支持多显示器输出,多个显示器可以作为相互“复制”(显示同一桌面),也可以“扩展”(两个显示器拼成大桌面)。这时可以在一个桌面的程序中,用VLC监视另一个桌面。

1、安装扩展:工具→包管理器→浏览“VLC”→安装扩展

2、从工具箱中拖动VLC控件到窗体设计器中


3、配置VLC库文件路径:VLC控件→事件→VlcLibDirectoryNeeded
private void vlcPreview_VlcLibDirectoryNeeded(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
{
string myVLC = @"C:\Program Files (x86)\VideoLAN\VLC";
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
if (currentDirectory == null)
return;
if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, myVLC));
}
4、监控桌面代码:(扩展桌面在主桌面右侧)
//计算VLC抓拍(监视)参数
String[] playOption = {
":screen-top=0",
":screen-left=1921",
":screen-width=1920",
":screen-height=1080",
":screen-fps=30.000000"
};
//监视桌面
vlcPreview.Play(new Uri("screen://"), playOption);
最终效果:
