Skip to content

Commit

Permalink
Add sub-delay key binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbirec committed May 1, 2016
1 parent e887983 commit d9666aa
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,69 @@
</Actions>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PeerPlayer/MpvController.m"
timestampString = "483771180.732346"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "318"
endingLineNumber = "318"
landmarkName = "-updateInfo:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PeerPlayer/MpvController.m"
timestampString = "483771180.732346"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "287"
endingLineNumber = "287"
landmarkName = "-updateInfo:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PeerPlayer/MpvController.m"
timestampString = "483771180.732346"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "305"
endingLineNumber = "305"
landmarkName = "-updateInfo:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PeerPlayer/MpvController.m"
timestampString = "483771256.417592"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "317"
endingLineNumber = "317"
landmarkName = "-updateInfo:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
2 changes: 2 additions & 0 deletions PeerPlayer/MpvController.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@property double cacheDuration; // in seconds
@property BOOL paused;
@property double volume;
@property double subDelay;

@end

Expand Down Expand Up @@ -69,5 +70,6 @@ typedef NS_ENUM(NSUInteger, PlayEndReason) {
-(void) seek:(int)seconds;
-(void) volume:(double)vol;
-(void) loadSubtitle:(NSString*)filepath;
-(void) subDelay:(double)delay;

@end
16 changes: 16 additions & 0 deletions PeerPlayer/MpvController.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ -(id) initWithWindow:(MpvWindow*) window {
mpv_observe_property(mpv, 0, "volume", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "track-list", MPV_FORMAT_NODE);
mpv_observe_property(mpv, 0, "video-params", MPV_FORMAT_NODE);
mpv_observe_property(mpv, 0, "sub-delay", MPV_FORMAT_DOUBLE);

// Deal with MPV in the background.
queue = dispatch_queue_create("mpv", DISPATCH_QUEUE_SERIAL);
Expand Down Expand Up @@ -237,6 +238,15 @@ -(void) loadSubtitle:(NSString*)filepath {
});
}

-(void) subDelay:(double)delay {
dispatch_async(queue, ^{
double d;
mpv_get_property(mpv, "sub-delay", MPV_FORMAT_DOUBLE, &d);
d += delay;
mpv_set_property(mpv, "sub-delay", MPV_FORMAT_DOUBLE, (void*)&d);
});
}

-(void) quit {
mpv_opengl_cb_uninit_gl(self.window.glView.mpvGL);
[self.window.glView clearGLContext];
Expand Down Expand Up @@ -303,6 +313,12 @@ -(void) updateInfo:(mpv_event_property*) prop {
NSDictionary* data = [MpvEvent convertProperty:prop];
[self performSelectorOnMainThread:@selector(gotVideoParam:) withObject:data waitUntilDone:NO];
}
else if(strcmp(prop->name, "sub-delay") == 0) {
self.info.subDelay = [[MpvEvent convertProperty:prop] doubleValue];
[self playInfoChanged];
}


}

- (void) readEvents
Expand Down
8 changes: 8 additions & 0 deletions PeerPlayer/RootView.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ -(void) keyDown:(NSEvent *)event
case 36:
[self.window toggleFullScreen:self];
break;
// z
case 6:
[[MpvController getInstance] subDelay:-0.1f];
break;
// x
case 7:
[[MpvController getInstance] subDelay:0.1f];
break;
// Esc
case 53:
if([self isFullscreen]) {
Expand Down

0 comments on commit d9666aa

Please sign in to comment.