From 09a39bda761c319d11a96e33c52323b3bd58eed5 Mon Sep 17 00:00:00 2001
From: Diogo Simao Marques <dogo@videolabs.io>
Date: Wed, 26 Mar 2025 18:10:20 +0100
Subject: [PATCH] PlayerViewController: Fix the brightness & volume gestures

The brightness and volume gestures are now correctly handled when
enabled.

If the gestures are disabled, swiping down will minimize the player.

Closes #1887
---
 .../Player/PlayerViewController.swift         | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift
index 092f048a3..19490da2c 100644
--- a/Sources/Playback/Player/PlayerViewController.swift
+++ b/Sources/Playback/Player/PlayerViewController.swift
@@ -666,25 +666,24 @@ class PlayerViewController: UIViewController {
         let location: CGPoint = recognizer.location(in: window)
 
         // If minimization handler not ended yet, don't detect other gestures to don't block it.
-        guard minimizationInitialCenter == nil else { return .none }
+        guard minimizationInitialCenter == nil else {
+            return .none
+        }
 
-        var panType: PlayerPanType = .none
-        if location.x < 2 * windowWidth / 3 {
-            panType = .none
+        guard !playbackService.currentMediaIs360Video else {
+            return .projection
         }
+
+        var panType: PlayerPanType = .none
+
 #if os(iOS)
-        if location.x < 1 * windowWidth / 3 && playerController.isBrightnessGestureEnabled {
+        if location.x < windowWidth / 2 && playerController.isBrightnessGestureEnabled {
             panType = .brightness
-        }
-        if location.x < 3 * windowWidth / 3 && playerController.isVolumeGestureEnabled {
+        } else if location.x > windowWidth / 2 && playerController.isVolumeGestureEnabled {
             panType = .volume
         }
 #endif
 
-        if playbackService.currentMediaIs360Video {
-            panType = .projection
-        }
-
         return panType
     }
 
-- 
GitLab