简体   繁体   中英

WPF Control For Receving H.264 Video

I'm planning on creating a screen-sharing project for fun. It will stream H.264 video of the screen. My current dilemma is displaying said stream in a WPF application. I cannot decide which control would be suited for this. I doubt Image would work, and I don't see any built-in video control besides MediaElement . Is there in inbuilt control able to display h.264?

The mediaelement control plays HD videos with difficulty and With slow frames. it is better to use vlcdot.net instead. I used vlc myself for a personal project. I got to vlcdot after 2 weeks of wandering.

Install-Package Vlc.DotNet.Wpf -Version 3.1.0

xaml code

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

Quotation code

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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