Commit 1e0c06a5 authored by Martin Finkel's avatar Martin Finkel

WPF Sample: Use VideoView.Loaded event to set mediaplayer

parent 7d6f5c42
......@@ -17,12 +17,13 @@ namespace LibVLCSharp.WPF.Sample
InitializeComponent();
Loaded += Controls_Loaded;
// we need the VideoView to be fully loaded before setting a MediaPlayer on it.
parent.VideoView.Loaded += VideoView_Loaded;
PlayButton.Click += PlayButton_Click;
StopButton.Click += StopButton_Click;
}
private void Controls_Loaded(object sender, RoutedEventArgs e)
private void VideoView_Loaded(object sender, RoutedEventArgs e)
{
_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC);
......
......@@ -28,7 +28,8 @@ namespace LibVLCSharp.WPF.Sample
_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC);
VideoView.MediaPlayer = _mediaPlayer;
// we need the VideoView to be fully loaded before setting a MediaPlayer on it.
VideoView.Loaded += (sender, e) => VideoView.MediaPlayer = _mediaPlayer;
}
void StopButton_Click(object sender, RoutedEventArgs e)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment