فهرست منبع

Movie View: allow user to tap on time display to toggle between elapsed and remaining time (setting retained throughout sessions)

Felix Paul Kühne 12 سال پیش
والد
کامیت
1fe4f90213
2فایلهای تغییر یافته به همراه32 افزوده شده و 4 حذف شده
  1. 2 0
      AspenProject/VLCConstants.h
  2. 30 4
      AspenProject/VLCMovieViewController.m

+ 2 - 0
AspenProject/VLCConstants.h

@@ -17,5 +17,7 @@
 #define kVLCSettingTextEncoding @"subsdec-encoding"
 #define kVLCSettingTextEncodingDefaultValue @"Windows-1252"
 
+#define kVLCShowRemainingTime @"show-remaining-time"
+
 #define kSupportedFileExtensions @"\\.(3gp|3gp|3gp2|3gpp|amv|asf|avi|axv|divx|dv|flv|f4v|gvi|gxf|m1v|m2p|m2t|m2ts|m2v|m4v|mks|mkv|moov|mov|mp2v|mp4|mpeg|mpeg1|mpeg2|mpeg4|mpg|mpv|mt2s|mts|mxf|nsv|nuv|oga|ogg|ogm|ogv|ogx|spx|ps|qt|rar|rec|rm|rmvb|tod|ts|tts|vob|vro|webm|wm|wmv|wtv|xesc)$"
 #define kSupportedSubtitleFileExtensions @"\\.(cdg|idx|srt|sub|utf|ass|ssa|aqt|jss|psb|rt|smi|txt|smil)$"

+ 30 - 4
AspenProject/VLCMovieViewController.m

@@ -16,6 +16,7 @@
 {
     BOOL _shouldResumePlaying;
     BOOL _viewAppeared;
+    BOOL _displayRemainingTime;
 }
 
 @property (nonatomic, strong) UIPopoverController *masterPopoverController;
@@ -24,6 +25,15 @@
 
 @implementation VLCMovieViewController
 
++ (void)initialize
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+
+    NSDictionary *appDefaults = @{kVLCShowRemainingTime : @(YES)};
+
+    [defaults registerDefaults:appDefaults];
+}
+
 - (void)dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -74,9 +84,15 @@
         [self showOnExternalDisplay];
 
     _movieView.userInteractionEnabled = NO;
-    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleControlsVisible)];
-    recognizer.delegate = self;
-    [self.view addGestureRecognizer:recognizer];
+    UITapGestureRecognizer *tapOnVideoRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleControlsVisible)];
+    tapOnVideoRecognizer.delegate = self;
+    [self.view addGestureRecognizer:tapOnVideoRecognizer];
+
+    UITapGestureRecognizer *tapOnTimeRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleTimeDisplay)];
+    self.timeDisplay.userInteractionEnabled = YES;
+    [self.timeDisplay addGestureRecognizer:tapOnTimeRecognizer];
+
+    _displayRemainingTime = [[[NSUserDefaults standardUserDefaults] objectForKey:kVLCShowRemainingTime] boolValue];
 
 #if 0 // FIXME: trac #8742
     UISwipeGestureRecognizer *leftSwipeRecognizer = [[VLCHorizontalSwipeGestureRecognizer alloc] initWithTarget:self action:nil];
@@ -241,6 +257,8 @@
     [super viewDidDisappear:animated];
     [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
     [self resignFirstResponder];
+
+    [[NSUserDefaults standardUserDefaults] setBool:_displayRemainingTime forKey:kVLCShowRemainingTime];
 }
 
 - (BOOL)canBecomeFirstResponder
@@ -386,7 +404,10 @@
 
 - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification {
     self.positionSlider.value = [_mediaPlayer position];
-    self.timeDisplay.text = [[_mediaPlayer remainingTime] stringValue];
+    if (_displayRemainingTime)
+        self.timeDisplay.text = [[_mediaPlayer remainingTime] stringValue];
+    else
+        self.timeDisplay.text = [[_mediaPlayer time] stringValue];
 }
 
 - (void)mediaPlayerStateChanged:(NSNotification *)aNotification
@@ -480,6 +501,11 @@
     }
 }
 
+- (void)toggleTimeDisplay
+{
+    _displayRemainingTime = !_displayRemainingTime;
+}
+
 #pragma mark - swipe gestures
 
 - (void)horizontalSwipePercentage:(CGFloat)percentage inView:(UIView *)view