Commit 1554eb2d authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: implemented both skipping within an item and item changing for the...

macosx: implemented both skipping within an item and item changing for the forward/backward buttons (closes #4943)
parent 496bd7cd
...@@ -77,6 +77,11 @@ ...@@ -77,6 +77,11 @@
NSImage * o_shuffle_pressed_img; NSImage * o_shuffle_pressed_img;
NSImage * o_shuffle_on_img; NSImage * o_shuffle_on_img;
NSImage * o_shuffle_on_pressed_img; NSImage * o_shuffle_on_pressed_img;
NSTimeInterval last_fwd_event;
NSTimeInterval last_bwd_event;
BOOL just_triggered_next;
BOOL just_triggered_previous;
} }
+ (VLCMainWindow *)sharedInstance; + (VLCMainWindow *)sharedInstance;
......
...@@ -215,15 +215,82 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -215,15 +215,82 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[VLCCoreInteraction sharedInstance] play]; [[VLCCoreInteraction sharedInstance] play];
} }
// TODO: we need more advanced handling for the next 2 actions to handling skipping as well - (void)resetPreviousButton
{
if (([NSDate timeIntervalSinceReferenceDate] - last_bwd_event) >= 0.35) {
// seems like no further event occured, so let's switch the playback item
[[VLCCoreInteraction sharedInstance] previous];
just_triggered_previous = NO;
}
}
- (void)resetBackwardSkip
{
// the user stopped skipping, so let's allow him to change the item
if (([NSDate timeIntervalSinceReferenceDate] - last_bwd_event) >= 0.35)
just_triggered_previous = NO;
}
- (IBAction)bwd:(id)sender - (IBAction)bwd:(id)sender
{ {
[[VLCCoreInteraction sharedInstance] previous]; if(!just_triggered_previous)
{
just_triggered_previous = YES;
[self performSelector:@selector(resetPreviousButton)
withObject: NULL
afterDelay:0.40];
}
else
{
if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) > 0.12 )
{
// we just skipped 3 "continous" events, otherwise we are too fast
[[VLCCoreInteraction sharedInstance] backward];
last_bwd_event = [NSDate timeIntervalSinceReferenceDate];
[self performSelector:@selector(resetBackwardSkip)
withObject: NULL
afterDelay:0.40];
}
}
}
- (void)resetNextButton
{
if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) >= 0.35) {
// seems like no further event occured, so let's switch the playback item
[[VLCCoreInteraction sharedInstance] next];
just_triggered_next = NO;
}
}
- (void)resetForwardSkip
{
// the user stopped skipping, so let's allow him to change the item
if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) >= 0.35)
just_triggered_next = NO;
} }
- (IBAction)fwd:(id)sender - (IBAction)fwd:(id)sender
{ {
[[VLCCoreInteraction sharedInstance] next]; if(!just_triggered_next)
{
just_triggered_next = YES;
[self performSelector:@selector(resetNextButton)
withObject: NULL
afterDelay:0.40];
}
else
{
if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) > 0.12 )
{
// we just skipped 3 "continous" events, otherwise we are too fast
[[VLCCoreInteraction sharedInstance] forward];
last_fwd_event = [NSDate timeIntervalSinceReferenceDate];
[self performSelector:@selector(resetForwardSkip)
withObject: NULL
afterDelay:0.40];
}
}
} }
- (IBAction)stop:(id)sender - (IBAction)stop:(id)sender
...@@ -585,4 +652,4 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -585,4 +652,4 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
} }
@end @end
\ No newline at end of file
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