Pārlūkot izejas kodu

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 12 gadi atpakaļ
vecāks
revīzija
40c85b34f0
1 mainītis faili ar 11 papildinājumiem un 1 dzēšanām
  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];