I am trying to use VLC in WPF via Vlc.DotNet. I have been successful in getting Vlc.DotNet to work in Winforms, but thus far unsuccessful with WPF.
I get no errors, but I also get no video... just a blank white pane.
Here is my very simple XAML:
<Window x:Class="VLC.Wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Closing="Window_Closing">
<Grid x:Name="Grid1">
</Grid>
</Window>
And here is the codebehind I use to insert and start the Vlc Wpf control.
public MainWindow()
{
VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;
VlcContext.StartupOptions.IgnoreConfig = true;
VlcContext.Initialize();
InitializeComponent();
var vlcPlayer = new VlcControl();
var media = new LocationMedia("rtsp://admin:12345@192.168.42.200:554/MediaInput/h264");
Grid1.Children.Add(vlcPlayer);
var vlcBinding = new Binding("VideoSource");
vlcBinding.Source = vlcPlayer;
var vImage = new Image();
vImage.SetBinding(Image.SourceProperty, vlcBinding);
var vBrush = new VisualBrush();
vBrush.TileMode = TileMode.None;
vBrush.Stretch = Stretch.Uniform;
vBrush.Visual = vImage;
Grid1.Background = vBrush;
vlcPlayer.Play();
}
Does anyone see anything wrong with this?
Using Vlc 2.1.5 win32
You haven't set vlcPlayer's Media property
.
var vlcPlayer = new VlcControl();
var media = new LocationMedia("rtsp://admin:12345@192.168.42.200:554/MediaInput/h264");
vlcPlayer.Media = media; //add this
Btw, you don't need to add vlcPlayer
to Grid1
.