Explorar o código

Update transport bar when it becomes visible

The transport bar is being updated whenever the playback position has changed and when the transport bar is visible. This causes an old position being displayed when the playback is paused and the transport bar is not visible at that time. A previous commit fixed that problem by adding another update when the playback is paused. But this is not enough to fix all cases where the old value could be displayed. If the playback state is changing to buffering because there is a switch between two media, the bar is also not being updated. And there are probably more cases where this happens. This commit therefore takes a more general approach to solve the problem by updating the transport bar whenever it becomes visible.

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Benjamin Adolphi %!s(int64=9) %!d(string=hai) anos
pai
achega
ca408dd9c2
Modificáronse 1 ficheiros con 8 adicións e 8 borrados
  1. 8 8
      Apple-TV/Playback/VLCFullscreenMovieTVViewController.m

+ 8 - 8
Apple-TV/Playback/VLCFullscreenMovieTVViewController.m

@@ -747,6 +747,11 @@ static const NSInteger VLCJumpInterval = 10000; // 10 seconds
 
     if (self.bottomOverlayView.alpha == 0.0) {
         [self animatePlaybackControlsToVisibility:YES];
+
+        // We need an additional update here because in some cases (e.g. when the playback was
+        // paused or started buffering), the transport bar is only updated when it is visible
+        // and if the playback is interrupted, no updates of the transport bar are triggered.
+        [self updateTransportBarPosition];
     }
     [self hidePlaybackControlsIfNeededAfterDelay];
 }
@@ -817,12 +822,6 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
         [self hidePlaybackControlsIfNeededAfterDelay];
     } else {
         [self showPlaybackControlsIfNeededForUserInteraction];
-
-        // We need an additional update here in case the playback was paused because the transport bar is only updated when it
-        // is visible and if the playback is paused, no updates of the transport bar are triggered.
-        if (currentState == VLCMediaPlayerStatePaused) {
-            [self updateTransportBarPosition:controller];
-        }
     }
 
     if (controller.isPlaying && !self.bufferingLabel.hidden) {
@@ -911,8 +910,9 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 
 #pragma mark -
 
-- (void)updateTransportBarPosition:(VLCPlaybackController *)controller
+- (void)updateTransportBarPosition
 {
+    VLCPlaybackController *controller = [VLCPlaybackController sharedInstance];
     VLCMediaPlayer *mediaPlayer = controller.mediaPlayer;
     VLCTransportBar *transportBar = self.transportBar;
     transportBar.remainingTimeLabel.text = [[mediaPlayer remainingTime] stringValue];
@@ -926,7 +926,7 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
     [self updateActivityIndicatorForState:VLCMediaPlayerStatePlaying];
 
     if (self.bottomOverlayView.alpha != 0.0) {
-        [self updateTransportBarPosition:controller];
+        [self updateTransportBarPosition];
     }
 }