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

[Playback] Reflect current playback position to control center

Using `jumpForward` function to reflect current playback location.
NOTE: Simply setting the `.position` of `VLCMediaPlayer` seems to not
work.
parent 68d279d7
......@@ -18,17 +18,21 @@
static inline NSArray * RemoteCommandCenterCommandsToHandle()
{
MPRemoteCommandCenter *cc = [MPRemoteCommandCenter sharedCommandCenter];
return @[cc.pauseCommand,
cc.playCommand,
cc.stopCommand,
cc.togglePlayPauseCommand,
cc.nextTrackCommand,
cc.previousTrackCommand,
cc.skipForwardCommand,
cc.skipBackwardCommand,
cc.changePlaybackRateCommand,
cc.changePlaybackPositionCommand,
];
NSMutableArray *commands = [NSMutableArray arrayWithObjects:
cc.pauseCommand,
cc.playCommand,
cc.stopCommand,
cc.togglePlayPauseCommand,
cc.nextTrackCommand,
cc.previousTrackCommand,
cc.skipForwardCommand,
cc.skipBackwardCommand,
cc.changePlaybackRateCommand,
nil];
if (@available(iOS 9.1, *)) {
[commands addObject:cc.changePlaybackPositionCommand];
}
return commands;
}
- (void)subscribeToRemoteCommands
......@@ -57,7 +61,6 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
commandCenter.changeShuffleModeCommand.enabled = NO;
commandCenter.seekForwardCommand.enabled = NO;
commandCenter.seekBackwardCommand.enabled = NO;
commandCenter.changePlaybackPositionCommand.enabled = YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSNumber *forwardSkip = [defaults valueForKey:kVLCSettingPlaybackForwardSkipLength];
......
......@@ -508,7 +508,10 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
- (void)setPlaybackPosition:(float)position
{
_mediaPlayer.position = position;
#warning Should use `position` to change position. This is a hack!
float oldPosition = _mediaPlayer.position;
float diff = position - oldPosition;
[_mediaPlayer jumpForward:(diff * self.mediaDuration)/1000.];
}
- (void)setSubtitleDelay:(float)subtitleDeleay
......
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