Commit 48462549 authored by Andrew Breckenridge's avatar Andrew Breckenridge Committed by Carola

key command: add playback speed key commands

] to increase playback rate by 50%
[ to decrease playback rate by 25%
= to reset the playback rate, only shown when the playback rate isn't 1
parent 40b4f52e
......@@ -942,12 +942,22 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
- (NSArray<UIKeyCommand *> *)keyCommands
{
return @[
[UIKeyCommand keyCommandWithInput:@" " modifierFlags:0 action:@selector(playPause) discoverabilityTitle:@"Play/Pause"],
[UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(playPause) discoverabilityTitle:@"Play/Pause"],
[UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:0 action:@selector(keyBackward) discoverabilityTitle:@"Skip Back"],
[UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:0 action:@selector(keyForward) discoverabilityTitle:@"Skip Forward"],
];
NSMutableArray<UIKeyCommand *> *commands = [NSMutableArray arrayWithObjects:
[UIKeyCommand keyCommandWithInput:@" " modifierFlags:0 action:@selector(playPause) discoverabilityTitle:@"Play/Pause"],
[UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(playPause) discoverabilityTitle:@"Play/Pause"],
[UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:0 action:@selector(keyBackward) discoverabilityTitle:@"Skip Back"],
[UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:0 action:@selector(keyForward) discoverabilityTitle:@"Skip Forward"],
[UIKeyCommand keyCommandWithInput:@"[" modifierFlags:0 action:@selector(keyLeftBracket) discoverabilityTitle:@"Decrease playback speed"],
[UIKeyCommand keyCommandWithInput:@"]" modifierFlags:0 action:@selector(keyRightBracket) discoverabilityTitle:@"Increase playback speed"],
nil];
bool playbackRateIsOne = ((fabsf(_vpc.playbackRate) - 1) < FLT_EPSILON);
if (playbackRateIsOne) {
UIKeyCommand *resetPlaybackCommand = [UIKeyCommand keyCommandWithInput:@"=" modifierFlags:0 action:@selector(keyEqual) discoverabilityTitle:@"Reset playback speed"];
[commands addObject:resetPlaybackCommand];
}
return commands;
}
- (void)keyForward
......@@ -960,6 +970,21 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
[_vpc jumpBackward:BACKWARD_SWIPE_DURATION];
}
- (void)keyEqual
{
[_vpc setPlaybackRate:1];
}
- (void)keyLeftBracket
{
[_vpc setPlaybackRate:_vpc.playbackRate * 0.75];
}
- (void)keyRightBracket
{
[_vpc setPlaybackRate:_vpc.playbackRate * 1.5];
}
#pragma mark - controls
- (void)closePlayback:(id)sender
......
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