intf.m
来自「VLC媒体播放程序」· M 代码 · 共 1,410 行 · 第 1/4 页
M
1,410 行
{ audio_volume_t i_volume; intf_thread_t * p_intf = [NSApp getIntf]; aout_VolumeGet( p_intf, &i_volume ); [o_volumeslider setFloatValue: (float)i_volume / AOUT_VOLUME_STEP]; [o_volumeslider setEnabled: TRUE]; p_intf->p_sys->b_mute = ( i_volume == 0 );}- (IBAction)timesliderUpdate:(id)sender{ intf_thread_t * p_intf; input_thread_t * p_input; float f_updated; switch( [[NSApp currentEvent] type] ) { case NSLeftMouseUp: case NSLeftMouseDown: case NSLeftMouseDragged: f_updated = [sender floatValue]; break; default: return; } p_intf = [NSApp getIntf]; p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input != NULL ) { vlc_value_t time; mtime_t i_seconds; NSString * o_time; if( p_input->stream.b_seekable ) { vlc_value_t pos; pos.f_float = f_updated / 10000.; if( f_slider != f_updated ) { var_Set( p_input, "position", pos ); [o_timeslider setFloatValue: f_updated]; } } var_Get( p_input, "time", &time ); i_seconds = time.i_time / 1000000; o_time = [NSString stringWithFormat: @"%d:%02d:%02d", (int) (i_seconds / (60 * 60)), (int) (i_seconds / 60 % 60), (int) (i_seconds % 60)]; [o_timefield setStringValue: o_time]; vlc_object_release( p_input ); }}- (void)terminate{ NSEvent * o_event; playlist_t * p_playlist; vout_thread_t * p_vout; intf_thread_t * p_intf = [NSApp getIntf]; /* Stop playback */ if( ( p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ) ) ) { playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); } /* FIXME - Wait here until all vouts are terminated because libvlc's VLC_Stop destroys interfaces before vouts, which isn't good on OS X. We definitly need a cleaner way to handle this, but this may hopefully be good enough for now. -- titer 2003/11/22 */ while( ( p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ) ) ) { vlc_object_release( p_vout ); msleep( 100000 ); } msleep( 500000 ); if( o_img_pause_pressed != nil ) { [o_img_pause_pressed release]; o_img_pause_pressed = nil; } if( o_img_pause_pressed != nil ) { [o_img_pause_pressed release]; o_img_pause_pressed = nil; } if( o_img_pause != nil ) { [o_img_pause release]; o_img_pause = nil; } if( o_img_play != nil ) { [o_img_play release]; o_img_play = nil; } if( o_msg_arr != nil ) { [o_msg_arr removeAllObjects]; [o_msg_arr release]; o_msg_arr = nil; } if( o_msg_lock != nil ) { [o_msg_lock release]; o_msg_lock = nil; } [NSApp stop: nil]; /* write cached user defaults to disk */ [[NSUserDefaults standardUserDefaults] synchronize]; /* send a dummy event to break out of the event loop */ o_event = [NSEvent mouseEventWithType: NSLeftMouseDown location: NSMakePoint( 1, 1 ) modifierFlags: 0 timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber] context: [NSGraphicsContext currentContext] eventNumber: 1 clickCount: 1 pressure: 0.0]; [NSApp postEvent: o_event atStart: YES];}- (IBAction)clearRecentItems:(id)sender{ [[NSDocumentController sharedDocumentController] clearRecentDocuments: nil];}- (void)openRecentItem:(id)sender{ [self application: nil openFile: [sender title]]; }- (IBAction)viewPreferences:(id)sender{ [o_prefs showPrefs];}- (IBAction)closeError:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = [NSApp getIntf]; if( [o_err_ckbk_surpress state] == NSOnState ) { val.i_int = -1; var_Set( p_intf->p_vlc, "verbose", val ); } [o_err_msg setString: @""]; [o_error performClose: self];}- (IBAction)openReadMe:(id)sender{ NSString * o_path = [[NSBundle mainBundle] pathForResource: @"README.MacOSX" ofType: @"rtf"]; [[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"TextEdit"];}- (IBAction)openDocumentation:(id)sender{ NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/doc/"]; [[NSWorkspace sharedWorkspace] openURL: o_url];}- (IBAction)reportABug:(id)sender{ NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/support/bug-reporting.html"]; [[NSWorkspace sharedWorkspace] openURL: o_url];}- (IBAction)openWebsite:(id)sender{ NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org/"]; [[NSWorkspace sharedWorkspace] openURL: o_url];}- (IBAction)openLicense:(id)sender{ NSString * o_path = [[NSBundle mainBundle] pathForResource: @"COPYING" ofType: nil]; [[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"TextEdit"];}- (IBAction)openCrashLog:(id)sender{ NSString * o_path = [@"~/Library/Logs/CrashReporter/VLC.crash.log" stringByExpandingTildeInPath]; if ( [[NSFileManager defaultManager] fileExistsAtPath: o_path ] ) { [[NSWorkspace sharedWorkspace] openFile: o_path withApplication: @"Console"]; } else { NSBeginInformationalAlertSheet(_NS("No CrashLog found"), @"Continue", nil, nil, o_msgs_panel, self, NULL, NULL, nil, _NS("Either you are running Mac OS X pre 10.2 or you haven't experienced any heavy crashes yet.") ); }}- (void)windowDidBecomeKey:(NSNotification *)o_notification{ if( [o_notification object] == o_msgs_panel ) { id o_msg; NSEnumerator * o_enum; [o_messages setString: @""]; [o_msg_lock lock]; o_enum = [o_msg_arr objectEnumerator]; while( ( o_msg = [o_enum nextObject] ) != nil ) { [o_messages insertText: o_msg]; } [o_msg_lock unlock]; }}@end@implementation VLCMain (NSMenuValidation)- (BOOL)validateMenuItem:(NSMenuItem *)o_mi{ NSString *o_title = [o_mi title]; BOOL bEnabled = TRUE; if( [o_title isEqualToString: _NS("License")] ) { /* we need to do this only once */ [self setupMenus]; } /* Recent Items Menu */ if( [o_title isEqualToString: _NS("Clear Menu")] ) { NSMenu * o_menu = [o_mi_open_recent submenu]; int i_nb_items = [o_menu numberOfItems]; NSArray * o_docs = [[NSDocumentController sharedDocumentController] recentDocumentURLs]; UInt32 i_nb_docs = [o_docs count]; if( i_nb_items > 1 ) { while( --i_nb_items ) { [o_menu removeItemAtIndex: 0]; } } if( i_nb_docs > 0 ) { NSURL * o_url; NSString * o_doc; [o_menu insertItem: [NSMenuItem separatorItem] atIndex: 0]; while( TRUE ) { i_nb_docs--; o_url = [o_docs objectAtIndex: i_nb_docs]; if( [o_url isFileURL] ) { o_doc = [o_url path]; } else { o_doc = [o_url absoluteString]; } [o_menu insertItemWithTitle: o_doc action: @selector(openRecentItem:) keyEquivalent: @"" atIndex: 0]; if( i_nb_docs == 0 ) { break; } } } else { bEnabled = FALSE; } } return( bEnabled );}@end@implementation VLCMain (Internal)- (void)handlePortMessage:(NSPortMessage *)o_msg{ id ** val; NSData * o_data; NSValue * o_value; NSInvocation * o_inv; NSConditionLock * o_lock; o_data = [[o_msg components] lastObject]; o_inv = *((NSInvocation **)[o_data bytes]); [o_inv getArgument: &o_value atIndex: 2]; val = (id **)[o_value pointerValue]; [o_inv setArgument: val[1] atIndex: 2]; o_lock = *(val[0]); [o_lock lock]; [o_inv invoke]; [o_lock unlockWithCondition: 1];}@end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?