Recently, I am working on VLC streaming media playback in WPF. Now I can implement VLC local playback in WPF,Streaming playback solves the problem. In the following code, comment out the two pieces of code for streaming media playback. More people care about it ^,For everyone to learn from each other, here I will first write the code and process for VLC local playback to a friend in need for reference.
1. first go to the following website:
Http://vlcdotnet.codeplex.com/releases/view/77778
Download
VideoLAN DOTNET for winform, WPF, sl5-2011.11.29.zip
After decompression, there are five. DLL files.
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 according to the program you are using. For example, if you are using WPF, selectVLC. DOTNET. WPF. dll,VLC. DOTNET. Core. dll,VLC. DOTNET. Core. interops. dll is added to the project and referenced.
2. download the latest VLC player from the official VLC website, install it, and copy the VideoLAN \ VLC \ and VideoLAN \ VLC \ plugins \ files to the project directory.
After completing the preceding tasksAdd a namespace reference 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 a binding and bind an image
Binding Bing = new binding ();
Bing. Source = myvlccontrol;
Bing. Path = new propertypath ("videosource ");
IMG. setbinding (image. sourceproperty, Bing );
// Stream Media Playback
VaR media = new locationmedia ("UDP: // @: IP: Port ");
Myvlccontrol. Play (media );
// Local playback
Myvlccontrol. Play (New pathmedia (add a local video path ));
// Vlccontext. closeall ();
}
If you have any questions or better suggestions, please kindly advise! Thanks !!!