📄 intf.m
字号:
*****************************************************************************/- (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event{ unichar key = 0; vlc_value_t val; unsigned int i_pressed_modifiers = 0; struct hotkey *p_hotkeys; int i; val.i_int = 0; p_hotkeys = p_intf->p_libvlc->p_hotkeys; 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]; switch( key ) { case NSDeleteCharacter: case NSDeleteFunctionKey: case NSDeleteCharFunctionKey: case NSBackspaceCharacter: case NSUpArrowFunctionKey: case NSDownArrowFunctionKey: case NSRightArrowFunctionKey: case NSLeftArrowFunctionKey: case NSEnterCharacter: case NSCarriageReturnCharacter: return NO; } val.i_int |= CocoaKeyToVLC( key ); for( i = 0; p_hotkeys[i].psz_action != NULL; i++ ) { if( p_hotkeys[i].i_key == val.i_int ) { var_Set( p_intf->p_libvlc, "key-pressed", val ); return YES; } } return NO;}#pragma mark -#pragma mark Other objects getters// FIXME: this is ugly and does not respect cocoa naming scheme- (id)getControls{ if( o_controls ) return o_controls; return nil;}- (id)getSimplePreferences{ if( !o_sprefs ) return nil; if( !nib_prefs_loaded ) nib_prefs_loaded = [NSBundle loadNibNamed:@"Preferences" owner: self]; return o_sprefs;}- (id)getPreferences{ if( !o_prefs ) return nil; if( !nib_prefs_loaded ) nib_prefs_loaded = [NSBundle loadNibNamed:@"Preferences" owner: self]; return o_prefs;}- (id)getPlaylist{ if( o_playlist ) return o_playlist; return nil;}- (id)getInfo{ if( o_info ) return o_info; return nil;}- (id)getWizard{ if( o_wizard ) return o_wizard; return nil;}- (id)getBookmarks{ if( o_bookmarks ) return o_bookmarks; return nil;}- (id)getEmbeddedList{ if( o_embedded_list ) return o_embedded_list; return nil;}- (id)getInteractionList{ if( o_interaction_list ) return o_interaction_list; return nil;}- (id)getMainIntfPgbar{ if( o_main_pgbar ) return o_main_pgbar; return nil;}- (id)getControllerWindow{ if( o_window ) return o_window; return nil;}- (id)getVoutMenu{ return o_vout_menu;}- (id)getEyeTVController{ if( o_eyetv ) return o_eyetv; return nil;}#pragma mark -#pragma mark Polling/***************************************************************************** * ManageThread: An ugly thread that polls *****************************************************************************/static void * ManageThread( void *user_data ){ id self = user_data; [self manage]; return NULL;}- (void)manage{ playlist_t * p_playlist; input_thread_t * p_input = NULL; /* new thread requires a new pool */ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); p_playlist = pl_Yield( p_intf ); var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, self ); var_AddCallback( p_playlist, "intf-change", PlaylistChanged, self ); var_AddCallback( p_playlist, "item-change", PlaylistChanged, self ); var_AddCallback( p_playlist, "item-append", PlaylistChanged, self ); var_AddCallback( p_playlist, "item-deleted", PlaylistChanged, self ); pl_Release( p_intf ); vlc_object_lock( p_intf ); while( vlc_object_alive( p_intf ) ) { vlc_mutex_lock( &p_intf->change_lock ); if( !p_input ) { p_input = playlist_CurrentInput( p_playlist ); /* Refresh the interface */ if( p_input ) { msg_Dbg( p_intf, "input has changed, refreshing interface" ); p_intf->p_sys->b_input_update = true; } } else if( !vlc_object_alive (p_input) || p_input->b_dead ) { /* input stopped */ p_intf->p_sys->b_intf_update = true; p_intf->p_sys->i_play_status = END_S; msg_Dbg( p_intf, "input has stopped, refreshing interface" ); vlc_object_release( p_input ); p_input = NULL; } else if( cachedInputState != input_GetState( p_input ) ) { p_intf->p_sys->b_intf_update = true; } /* Manage volume status */ [self manageVolumeSlider]; vlc_mutex_unlock( &p_intf->change_lock ); vlc_object_timedwait( p_intf, 100000 + mdate()); } vlc_object_unlock( p_intf ); [o_pool release]; if( p_input ) vlc_object_release( p_input ); var_DelCallback( p_playlist, "playlist-current", PlaylistChanged, self ); var_DelCallback( p_playlist, "intf-change", PlaylistChanged, self ); var_DelCallback( p_playlist, "item-change", PlaylistChanged, self ); var_DelCallback( p_playlist, "item-append", PlaylistChanged, self ); var_DelCallback( p_playlist, "item-deleted", PlaylistChanged, self ); pthread_testcancel(); /* If we were cancelled stop here */ msg_Dbg( p_intf, "Killing the Mac OS X module" ); /* We are dead, terminate */ [NSApp performSelectorOnMainThread: @selector(terminate:) withObject:nil waitUntilDone:NO];}- (void)manageVolumeSlider{ audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); if( i_volume != i_lastShownVolume ) { i_lastShownVolume = i_volume; p_intf->p_sys->b_volume_update = TRUE; }}- (void)manageIntf:(NSTimer *)o_timer{ vlc_value_t val; playlist_t * p_playlist; input_thread_t * p_input; if( p_intf->p_sys->b_input_update ) { /* Called when new input is opened */ p_intf->p_sys->b_current_title_update = true; p_intf->p_sys->b_intf_update = true; p_intf->p_sys->b_input_update = false; [self setupMenus]; /* Make sure input menu is up to date */ } if( p_intf->p_sys->b_intf_update ) { bool b_input = false; bool b_plmul = false; bool b_control = false; bool b_seekable = false; bool b_chapters = false; playlist_t * p_playlist = pl_Yield( p_intf ); /* TODO: fix i_size use */ b_plmul = p_playlist->items.i_size > 1; p_input = playlist_CurrentInput( p_playlist ); bool b_buffering = NO; if( ( b_input = ( p_input != NULL ) ) ) { /* seekable streams */ cachedInputState = input_GetState( p_input ); if ( cachedInputState == INIT_S || cachedInputState == OPENING_S || cachedInputState == BUFFERING_S ) { b_buffering = YES; } /* seekable streams */ b_seekable = var_GetBool( p_input, "seekable" ); /* check whether slow/fast motion is possible */ b_control = p_input->b_can_pace_control; /* chapters & titles */ //b_chapters = p_input->stream.i_area_nb > 1; vlc_object_release( p_input ); } pl_Release( p_intf ); if( b_buffering ) { [o_main_pgbar startAnimation:self]; [o_main_pgbar setIndeterminate:YES]; [o_main_pgbar setHidden:NO]; } else { [o_main_pgbar stopAnimation:self]; [o_main_pgbar setHidden:YES]; } [o_btn_stop setEnabled: b_input]; [o_btn_ff setEnabled: b_seekable]; [o_btn_rewind setEnabled: b_seekable]; [o_btn_prev setEnabled: (b_plmul || b_chapters)]; [o_btn_next setEnabled: (b_plmul || b_chapters)]; [o_timeslider setFloatValue: 0.0]; [o_timeslider setEnabled: b_seekable]; [o_timefield setStringValue: @"00:00"]; [[[self getControls] getFSPanel] setStreamPos: 0 andTime: @"00:00"]; [[[self getControls] getFSPanel] setSeekable: b_seekable]; [o_embedded_window setSeekable: b_seekable]; p_intf->p_sys->b_current_title_update = true; p_intf->p_sys->b_intf_update = false; } if( p_intf->p_sys->b_playmode_update ) { [o_playlist playModeUpdated]; p_intf->p_sys->b_playmode_update = false; } if( p_intf->p_sys->b_playlist_update ) { [o_playlist playlistUpdated]; p_intf->p_sys->b_playlist_update = false; } if( p_intf->p_sys->b_fullscreen_update ) { p_intf->p_sys->b_fullscreen_update = false; } if( p_intf->p_sys->b_intf_show ) { [o_window makeKeyAndOrderFront: self]; p_intf->p_sys->b_intf_show = false; } p_input = pl_CurrentInput( p_intf ); if( p_input && vlc_object_alive (p_input) ) { vlc_value_t val; if( p_intf->p_sys->b_current_title_update ) { NSString *aString; input_item_t * p_item = input_GetItem( p_input ); char * name = input_item_GetNowPlaying( p_item ); if( !name ) name = input_item_GetName( p_item ); aString = [NSString stringWithUTF8String:name];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -