I'm using the LibVLCSharp.WPF
to play a video using the VideoView
control. I've binded MediaPlayer and Visibility in my ViewModel
. I can get it to play the video but rather than be embedded inside the Grid control it creates and opens a new window and plays the video there. I've searched and saw there is an airspace issue but maybe there is something I'm doing wrong to keep the video from playing inside the grid like when you place an image in an image control.
The player is inside a UserControl that is inside the MainWindow.
XAML
<Grid>
<media:VideoView x:Name="MediaPlayer"
VerticalAlignment="Center"
HorizontalAlignment="Center"
MediaPlayer="{Binding MyMediaPlayer}"
Visibility="{Binding IsMediaPlayerVisible, Converter={StaticResource VisConverter}}"/>
</Grid>
ViewModel
void StartVideo()
{
IsMediaPlayerVisible = true;
Core.Initialize();
using (_libVLC = new LibVLC())
{
MyMediaPlayer = new MediaPlayer(_libVLC);
MyMediaPlayer.Media = new Media(_libVLC, new Uri(@"path\to\media\file"));
MyMediaPlayer.Play();
}
}
Can I embed the VideoView
like a Image control inside a Grid?