Explorar o código

Movie View: improve continue-where-left-off playback behavior, so we no longer show the clip's first frame but jump directly to the last position

Note that this requires a recent libvlc checkout due to underlying, required improvements merged last week
Felix Paul Kühne %!s(int64=12) %!d(string=hai) anos
pai
achega
40c85b34f0
Modificáronse 1 ficheiros con 11 adicións e 1 borrados
  1. 11 1
      AspenProject/VLCMovieViewController.m

+ 11 - 1
AspenProject/VLCMovieViewController.m

@@ -204,10 +204,20 @@
 
 - (void)_playNewMedia
 {
+    if (self.mediaItem.lastPosition && [self.mediaItem.lastPosition floatValue] < .95) {
+        if (self.mediaItem.duration.intValue != 0) {
+            NSNumber *playbackPositionInTime = @(self.mediaItem.lastPosition.floatValue * (self.mediaItem.duration.intValue / 1000.));
+            [_mediaPlayer.media addOptions:@{@"start-time": playbackPositionInTime}];
+            APLog(@"set starttime to %i", playbackPositionInTime.intValue);
+        }
+    }
+
     [_mediaPlayer play];
 
-    if (self.mediaItem.lastPosition && [self.mediaItem.lastPosition floatValue] < .95)
+    /* fallback if an invalid duration was reported by MLKit */
+    if (self.mediaItem.duration.intValue == 0 && self.mediaItem.lastPosition && [self.mediaItem.lastPosition floatValue] < .95)
         [_mediaPlayer setPosition:[self.mediaItem.lastPosition floatValue]];
+
     self.playbackSpeedSlider.value = [self _playbackSpeed];
     [self _updatePlaybackSpeedIndicator];