Commit 39e96176 authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

[Playback] Enable scrubbing from iOS control center

parent 7acee25e
......@@ -24,6 +24,7 @@
- (void)remoteControlService:(VLCRemoteControlService *)rcs jumpBackwardInSeconds:(NSTimeInterval)seconds;
- (NSInteger)remoteControlServiceNumberOfMediaItemsinList:(VLCRemoteControlService *)rcs;
- (void)remoteControlService:(VLCRemoteControlService *)rcs setPlaybackRate:(CGFloat)playbackRate;
- (void)remoteControlService:(VLCRemoteControlService *)rcs setCurrentPlaybackTime:(NSTimeInterval)playbackTime;
@end
......
......@@ -27,6 +27,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
cc.skipForwardCommand,
cc.skipBackwardCommand,
cc.changePlaybackRateCommand,
cc.changePlaybackPositionCommand,
];
}
......@@ -56,7 +57,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
commandCenter.changeShuffleModeCommand.enabled = NO;
commandCenter.seekForwardCommand.enabled = NO;
commandCenter.seekBackwardCommand.enabled = NO;
commandCenter.changePlaybackPositionCommand.enabled = NO;
commandCenter.changePlaybackPositionCommand.enabled = YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSNumber *forwardSkip = [defaults valueForKey:kVLCSettingPlaybackForwardSkipLength];
......@@ -125,6 +126,11 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
[_remoteControlServiceDelegate remoteControlService:self setPlaybackRate:rateEvent.playbackRate];
return MPRemoteCommandHandlerStatusSuccess;
}
if (event.command == cc.changePlaybackPositionCommand) {
MPChangePlaybackPositionCommandEvent *positionEvent = (MPChangePlaybackPositionCommandEvent *)event;
[_remoteControlServiceDelegate remoteControlService:self setCurrentPlaybackTime:positionEvent.positionTime];
return MPRemoteCommandHandlerStatusSuccess;
}
NSAssert(NO, @"remote control event not handled");
APLog(@"%s Wasn't able to handle remote control event: %@",__PRETTY_FUNCTION__,event);
return MPRemoteCommandHandlerStatusCommandFailed;
......
......@@ -1263,6 +1263,13 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
{
self.playbackRate = playbackRate;
}
- (void)remoteControlService:(VLCRemoteControlService *)rcs setCurrentPlaybackTime:(NSTimeInterval)playbackTime
{
float positionDiff = playbackTime - [self.metadata.elapsedPlaybackTime floatValue];
[_mediaPlayer jumpForward:positionDiff];
}
#pragma mark - helpers
- (NSDictionary *)mediaOptionsDictionary
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment