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

[Playback] Enable scrubbing from iOS control center

parent 7acee25e
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
- (void)remoteControlService:(VLCRemoteControlService *)rcs jumpBackwardInSeconds:(NSTimeInterval)seconds; - (void)remoteControlService:(VLCRemoteControlService *)rcs jumpBackwardInSeconds:(NSTimeInterval)seconds;
- (NSInteger)remoteControlServiceNumberOfMediaItemsinList:(VLCRemoteControlService *)rcs; - (NSInteger)remoteControlServiceNumberOfMediaItemsinList:(VLCRemoteControlService *)rcs;
- (void)remoteControlService:(VLCRemoteControlService *)rcs setPlaybackRate:(CGFloat)playbackRate; - (void)remoteControlService:(VLCRemoteControlService *)rcs setPlaybackRate:(CGFloat)playbackRate;
- (void)remoteControlService:(VLCRemoteControlService *)rcs setCurrentPlaybackTime:(NSTimeInterval)playbackTime;
@end @end
......
...@@ -27,6 +27,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle() ...@@ -27,6 +27,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
cc.skipForwardCommand, cc.skipForwardCommand,
cc.skipBackwardCommand, cc.skipBackwardCommand,
cc.changePlaybackRateCommand, cc.changePlaybackRateCommand,
cc.changePlaybackPositionCommand,
]; ];
} }
...@@ -56,7 +57,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle() ...@@ -56,7 +57,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
commandCenter.changeShuffleModeCommand.enabled = NO; commandCenter.changeShuffleModeCommand.enabled = NO;
commandCenter.seekForwardCommand.enabled = NO; commandCenter.seekForwardCommand.enabled = NO;
commandCenter.seekBackwardCommand.enabled = NO; commandCenter.seekBackwardCommand.enabled = NO;
commandCenter.changePlaybackPositionCommand.enabled = NO; commandCenter.changePlaybackPositionCommand.enabled = YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSNumber *forwardSkip = [defaults valueForKey:kVLCSettingPlaybackForwardSkipLength]; NSNumber *forwardSkip = [defaults valueForKey:kVLCSettingPlaybackForwardSkipLength];
...@@ -125,6 +126,11 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle() ...@@ -125,6 +126,11 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
[_remoteControlServiceDelegate remoteControlService:self setPlaybackRate:rateEvent.playbackRate]; [_remoteControlServiceDelegate remoteControlService:self setPlaybackRate:rateEvent.playbackRate];
return MPRemoteCommandHandlerStatusSuccess; 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"); NSAssert(NO, @"remote control event not handled");
APLog(@"%s Wasn't able to handle remote control event: %@",__PRETTY_FUNCTION__,event); APLog(@"%s Wasn't able to handle remote control event: %@",__PRETTY_FUNCTION__,event);
return MPRemoteCommandHandlerStatusCommandFailed; return MPRemoteCommandHandlerStatusCommandFailed;
......
...@@ -1263,6 +1263,13 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) { ...@@ -1263,6 +1263,13 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
{ {
self.playbackRate = playbackRate; self.playbackRate = playbackRate;
} }
- (void)remoteControlService:(VLCRemoteControlService *)rcs setCurrentPlaybackTime:(NSTimeInterval)playbackTime
{
float positionDiff = playbackTime - [self.metadata.elapsedPlaybackTime floatValue];
[_mediaPlayer jumpForward:positionDiff];
}
#pragma mark - helpers #pragma mark - helpers
- (NSDictionary *)mediaOptionsDictionary - (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