0

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:[email protected]: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

1

1 Answer 1

1

You haven't set vlcPlayer's Media property.

var vlcPlayer = new VlcControl(); var media = new LocationMedia("rtsp://admin:[email protected]:554/MediaInput/h264"); vlcPlayer.Media = media; //add this 

Btw, you don't need to add vlcPlayer to Grid1.

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

2 Comments

Doah!! I had intended to do this: vlcPlayer.Media = new LocationMedia("rtsp://etc etc Sometimes you can't see what's right in front of you and need fresh eyes.
@cavedove (sic!): No, you ain't vlcPlayer.Media = ... You only have var media = ... So, technically speakin' KennyZX is right Doah!! ;-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.