Prechádzať zdrojové kódy

Fix a bug where brightness could be 101% or -1%

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Marc Etcheverry 11 rokov pred
rodič
commit
e3ceff6f2d
1 zmenil súbory, kde vykonal 8 pridanie a 0 odobranie
  1. 8 0
      Sources/VLCMovieViewController.m

+ 8 - 0
Sources/VLCMovieViewController.m

@@ -1192,6 +1192,14 @@
         else
             brightness = brightness + 0.01;
 
+        // Sanity check since -[UIScreen brightness] does not go by 0.01 steps
+        if (brightness > 1.0)
+            brightness = 1.0;
+        else if (brightness < 0.0)
+            brightness = 0.0;
+
+        NSAssert(brightness >= 0 && brightness <= 1, @"Brightness must be within 0 and 1 (it is %f)", brightness);
+
         [[UIScreen mainScreen] setBrightness:brightness];
         self.brightnessSlider.value = brightness * 2.;