From 40c85b34f0e1483f3dd7443bc646d8896d04c82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= Date: Tue, 4 Jun 2013 13:04:19 +0200 Subject: [PATCH] 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 --- AspenProject/VLCMovieViewController.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/AspenProject/VLCMovieViewController.m b/AspenProject/VLCMovieViewController.m index bb230209..aead0ad6 100644 --- a/AspenProject/VLCMovieViewController.m +++ b/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]; -- GitLab