播放是使用vlc.Dotnet.forms
下载这两个
然后工具箱里就多了一个vlc.dotnet.forms
注意在vlc控件的vlclibdirectoryNeeded事件中添加这个
var currentAssesmbly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssesmbly.Location).DirectoryName;
if (null == currentDirectory)
{
e.VlcLibDirectory = new DirectoryInfo(Path.GetFullPath(@".\libvlc\win-x86\"));
}
else
{
e.VlcLibDirectory = new DirectoryInfo(Path.GetFullPath(@".\libvlc\win-x64\"));
}
if (!e.VlcLibDirectory.Exists)
{
var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog.Description = "Select Vlc libraries folder.";
folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
folderBrowserDialog.ShowNewFolderButton = true;
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
e.VlcLibDirectory = new DirectoryInfo(folderBrowserDialog.SelectedPath);
}
}
播放按钮代码
string[] options = { ":network-caching=100", ":rtsp-tcp", ":no-audio" };// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; // --avcodec-hw={any,d3d11va,dxva2,none}
var videoUri = new Uri(txtUrl1.Text.Trim());
vlcControl1.Play(videoUri, options);
截图按钮代码
using(SaveFileDialog sfd = new SaveFileDialog())
{
sfd.Filter = "jpg文件 | *.jpg";
if(sfd.ShowDialog() == DialogResult.OK)
{
vlcControl1.TakeSnapshot(sfd.FileName);
}
}
这鬼截图找遍了都没找到,最后还是在哔哩哔哩看视频偶然看到了,这里写出来希望能够帮到别人
暂停和停止都很简单,网上也能找到我就不写了
直接保存可以这样写vlcControl1.TakeSnapshot("D://")这样是保存到了D盘下