winfrom+vlc

1 引入库文件

1.1 NuGet包管理器导入    Vlc.DotNet.Forms、VideoLAN.LibVLC.Windows

1.1.1 Vlc.DotNet.Forms  2.2.1

 

 

 1.1.2 VideoLAN.LibVLC.Windows 3.0.6

 

 

 

 1.1.3 安装完成

 

 

 

1.2  vlc插入winform,并添加directory

 

 

 

private void vlcControl1_VlcLibDirectoryNeeded(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
        {
            //获取当前路径
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            //获取对应平台的VLC路径
            // Default installation path of VideoLAN.LibVLC.Windows
            e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
            //如果不存在,手动指定
            if (!e.VlcLibDirectory.Exists)
            {
                var folderBrowserDialog = new 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);
                }
            }
        }

1.3  使用播放

 

 

 

 

vlcControl1.Play(new Uri("rtsp://127.0.0.1:8554/rtsp01"));

 

posted @ 2022-04-11 14:39  驼七  阅读(351)  评论(0编辑  收藏  举报