Sfoglia il codice sorgente

VLCPlaybackService: State recovery: Check for media duration

In the case where the media is short (e.g. 3 sec), the last position
check wouldn't be enough to restrict the opening and closing behaviour.

Indeed, when the position is saved from the `libvlc_MediaPlayerStopped`
event. It seems that the position isn't guaranteed to be correct even at
the end of a playback.

This will match VLC Android's behaviour.
Soomin Lee 5 anni fa
parent
commit
d078b8422f
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      Sources/VLCPlaybackService.m

+ 4 - 1
Sources/VLCPlaybackService.m

@@ -1099,7 +1099,10 @@ NSString *const VLCPlaybackServicePlaybackPositionUpdated = @"VLCPlaybackService
 
     CGFloat lastPosition = media.progress;
     // .95 prevents the controller from opening and closing immediatly when restoring state
-    if (lastPosition < .95 && _mediaPlayer.position < lastPosition) {
+    //  Additionaly, check if the media is more than 10 sec
+    if (lastPosition < .95
+        && media.duration > 10000
+        && _mediaPlayer.position < lastPosition) {
         NSInteger continuePlayback;
         if (media.type == VLCMLMediaTypeAudio)
             continuePlayback = [[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinueAudioPlayback] integerValue];