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;
|
_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.Mute = IsMuted;
|
||||||
_player.Volume = ToVlcVolume(Volume);
|
_player.Volume = ToVlcVolume(Volume);
|
||||||
_surfaceReady = true;
|
_surfaceReady = true;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
<!-- VLC paints into a native child window, which sits above the Avalonia surface, so
|
<!-- 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. -->
|
the error message lives in its own row instead of on top of the picture. -->
|
||||||
<Grid Grid.Row="1" RowDefinitions="*,Auto">
|
<Grid Grid.Row="1" RowDefinitions="*,Auto">
|
||||||
<Panel Grid.Row="0" Background="Black">
|
<Panel Grid.Row="0" Name="VideoArea" Background="Black">
|
||||||
<controls:VlcVideoView Name="Player"
|
<controls:VlcVideoView Name="Player"
|
||||||
Source="{Binding Source}"
|
Source="{Binding Source}"
|
||||||
AutoPlay="True"
|
AutoPlay="True"
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ public sealed partial class VideoPlayerView : UserControl
|
|||||||
|
|
||||||
VolumeSlider.PropertyChanged += OnVolumeChanged;
|
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.PositionProperty).Subscribe(OnPositionChanged);
|
||||||
Player.GetObservable(VlcVideoView.DurationProperty).Subscribe(OnDurationChanged);
|
Player.GetObservable(VlcVideoView.DurationProperty).Subscribe(OnDurationChanged);
|
||||||
Player.GetObservable(VlcVideoView.IsPlayingProperty).Subscribe(OnIsPlayingChanged);
|
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 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 OnScrubStarted(object? sender, PointerPressedEventArgs e) => _isScrubbing = true;
|
||||||
|
|
||||||
private void OnScrubFinished(object? sender, PointerReleasedEventArgs e)
|
private void OnScrubFinished(object? sender, PointerReleasedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user