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

[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 @@ ...@@ -18,17 +18,21 @@
static inline NSArray * RemoteCommandCenterCommandsToHandle() static inline NSArray * RemoteCommandCenterCommandsToHandle()
{ {
MPRemoteCommandCenter *cc = [MPRemoteCommandCenter sharedCommandCenter]; MPRemoteCommandCenter *cc = [MPRemoteCommandCenter sharedCommandCenter];
return @[cc.pauseCommand, NSMutableArray *commands = [NSMutableArray arrayWithObjects:
cc.playCommand, cc.pauseCommand,
cc.stopCommand, cc.playCommand,
cc.togglePlayPauseCommand, cc.stopCommand,
cc.nextTrackCommand, cc.togglePlayPauseCommand,
cc.previousTrackCommand, cc.nextTrackCommand,
cc.skipForwardCommand, cc.previousTrackCommand,
cc.skipBackwardCommand, cc.skipForwardCommand,
cc.changePlaybackRateCommand, cc.skipBackwardCommand,
cc.changePlaybackPositionCommand, cc.changePlaybackRateCommand,
]; nil];
if (@available(iOS 9.1, *)) {
[commands addObject:cc.changePlaybackPositionCommand];
}
return commands;
} }
- (void)subscribeToRemoteCommands - (void)subscribeToRemoteCommands
...@@ -57,7 +61,6 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle() ...@@ -57,7 +61,6 @@ 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 = YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSNumber *forwardSkip = [defaults valueForKey:kVLCSettingPlaybackForwardSkipLength]; NSNumber *forwardSkip = [defaults valueForKey:kVLCSettingPlaybackForwardSkipLength];
......
...@@ -508,7 +508,10 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) { ...@@ -508,7 +508,10 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
- (void)setPlaybackPosition:(float)position - (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 - (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