繁体   English   中英

WPF 控制用于接收 H.264 视频

[英]WPF Control For Receving H.264 Video

我正计划创建一个有趣的屏幕共享项目。 它将 stream H.264 视频的屏幕。 我目前的困境是在 WPF 应用程序中显示 stream。 我无法决定哪个控件适合这个。 我怀疑Image会起作用,而且除了MediaElement之外,我没有看到任何内置的视频控件。 是否有能够显示 h.264 的内置控件?

mediaelement 控件难以播放高清视频且帧数较慢。 最好改用 vlcdot.net。 我自己将 vlc 用于个人项目。 经过 2 周的徘徊,我到了 vlcdot。

Install-Package Vlc.DotNet.Wpf -Version 3.1.0

xaml代码

//add window tag xmlns:Wpf="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
<Wpf:VlcControl x:Name="mediaElement"/>

报价代码

public async void LoadVideo(string Url)
{
   var currentAssembly = Assembly.GetEntryAssembly();
   var currentDirectory = new System.IO.FileInfo(currentAssembly.Location).DirectoryName;
   string str = IntPtr.Size == 4 ? "win-x86" : "win-x64";
   var vlcLibDirectory = new System.IO.DirectoryInfo(System.IO.Path.Combine(currentDirectory, "libvlc", str));

   var options = new string[]
   {
      // VLC options can be given here. Please refer to the VLC command line documentation.
   };


   await Task.Run(() =>
   {
      mediaElement.SourceProvider.CreatePlayer(vlcLibDirectory, options);
      mediaElement.SourceProvider.MediaPlayer.Play(@"file:///" + Url);
               
     //mediaElement.SourceProvider.MediaPlayer.EndReached += MediaPlayer_EndReached;
     //mediaElement.SourceProvider.MediaPlayer.Playing += MediaPlayer_Playing;

   });

   mediaElement.SourceProvider.MediaPlayer.Audio.Volume = Convert.ToInt32(prgBrVolume.Value);
   mediaElement.SourceProvider.MediaPlayer.Audio.IsMute = false;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM