📄 vout.m
字号:
newsize.width = (int) ( i_corrected_width * factor ); newsize.height = (int) ( p_vout->render.i_height * factor ); } else { i_corrected_height = p_vout->render.i_width * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect; newsize.width = (int) ( p_vout->render.i_width * factor ); newsize.height = (int) ( i_corrected_height * factor ); } [self setContentSize: newsize]; [self setFrameTopLeftPoint: topleftscreen]; p_vout->i_changes |= VOUT_SIZE_CHANGE; }}- (void)toggleFloatOnTop{ vlc_value_t val; if( var_Get( p_real_vout, "video-on-top", &val )>=0 && val.b_bool) { val.b_bool = VLC_FALSE; } else { val.b_bool = VLC_TRUE; } var_Set( p_real_vout, "video-on-top", val );}- (void)toggleFullscreen{ vlc_value_t val; var_Get( p_real_vout, "fullscreen", &val ); val.b_bool = !val.b_bool; var_Set( p_real_vout, "fullscreen", val );}- (BOOL)isFullscreen{ vlc_value_t val; var_Get( p_real_vout, "fullscreen", &val ); return( val.b_bool );}- (void)snapshot{ vout_Control( p_real_vout, VOUT_SNAPSHOT );}- (BOOL)canBecomeKeyWindow{ return YES;}/* Sometimes crashes VLC....- (BOOL)performKeyEquivalent:(NSEvent *)o_event{ return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];}*/- (void)keyDown:(NSEvent *)o_event{ unichar key = 0; vlc_value_t val; unsigned int i_pressed_modifiers = 0; val.i_int = 0; i_pressed_modifiers = [o_event modifierFlags]; if( i_pressed_modifiers & NSShiftKeyMask ) val.i_int |= KEY_MODIFIER_SHIFT; if( i_pressed_modifiers & NSControlKeyMask ) val.i_int |= KEY_MODIFIER_CTRL; if( i_pressed_modifiers & NSAlternateKeyMask ) val.i_int |= KEY_MODIFIER_ALT; if( i_pressed_modifiers & NSCommandKeyMask ) val.i_int |= KEY_MODIFIER_COMMAND; key = [[o_event charactersIgnoringModifiers] characterAtIndex: 0]; if( key ) { /* Escape should always get you out of fullscreen */ if( key == (unichar) 0x1b ) { if( [self isFullscreen] ) { [self toggleFullscreen]; } } else if ( key == ' ' ) { vlc_value_t val; val.i_int = config_GetInt( p_vout, "key-play-pause" ); var_Set( p_vout->p_vlc, "key-pressed", val ); } else { val.i_int |= CocoaKeyToVLC( key ); var_Set( p_vout->p_vlc, "key-pressed", val ); } } else { [super keyDown: o_event]; }}- (void)updateTitle{ NSMutableString * o_title = NULL, * o_mrl = NULL; input_thread_t * p_input; if( p_vout == NULL ) { return; } p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, FIND_PARENT ); if( p_input == NULL ) { return; } if( p_input->input.p_item->psz_name != NULL ) o_title = [NSMutableString stringWithUTF8String: p_input->input.p_item->psz_name]; if( p_input->input.p_item->psz_uri != NULL ) o_mrl = [NSMutableString stringWithUTF8String: p_input->input.p_item->psz_uri]; if( o_title == nil ) o_title = o_mrl; vlc_object_release( p_input ); if( o_mrl != nil ) { if( p_input->input.p_access && !strcmp( p_input->input.p_access->p_module->psz_shortname, "File" ) ) { NSRange prefix_range = [o_mrl rangeOfString: @"file:"]; if( prefix_range.location != NSNotFound ) [o_mrl deleteCharactersInRange: prefix_range]; [self setRepresentedFilename: o_mrl]; } [self setTitle: o_title]; } else { [self setTitle: [NSString stringWithCString: VOUT_TITLE]]; }}/* This is actually the same as VLCControls::stop. */- (BOOL)windowShouldClose:(id)sender{ playlist_t * p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return NO; } playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); /* The window will be closed by the intf later. */ return NO;}- (BOOL)acceptsFirstResponder{ return YES;}- (BOOL)becomeFirstResponder{ return YES;}- (BOOL)resignFirstResponder{ /* We need to stay the first responder or we'll miss some events */ return NO;}- (void)mouseDown:(NSEvent *)o_event{ vlc_value_t val; switch( [o_event type] ) { case NSLeftMouseDown: { var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 1; var_Set( p_vout, "mouse-button-down", val ); } break; default: [super mouseDown: o_event]; break; }}- (void)otherMouseDown:(NSEvent *)o_event{ vlc_value_t val; switch( [o_event type] ) { case NSOtherMouseDown: { var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 2; var_Set( p_vout, "mouse-button-down", val ); } break; default: [super mouseDown: o_event]; break; }}- (void)rightMouseDown:(NSEvent *)o_event{ vlc_value_t val; switch( [o_event type] ) { case NSRightMouseDown: { var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 4; var_Set( p_vout, "mouse-button-down", val ); } break; default: [super mouseDown: o_event]; break; }}- (void)mouseUp:(NSEvent *)o_event{ vlc_value_t val; switch( [o_event type] ) { case NSLeftMouseUp: { vlc_value_t b_val; b_val.b_bool = VLC_TRUE; var_Set( p_vout, "mouse-clicked", b_val ); var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~1; var_Set( p_vout, "mouse-button-down", val ); } break; default: [super mouseUp: o_event]; break; }}- (void)otherMouseUp:(NSEvent *)o_event{ vlc_value_t val; switch( [o_event type] ) { case NSOtherMouseUp: { var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~2; var_Set( p_vout, "mouse-button-down", val ); } break; default: [super mouseUp: o_event]; break; }}- (void)rightMouseUp:(NSEvent *)o_event{ vlc_value_t val; switch( [o_event type] ) { case NSRightMouseUp: { var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~4; var_Set( p_vout, "mouse-button-down", val ); } break; default: [super mouseUp: o_event]; break; }}- (void)mouseDragged:(NSEvent *)o_event{ [self mouseMoved: o_event];}- (void)otherMouseDragged:(NSEvent *)o_event{ [self mouseMoved: o_event];}- (void)rightMouseDragged:(NSEvent *)o_event{ [self mouseMoved: o_event];}- (void)mouseMoved:(NSEvent *)o_event{ NSPoint ml; NSRect s_rect; BOOL b_inside; i_time_mouse_last_moved = mdate(); s_rect = [o_view bounds]; ml = [o_view convertPoint: [o_event locationInWindow] fromView: nil]; b_inside = [o_view mouse: ml inRect: s_rect]; if( b_inside ) { vlc_value_t val; unsigned int i_width, i_height, i_x, i_y; vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width, (unsigned int)s_rect.size.height, &i_x, &i_y, &i_width, &i_height ); val.i_int = ( ((int)ml.x) - i_x ) * p_vout->render.i_width / i_width; var_Set( p_vout, "mouse-x", val ); if( [[o_view className] isEqualToString: @"VLCGLView"] ) { val.i_int = ( ((int)(s_rect.size.height - ml.y)) - i_y ) * p_vout->render.i_height / i_height; } else { val.i_int = ( ((int)ml.y) - i_y ) * p_vout->render.i_height / i_height; } var_Set( p_vout, "mouse-y", val ); val.b_bool = VLC_TRUE; var_Set( p_vout, "mouse-moved", val ); } [super mouseMoved: o_event];}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -