栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

vlc集成c#

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

vlc集成c#

开发环境:

Visual Studio 2015

.Net Framework 4.5

1.新建一个Windows窗体应用程序

修改框架为.Net Framework 4.5

2.管理NuGet包

下载安装5个包

VideoLAN.LibVLC.Windows

Vlc.DotNet.Core

Vlc.DotNet.Core.Interops

Vlc.DotNet.Forms

Vlc.DotNet.Wpf

3.添加VlcControl

工具箱添加VlcControl,dll位于当前项目中

将VlcControl添加到窗体上

在VlcControl的VlcLibDirectoryNeeded事件中添加如下代码(必须)

///

///Looks for the vlc directory on the opening of the app///Opens a dialog if the libvlc folder is not found for the user to pick the good one///Folder for 32bits should be "libvlcwin-x86" and "libvlcwin-x64" for 64 bits///

///

///

private void myVlcControl_VlcLibDirectoryNeeded(objectsender, VlcLibDirectoryNeededEventArgs e)

{var currentAssembly =Assembly.GetEntryAssembly();var currentDirectory = newFileInfo(currentAssembly.Location).DirectoryName;if (currentDirectory == null)return;if (IntPtr.Size == 4)

e.VlcLibDirectory= new DirectoryInfo(Path.GetFullPath(@".libvlcwin-x86"));elsee.VlcLibDirectory= new DirectoryInfo(Path.GetFullPath(@".libvlcwin-x64"));if (!e.VlcLibDirectory.Exists)

{var folderBrowserDialog = newSystem.Windows.Forms.FolderBrowserDialog();

folderBrowserDialog.Description= "Select Vlc libraries folder.";

folderBrowserDialog.RootFolder=Environment.SpecialFolder.Desktop;

folderBrowserDialog.ShowNewFolderButton= true;if (folderBrowserDialog.ShowDialog() ==DialogResult.OK)

{

e.VlcLibDirectory= newDirectoryInfo(folderBrowserDialog.SelectedPath);

}

}

}

4.播放视频

使用VlcControl.Play()方法播放视频

vlcControl1.Play("http:/******.flv");//只能播放网络流视频

vlcControl1.SetMedia(new System.IO.FileInfo(@"f:1.flv"));//本地视频

vlcControl1.Play();

运行结果:

参考:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/910737.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号