Article From:https://www.cnblogs.com/lonelyxmas/p/9689100.html
WPF: VLC streaming media player

Recently I’ve been working on the issue of using VLC streaming media in WPF. Now VLC can be played locally in WPF.Streaming playback solved, in the following code annotation streaming media playback those two pieces of code, more care about people to explore the ^^,For everyone to learn from each other, here I will first implement the VLC local broadcast code and process to write a friend for reference.

First, go to the following website:

http://vlcdotnet.codeplex.com/releases/view/77778

download

Application VideoLan DotNet for WinForm, WPF, SL5 – 2011.11.29.zip

After decompression, there are five.Dll inside.

1.Vlc.DotNet.Core.dll
2.Vlc.DotNet.Core.Interops.dll
3.Vlc.DotNet.Forms.dll
4.Vlc.DotNet.Silverlight.dll
5.Vlc.DotNet.Wpf.dll

Add different references depending on what program you write, such as the program you use WPF to doVlc.DotNet.Wpf.dllVlc.DotNet.Core.dll、Vlc.DotNet.Core.Interops.dllAdd to project and reference.

2. Download the latest VLC player on the VLC website, then install it, and copy the files VideoLAN VLC and VideoLAN VLC plugins into the project in the installation file directory.

After completing the above tasksAdd reference to namespace in XAML:

xmlns:local=”clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf”

<Grid>

<Image x:Name=”img”/>

<Grid/>

The background code in the project is as follows:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
var appPath = AppDomain.CurrentDomain.BaseDirectory;
VlcContext.LibVlcDllsPath = appPath + @”VLC\”;
//Set the vlc plugins directory path
VlcContext.LibVlcPluginsPath = appPath + @”plugins\”;

//Set the startup options
VlcContext.StartupOptions.IgnoreConfig = true;
VlcContext.StartupOptions.LogOptions.LogInFile = false;
VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;
VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.None;

//Initialize the VlcContext
VlcContext.Initialize();

VlcControl myVlcControl = new VlcControl();
// Create bindings, bind Image
Binding bing = new Binding();
bing.Source = myVlcControl;
bing.Path = new PropertyPath(“VideoSource”);
img.SetBinding(Image.SourceProperty, bing);

//Streaming media playback

var media=new LocationMedia(“udp://@:ip:port”);

myVlcControl.Play(media);

//Local playback

myVlcControl.Play(new PathMedia(Add local video path)

//VlcContext.CloseAll();
}

If you have any questions or better suggestions, please give us more advice! Thanks!!!

Link of this Article: WPF VLC streaming media playback

Leave a Reply

Your email address will not be published. Required fields are marked *