Skip to content

Commit

Permalink
Improve skip button behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Nov 29, 2018
1 parent 8e3258b commit d749b2d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Framework/Sources/Controllers/SRGMediaPlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,14 @@ - (BOOL)canSkipBackwardFromTime:(CMTime)time
return NO;
}

SRGMediaPlayerStreamType streamType = self.controller.streamType;
SRGMediaPlayerController *controller = self.controller;
SRGMediaPlayerPlaybackState playbackState = controller.playbackState;

if (playbackState == SRGMediaPlayerPlaybackStateIdle || playbackState == SRGMediaPlayerPlaybackStatePreparing) {
return NO;
}

SRGMediaPlayerStreamType streamType = controller.streamType;
return (streamType == SRGMediaPlayerStreamTypeOnDemand || streamType == SRGMediaPlayerStreamTypeDVR);
}

Expand All @@ -372,8 +379,15 @@ - (BOOL)canSkipForwardFromTime:(CMTime)time
}

SRGMediaPlayerController *controller = self.controller;
return (controller.streamType == SRGMediaPlayerStreamTypeOnDemand && CMTimeGetSeconds(time) + SRGMediaPlayerViewControllerForwardSkipInterval < CMTimeGetSeconds(controller.player.currentItem.duration))
|| (controller.streamType == SRGMediaPlayerStreamTypeDVR && ! controller.live);
SRGMediaPlayerPlaybackState playbackState = controller.playbackState;

if (playbackState == SRGMediaPlayerPlaybackStateIdle || playbackState == SRGMediaPlayerPlaybackStatePreparing) {
return NO;
}

SRGMediaPlayerStreamType streamType = controller.streamType;
return (streamType == SRGMediaPlayerStreamTypeOnDemand && CMTimeGetSeconds(time) + SRGMediaPlayerViewControllerForwardSkipInterval < CMTimeGetSeconds(controller.player.currentItem.duration))
|| (streamType == SRGMediaPlayerStreamTypeDVR && ! controller.live);
}

- (void)skipBackwardFromTime:(CMTime)time withCompletionHandler:(void (^)(BOOL finished))completionHandler
Expand Down

0 comments on commit d749b2d

Please sign in to comment.