1

I want to integrate the vlc player to my project in order to display the stream of an IP camera. I was following this Integrate VLC player in C# (WPF) project using Vlc.DotNet to make a demo. Here is my c# code:

 using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Vlc.DotNet.Wpf; namespace RTSPyVLC { /// <summary> /// Lógica de interacción para MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); vlcPlayer.MediaPlayer.VlcLibDirectory = //replace this path with an appropriate one new DirectoryInfo(@"c:\Program Files (x86)\VideoLAN\VLC\"); vlcPlayer.MediaPlayer.EndInit(); vlcPlayer.MediaPlayer.Play(new Uri("http://download.blender.org/peach/" + "bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi")); } } } 

I do the same, but an error appears: VlcControl does not contain a definition for "MediaPlayer"... And its true, the class VlcControl doesn contain it. The question is if I adding the wrong package (Vlc.DotNet.wpf by ZeBobo5 added with NuGet) or there is another way to integrate the vlc player with this library. If you know about an example or a guide it would be magnificient.

Thank you a lot.

2
  • could you show your wpf code? Commented May 6, 2020 at 11:59
  • I have solve the problem, thanks anyway. What I would want to know is how to reduce the buffer in order to reduce the delay. Commented May 7, 2020 at 8:34

1 Answer 1

1

you have an help WIKI for VLC, at the bottom of the web page you have all information about wpf with a sample.

in wpf:

<Vlc:VlcControl xmlns:Vlc="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf" x:Name="MyControl" /> 

In your view constructor, after the call to InitializeComponent()

 var vlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); var options = new string[] { // VLC options can be given here. Please refer to the VLC command line documentation. }; this.MyControl.SourceProvider.CreatePlayer(vlcLibDirectory, options); // Load libvlc libraries and initializes stuff. It is important that the options (if you want to pass any) and lib directory are given before calling this method. this.MyControl.SourceProvider.MediaPlayer.Play("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov"); 
Sign up to request clarification or add additional context in comments.

2 Comments

The wiki link you mentionned is a good place to start. However, for perf reasons, I usually recommend not to use the Wpf control and just wrap the WinForms control instead (see the readme). One more tip : There is now a NuGet package to install and redistribute libvlc for windows (see the wiki)
Thanks, that's worked! I had to add the vlc plugins to the repository, which I completly forget.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.