📄 intf.m
字号:
}}- (char *)delocalizeString:(NSString *)id{ NSData * o_data = [id dataUsingEncoding: NSUTF8StringEncoding allowLossyConversion: NO]; char * psz_string; if ( o_data == nil ) { o_data = [id dataUsingEncoding: NSUTF8StringEncoding allowLossyConversion: YES]; psz_string = malloc( [o_data length] + 1 ); [o_data getBytes: psz_string]; psz_string[ [o_data length] ] = '\0'; msg_Err( VLCIntf, "cannot convert to the requested encoding: %s", psz_string ); } else { psz_string = malloc( [o_data length] + 1 ); [o_data getBytes: psz_string]; psz_string[ [o_data length] ] = '\0'; } return psz_string;}/* i_width is in pixels */- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width{ NSMutableString *o_wrapped; NSString *o_out_string; NSRange glyphRange, effectiveRange, charRange; NSRect lineFragmentRect; unsigned glyphIndex, breaksInserted = 0; NSTextStorage *o_storage = [[NSTextStorage alloc] initWithString: o_in_string attributes: [NSDictionary dictionaryWithObjectsAndKeys: [NSFont labelFontOfSize: 0.0], NSFontAttributeName, nil]]; NSLayoutManager *o_layout_manager = [[NSLayoutManager alloc] init]; NSTextContainer *o_container = [[NSTextContainer alloc] initWithContainerSize: NSMakeSize(i_width, 2000)]; [o_layout_manager addTextContainer: o_container]; [o_container release]; [o_storage addLayoutManager: o_layout_manager]; [o_layout_manager release]; o_wrapped = [o_in_string mutableCopy]; glyphRange = [o_layout_manager glyphRangeForTextContainer: o_container]; for( glyphIndex = glyphRange.location ; glyphIndex < NSMaxRange(glyphRange) ; glyphIndex += effectiveRange.length) { lineFragmentRect = [o_layout_manager lineFragmentRectForGlyphAtIndex: glyphIndex effectiveRange: &effectiveRange]; charRange = [o_layout_manager characterRangeForGlyphRange: effectiveRange actualGlyphRange: &effectiveRange]; if ([o_wrapped lineRangeForRange: NSMakeRange(charRange.location + breaksInserted, charRange.length)].length > charRange.length) { [o_wrapped insertString: @"\n" atIndex: NSMaxRange(charRange) + breaksInserted]; breaksInserted++; } } o_out_string = [NSString stringWithString: o_wrapped]; [o_wrapped release]; [o_storage release]; return o_out_string;}/***************************************************************************** * hasDefinedShortcutKey: Check to see if the key press is a defined VLC * shortcut key. If it is, pass it off to VLC for handling and return YES, * otherwise ignore it and return NO (where it will get handled by Cocoa). *****************************************************************************/- (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_vlc->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_vlc, "key-pressed", val ); return YES; } } return NO;}- (id)getControls{ if ( o_controls ) { return o_controls; } return nil;}- (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)getVoutMenu{ return o_vout_menu;}- (void)manage{ playlist_t * p_playlist; /* new thread requires a new pool */ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist != NULL ) { 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 ); var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, self ); vlc_object_release( p_playlist ); } while( !p_intf->b_die ) { vlc_mutex_lock( &p_intf->change_lock ); if( p_intf->p_sys->p_input == NULL ) { p_intf->p_sys->p_input = p_playlist->p_input; /* Refresh the interface */ if( p_intf->p_sys->p_input ) { msg_Dbg( p_intf, "input has changed, refreshing interface" ); p_intf->p_sys->b_input_update = VLC_TRUE; } } else if( p_intf->p_sys->p_input->b_die || p_intf->p_sys->p_input->b_dead ) { /* input stopped */ p_intf->p_sys->b_intf_update = VLC_TRUE; p_intf->p_sys->i_play_status = END_S; [self setScrollField: _NS("VLC media player") stopAfter:-1]; msg_Dbg( p_intf, "input has stopped, refreshing interface" ); p_intf->p_sys->p_input = NULL; } /* Manage volume status */ [self manageVolumeSlider]; vlc_mutex_unlock( &p_intf->change_lock ); msleep( 100000 ); } [o_pool release];}- (void)manageIntf:(NSTimer *)o_timer{ vlc_value_t val; if( p_intf->p_vlc->b_die == VLC_TRUE ) { [o_timer invalidate]; return; } if( p_intf->p_sys->b_input_update ) { /* Called when new input is opened */ p_intf->p_sys->b_current_title_update = VLC_TRUE; p_intf->p_sys->b_intf_update = VLC_TRUE; p_intf->p_sys->b_input_update = VLC_FALSE; } if( p_intf->p_sys->b_intf_update ) { vlc_bool_t b_input = VLC_FALSE; vlc_bool_t b_plmul = VLC_FALSE; vlc_bool_t b_control = VLC_FALSE; vlc_bool_t b_seekable = VLC_FALSE; vlc_bool_t b_chapters = VLC_FALSE; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); b_plmul = p_playlist->i_size > 1; vlc_object_release( p_playlist ); if( ( b_input = ( p_intf->p_sys->p_input != NULL ) ) ) { vlc_object_yield( p_intf->p_sys->p_input ); /* seekable streams */ b_seekable = var_GetBool( p_intf->p_sys->p_input, "seekable" ); /* check wether slow/fast motion is possible*/ b_control = p_intf->p_sys->p_input->input.b_can_pace_control; /* chapters & titles */ //b_chapters = p_intf->p_sys->p_input->stream.i_area_nb > 1; vlc_object_release( p_intf->p_sys->p_input ); } [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: @"0:00:00"]; [[[self getControls] getFSPanel] setStreamPos: 0 andTime: @"0:00:00"]; [[[self getControls] getFSPanel] setSeekable: b_seekable]; [o_embedded_window setSeekable: b_seekable]; p_intf->p_sys->b_intf_update = VLC_FALSE; } if( p_intf->p_sys->b_playmode_update ) { [o_playlist playModeUpdated]; p_intf->p_sys->b_playmode_update = VLC_FALSE; } if( p_intf->p_sys->b_playlist_update ) { [o_playlist playlistUpdated]; p_intf->p_sys->b_playlist_update = VLC_FALSE; } if( p_intf->p_sys->b_fullscreen_update ) { playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); var_Get( p_playlist, "fullscreen", &val ); [o_embedded_window setFullscreen: val.b_bool]; vlc_object_release( p_playlist ); p_intf->p_sys->b_fullscreen_update = VLC_FALSE; } if( p_intf->p_sys->b_intf_show ) { [o_window makeKeyAndOrderFront: self]; p_intf->p_sys->b_intf_show = VLC_FALSE; } if( p_intf->p_sys->p_input && !p_intf->p_sys->p_input->b_die ) { vlc_value_t val; if( p_intf->p_sys->b_current_title_update ) { NSString *o_temp; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL || p_playlist->status.p_item == NULL ) { return; } o_temp = [NSString stringWithUTF8String: p_playlist->status.p_item->input.psz_name]; if( o_temp == NULL ) o_temp = [NSString stringWithCString: p_playlist->status.p_item->input.psz_name]; [self setScrollField: o_temp stopAfter:-1]; [[[self getControls] getFSPanel] setStreamTitle: o_temp]; [[o_controls getVoutView] updateTitle]; [o_playlist updateRowSelection]; vlc_object_release( p_playlist ); p_intf->p_sys->b_current_title_update = FALSE; } if( p_intf->p_sys->p_input && [o_timeslider isEnabled] ) { /* Update the slider */ vlc_value_t time; NSString * o_time; mtime_t i_seconds; vlc_value_t pos; float f_updated; var_Get( p_intf->p_sys->p_input, "position", &pos ); f_updated = 10000. * pos.f_float; [o_timeslider setFloatValue: f_updated]; var_Get( p_intf->p_sys->p_input, "time", &time ); i_seconds = time.i_time / 1000000;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -