瀏覽代碼

iOS: Fix saving of the last timeleft display method

updateDefaults() method is called when the playback is closed resetting the value of _displayRemainingTime
just before viewWillDisappear() method which writes _displayRemainingTime in the UserDefaults.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Soomin Lee 8 年之前
父節點
當前提交
75906366db
共有 1 個文件被更改,包括 9 次插入3 次删除
  1. 9 3
      Sources/VLCMovieViewController.m

+ 9 - 3
Sources/VLCMovieViewController.m

@@ -86,6 +86,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     BOOL _closeGestureEnabled;
     BOOL _variableJumpDurationEnabled;
     BOOL _mediaHasProjection;
+    BOOL _playbackWillClose;
 
     UIPinchGestureRecognizer *_pinchRecognizer;
     VLCPanType _currentPanType;
@@ -443,6 +444,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
 {
     [super viewDidAppear:animated];
     _viewAppeared = YES;
+    _playbackWillClose = NO;
 
     [_vpc recoverDisplayedMetadata];
     _vpc.videoOutputView = nil;
@@ -533,11 +535,14 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     [super dismissViewControllerAnimated:flag completion:completion];
 }
 
-- (void) updateDefaults
+- (void)updateDefaults
 {
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    _displayRemainingTime = [[defaults objectForKey:kVLCShowRemainingTime] boolValue];
-    [self updateTimeDisplayButton];
+
+    if (!_playbackWillClose) {
+        _displayRemainingTime = [[defaults objectForKey:kVLCShowRemainingTime] boolValue];
+        [self updateTimeDisplayButton];
+    }
 
     _volumeGestureEnabled = [[defaults objectForKey:kVLCSettingVolumeGesture] boolValue];
     _playPauseGestureEnabled = [[defaults objectForKey:kVLCSettingPlayPauseGesture] boolValue];
@@ -726,6 +731,7 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
 - (IBAction)closePlayback:(id)sender
 {
     LOCKCHECK;
+    _playbackWillClose = YES;
     [_vpc stopPlayback];
 }