Reputation: 11
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.
Upvotes: 1
Views: 3330
Reputation: 17007
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");
Upvotes: 1