0

I want my WPF application to play video from a given stream. Tried to google, but didn't find any working example with the latest Vlc.Dotnet.Wpf version. I have installed the latest package with NuGet and here is what I have so far:

My XAML:

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

C# code:

 vlcPlayer.BeginInit(); vlcPlayer.MediaPlayer.VlcLibDirectory = new DirectoryInfo(@"C:\Program Files (x86)\VideoLAN\VLC\"); vlcPlayer.EndInit(); vlcPlayer.MediaPlayer.Play(new Uri("http://79.170.191.118:1935/formula55_2/stream55_2/playlist.m3u8")); 

When I run, nothing happens. However stream works fine in Vlc Player. What are my options here?

Thanks in advance.

1 Answer 1

1

This should get you started:

public MainWindow() { InitializeComponent(); var currentAssembly = Assembly.GetEntryAssembly(); var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName; // Default installation path of VideoLAN.LibVLC.Windows var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")); this.VlcControl.SourceProvider.CreatePlayer(libDirectory/* pass your player parameters here */); this.VlcControl.SourceProvider.MediaPlayer.Play(new Uri("http://79.170.191.118:1935/formula55_2/stream55_2/playlist.m3u8")); } 

You will need to install https://www.nuget.org/packages/VideoLAN.LibVLC.Windows/ which is the correct way to consume libvlc libraries in .NET.

For next time, post some logs please as otherwise it's mostly guesswork. Also check out the official samples https://github.com/ZeBobo5/Vlc.DotNet/tree/develop/src/Samples

Sign up to request clarification or add additional context in comments.

3 Comments

When I try to do write this.VlcControl.SourceProvider I cannot find any SourceProvider property for my Vlc player. I have installed the latest version (3.0.4) using NuGet.
Clone the repo with the samples and start from there. Look at the differences from your code. Check the using statements
Turns out SourceProvider is available only in version 3.0, which is in preview. So had to download the prerelease version.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.