瀏覽代碼

make swipe jump duration variable to video length

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Kevin Chromik 10 年之前
父節點
當前提交
ff62393df7
共有 1 個文件被更改,包括 8 次插入7 次删除
  1. 8 7
      Sources/VLCMovieViewController.m

+ 8 - 7
Sources/VLCMovieViewController.m

@@ -31,8 +31,6 @@
 #import "VLCStatusLabel.h"
 
 #define INPUT_RATE_DEFAULT  1000.
-#define FORWARD_SWIPE_DURATION 30
-#define BACKWARD_SWIPE_DURATION 10
 
 #define TRACK_SELECTOR_TABLEVIEW_CELL @"track selector table view cell"
 #define TRACK_SELECTOR_TABLEVIEW_SECTIONHEADER @"track selector table view section header"
@@ -1720,22 +1718,25 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
         return;
 
     NSString * hudString = @" ";
+    int swipeDuration = (int)(_mediaDuration*0.001*0.05);
 
     if (swipeRecognizer.direction == UISwipeGestureRecognizerDirectionRight) {
         double timeRemainingDouble = (-_mediaPlayer.remainingTime.intValue*0.001);
         int timeRemaining = timeRemainingDouble;
 
-        if (FORWARD_SWIPE_DURATION < timeRemaining) {
-            [_mediaPlayer jumpForward:FORWARD_SWIPE_DURATION];
-            hudString = [NSString stringWithFormat:@"⇒ %is", FORWARD_SWIPE_DURATION];
+        if (swipeDuration < timeRemaining) {
+            if (swipeDuration < 1)
+                swipeDuration = 1;
+            [_mediaPlayer jumpForward:swipeDuration];
+            hudString = [NSString stringWithFormat:@"⇒ %is", swipeDuration];
         } else {
             [_mediaPlayer jumpForward:(timeRemaining - 5)];
             hudString = [NSString stringWithFormat:@"⇒ %is",(timeRemaining - 5)];
         }
     }
     else if (swipeRecognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
-        [_mediaPlayer jumpBackward:BACKWARD_SWIPE_DURATION];
-        hudString = [NSString stringWithFormat:@"⇐ %is",BACKWARD_SWIPE_DURATION];
+        [_mediaPlayer jumpBackward:swipeDuration];
+        hudString = [NSString stringWithFormat:@"⇐ %is",swipeDuration];
     }
 
     if (swipeRecognizer.state == UIGestureRecognizerStateEnded) {