Enhance VlcVideoView and VideoPlayerView for improved user interaction. Add a named VideoArea panel for better layout management and implement double-tap functionality to toggle full-screen mode. Update event handling in VideoPlayerView to accommodate these changes.
This commit is contained in:
@@ -155,6 +155,11 @@ public sealed class VlcVideoView : NativeControlHost
|
||||
_player.NsObject = handle.Handle;
|
||||
}
|
||||
|
||||
// VLC grabs mouse and keyboard on its own window by default, which swallows every
|
||||
// gesture before Avalonia can see it. We do not need DVD menus, so hand input back.
|
||||
_player.EnableMouseInput = false;
|
||||
_player.EnableKeyInput = false;
|
||||
|
||||
_player.Mute = IsMuted;
|
||||
_player.Volume = ToVlcVolume(Volume);
|
||||
_surfaceReady = true;
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<!-- VLC paints into a native child window, which sits above the Avalonia surface, so
|
||||
the error message lives in its own row instead of on top of the picture. -->
|
||||
<Grid Grid.Row="1" RowDefinitions="*,Auto">
|
||||
<Panel Grid.Row="0" Background="Black">
|
||||
<Panel Grid.Row="0" Name="VideoArea" Background="Black">
|
||||
<controls:VlcVideoView Name="Player"
|
||||
Source="{Binding Source}"
|
||||
AutoPlay="True"
|
||||
|
||||
@@ -43,6 +43,10 @@ public sealed partial class VideoPlayerView : UserControl
|
||||
|
||||
VolumeSlider.PropertyChanged += OnVolumeChanged;
|
||||
|
||||
// Handled on the surrounding panel rather than the video itself: the native window
|
||||
// is not part of Avalonia's hit-test tree, so the gesture can only arrive here.
|
||||
VideoArea.DoubleTapped += OnVideoDoubleTapped;
|
||||
|
||||
Player.GetObservable(VlcVideoView.PositionProperty).Subscribe(OnPositionChanged);
|
||||
Player.GetObservable(VlcVideoView.DurationProperty).Subscribe(OnDurationChanged);
|
||||
Player.GetObservable(VlcVideoView.IsPlayingProperty).Subscribe(OnIsPlayingChanged);
|
||||
@@ -114,6 +118,15 @@ public sealed partial class VideoPlayerView : UserControl
|
||||
|
||||
private void OnToggleMute(object? sender, RoutedEventArgs e) => Player.IsMuted = !Player.IsMuted;
|
||||
|
||||
private void OnVideoDoubleTapped(object? sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is VideoPlayerViewModel viewModel)
|
||||
{
|
||||
viewModel.IsFullScreen = !viewModel.IsFullScreen;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnScrubStarted(object? sender, PointerPressedEventArgs e) => _isScrubbing = true;
|
||||
|
||||
private void OnScrubFinished(object? sender, PointerReleasedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user