feat: mouse wheel volume control on video player

This commit is contained in:
edde746
2026-02-10 18:34:47 +01:00
parent 7234da5b64
commit 68c169891c
2 changed files with 14 additions and 0 deletions
@@ -45,6 +45,7 @@ class KeyboardShortcutsService {
Map<String, String> get shortcuts => Map.from(_shortcuts);
Map<String, HotKey> get hotkeys => Map.from(_hotkeys);
int get maxVolume => _maxVolume;
String getShortcut(String action) {
return _shortcuts[action] ?? '';
@@ -676,6 +676,18 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
_hideControls();
}
void _handlePointerSignal(PointerSignalEvent event) {
if (event is PointerScrollEvent && _keyboardService != null) {
final delta = event.scrollDelta.dy;
final volume = widget.player.state.volume;
final maxVol = _keyboardService!.maxVolume.toDouble();
final newVolume = (volume - delta / 20).clamp(0.0, maxVol);
widget.player.setVolume(newVolume);
SettingsService.getInstance().then((s) => s.setVolume(newVolume));
_showControlsFromPointerActivity();
}
}
/// Show controls in response to pointer activity (mouse/trackpad movement).
void _showControlsFromPointerActivity() {
if (!_showControls) {
@@ -1565,6 +1577,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
child: Listener(
behavior: HitTestBehavior.translucent,
onPointerHover: (_) => _showControlsFromPointerActivity(),
onPointerSignal: _handlePointerSignal,
child: MouseRegion(
cursor: _showControls ? SystemMouseCursors.basic : SystemMouseCursors.none,
onHover: (_) => _showControlsFromPointerActivity(),