Browse Source

playback view: add horizontal swipe for playback position, vertical swipe on right handside for screen brightness and reserve vertical swipe on left for volume (which requires future audiounit_ios adaptations)

Felix Paul Kühne 12 years ago
parent
commit
544333827b
2 changed files with 45 additions and 1 deletions
  1. 3 1
      AspenProject/VLCMovieViewController.h
  2. 42 0
      AspenProject/VLCMovieViewController.m

+ 3 - 1
AspenProject/VLCMovieViewController.h

@@ -8,8 +8,10 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 #import "VLCStatusLabel.h"
 #import "VLCStatusLabel.h"
+#import "VLCHorizontalSwipeGestureRecognizer.h"
+#import "VLCVerticalSwipeGestureRecognizer.h"
 
 
-@interface VLCMovieViewController : UIViewController <VLCMediaPlayerDelegate, UIActionSheetDelegate>
+@interface VLCMovieViewController : UIViewController <VLCMediaPlayerDelegate, UIActionSheetDelegate, VLCHorizontalSwipeGestureRecognizer, VLCVerticalSwipeGestureRecognizer>
 {
 {
     VLCMediaPlayer *_mediaPlayer;
     VLCMediaPlayer *_mediaPlayer;
 
 

+ 42 - 0
AspenProject/VLCMovieViewController.m

@@ -77,6 +77,23 @@
     recognizer.delegate = self;
     recognizer.delegate = self;
     [self.view addGestureRecognizer:recognizer];
     [self.view addGestureRecognizer:recognizer];
 
 
+    UISwipeGestureRecognizer *leftSwipeRecognizer = [[VLCHorizontalSwipeGestureRecognizer alloc] initWithTarget:self action:nil];
+    leftSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
+    leftSwipeRecognizer.delegate = self;
+    [self.view addGestureRecognizer:leftSwipeRecognizer];
+    UISwipeGestureRecognizer *rightSwipeRecognizer = [[VLCHorizontalSwipeGestureRecognizer alloc] initWithTarget:self action:nil];
+    rightSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
+    rightSwipeRecognizer.delegate = self;
+    [self.view addGestureRecognizer:rightSwipeRecognizer];
+    UISwipeGestureRecognizer *upSwipeRecognizer = [[VLCVerticalSwipeGestureRecognizer alloc] initWithTarget:self action:nil];
+    upSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
+    upSwipeRecognizer.delegate = self;
+    [self.view addGestureRecognizer:upSwipeRecognizer];
+    UISwipeGestureRecognizer *downSwipeRecognizer = [[VLCVerticalSwipeGestureRecognizer alloc] initWithTarget:self action:nil];
+    downSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
+    downSwipeRecognizer.delegate = self;
+    [self.view addGestureRecognizer:downSwipeRecognizer];
+
     _aspectRatios = @[@"DEFAULT", @"4:3", @"16:9", @"16:10", @"2.21:1", @"FILL_TO_SCREEN"];
     _aspectRatios = @[@"DEFAULT", @"4:3", @"16:9", @"16:10", @"2.21:1", @"FILL_TO_SCREEN"];
 }
 }
 
 
@@ -452,6 +469,31 @@
     }
     }
 }
 }
 
 
+#pragma mark - swipe gestures
+
+- (void)horizontalSwipePercentage:(CGFloat)percentage inView:(UIView *)view
+{
+    if (percentage != 0.) {
+        _mediaPlayer.position = _mediaPlayer.position + percentage;
+    }
+}
+
+- (void)verticalSwipePercentage:(CGFloat)percentage inView:(UIView *)view half:(NSUInteger)half
+{
+    if (percentage != 0.) {
+        if (half > 0) {
+            CGFloat currentValue = self.brightnessSlider.value;
+            currentValue = currentValue + percentage;
+            self.brightnessSlider.value = currentValue;
+            if ([self hasExternalDisplay])
+                _mediaPlayer.brightness = currentValue;
+            else
+                [[UIScreen mainScreen] setBrightness:currentValue / 2];
+        } else
+            NSLog(@"volume setting through swipe not implemented");//_mediaPlayer.audio.volume = percentage * 200;
+    }
+}
+
 #pragma mark - Video Filter UI
 #pragma mark - Video Filter UI
 
 
 - (IBAction)videoFilterToggle:(id)sender
 - (IBAction)videoFilterToggle:(id)sender