[Wpf] [.net core 3.0] MouseMove can not be captured on VieoView Element
Summary
I'm add a few controls on the video player, and it can automatic disapper when no mouse move after 3 seconds, but I have problem to capture mouse move event on any possiable Element (Window, VideoView, Outer Grid, Inner Grid)!
Minimal project and steps to reproduce
<Window x:Class="ViewSyncDesktop.PlayerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ViewSyncDesktop"
xmlns:vlc="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
mc:Ignorable="d"
Title="PlayerWindow" Height="450" Width="800"
WindowState="Maximized" WindowStyle="None" MouseMove="palyer_MouseMove" PreviewMouseMove="palyer_MouseMove"> <!-- not work -->
<Grid>
<vlc:VideoView x:Name="palyer" Background="Black" Margin="40" MouseMove="palyer_MouseMove" PreviewMouseMove="palyer_MouseMove">
<!-- not work -->
<Grid x:Name="VideoControls" MouseMove="palyer_MouseMove" PreviewMouseMove="palyer_MouseMove">
<Button x:Name="exitBtn" Width="100" Height="50" BorderBrush="Transparent" HorizontalAlignment="Right" VerticalAlignment="Top" >
退出
</Button>
</Grid>
</vlc:VideoView>
</Grid>
</Window>
public partial class PlayerWindow : Window
{
private readonly string _address;
private readonly Timer timer = new Timer();
private double controlOpacity = 3.0;
private LibVLCSharp.Shared.MediaPlayer _mediaPlayer;
public PlayerWindow(string address)
{
_address = address;
InitializeComponent();
}
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
SetupPlayer();
this.palyer.Loaded += (s, e) =>
{
this.palyer.MediaPlayer = _mediaPlayer;
_mediaPlayer.Play();
};
timer.Interval = 100;
timer.Tick += (o, e) =>
{
controlOpacity -= 0.1;
if(controlOpacity < 1)
{
if(controlOpacity > 0.4)
{
this.VideoControls.Opacity = controlOpacity;
}
else
{
this.VideoControls.Opacity = 0.01; // I try to create a not full transparent background, but not work well too
}
}
};
timer.Start();
}
private void SetupPlayer()
{
_mediaPlayer = new LibVLCSharp.Shared.MediaPlayer(new LibVLCSharp.Shared.Media(new LibVLCSharp.Shared.LibVLC(), _address, LibVLCSharp.Shared.FromType.FromLocation));
}
// the event
private void palyer_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
controlOpacity = 3;
this.VideoControls.Opacity = 1;
}
}
What is the current bug behavior?
can not execute palyer_MouseMove
whatever The element below or above VideoView
What is the expected correct behavior?
execute palyer_MouseMove
when mouse move on VideoView
Environment
- OS: win 10
- Version 1903
- Device: pc
- LibVLC version and architecture :
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.8.1" />
- LibVLCSharp version
<PackageReference Include="LibVLCSharp.WPF" Version="3.3.0" />
Possible fixes
no