📄 intf.m
字号:
i_key = config_GetInt( p_intf, "key-next" ); [o_mi_next setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_next setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-jump+short" ); [o_mi_fwd setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_fwd setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-jump-short" ); [o_mi_bwd setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_bwd setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-jump+medium" ); [o_mi_fwd1m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_fwd1m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-jump-medium" ); [o_mi_bwd1m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_bwd1m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-jump+long" ); [o_mi_fwd5m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_fwd5m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-jump-long" ); [o_mi_bwd5m setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_bwd5m setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-vol-up" ); [o_mi_vol_up setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_vol_up setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-vol-down" ); [o_mi_vol_down setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_vol_down setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-vol-mute" ); [o_mi_mute setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_mute setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-fullscreen" ); [o_mi_fullscreen setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_fullscreen setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-snapshot" ); [o_mi_snapshot setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_snapshot setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; var_Create( p_intf, "intf-change", VLC_VAR_BOOL ); [self setSubmenusEnabled: FALSE]; [self manageVolumeSlider]; [o_window setDelegate: self]; if( [o_window frame].size.height <= 200 ) { b_small_window = YES; [o_window setFrame: NSMakeRect( [o_window frame].origin.x, [o_window frame].origin.y, [o_window frame].size.width, [o_window minSize].height ) display: YES animate:YES]; [o_playlist_view setAutoresizesSubviews: NO]; } else { b_small_window = NO; [o_playlist_view setFrame: NSMakeRect( 10, 10, [o_window frame].size.width - 20, [o_window frame].size.height - 105 )]; [o_playlist_view setNeedsDisplay:YES]; [o_playlist_view setAutoresizesSubviews: YES]; [[o_window contentView] addSubview: o_playlist_view]; } [self updateTogglePlaylistState]; o_size_with_playlist = [o_window frame].size; p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { /* Check if we need to start playing */ if( p_intf->b_play ) { playlist_LockControl( p_playlist, PLAYLIST_AUTOPLAY ); } var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL | VLC_VAR_DOINHERIT); val.b_bool = VLC_FALSE; var_AddCallback( p_playlist, "fullscreen", FullscreenChanged, self); var_AddCallback( p_playlist, "intf-show", ShowController, self); [o_embedded_window setFullscreen: var_GetBool( p_playlist, "fullscreen" )]; vlc_object_release( p_playlist ); } var_Create( p_intf, "interaction", VLC_VAR_ADDRESS ); var_AddCallback( p_intf, "interaction", InteractCallback, self ); p_intf->b_interaction = VLC_TRUE; /* update the playmode stuff */ p_intf->p_sys->b_playmode_update = VLC_TRUE; nib_main_loaded = TRUE;}- (void)initStrings{ [o_window setTitle: _NS("VLC - Controller")]; [self setScrollField:_NS("VLC media player") stopAfter:-1]; /* button controls */ [o_btn_prev setToolTip: _NS("Previous")]; [o_btn_rewind setToolTip: _NS("Rewind")]; [o_btn_play setToolTip: _NS("Play")]; [o_btn_stop setToolTip: _NS("Stop")]; [o_btn_ff setToolTip: _NS("Fast Forward")]; [o_btn_next setToolTip: _NS("Next")]; [o_btn_fullscreen setToolTip: _NS("Fullscreen")]; [o_volumeslider setToolTip: _NS("Volume")]; [o_timeslider setToolTip: _NS("Position")]; [o_btn_playlist setToolTip: _NS("Playlist")]; /* messages panel */ [o_msgs_panel setTitle: _NS("Messages")]; [o_msgs_btn_crashlog setTitle: _NS("Open CrashLog")]; /* main menu */ [o_mi_about setTitle: [_NS("About VLC media player") \ stringByAppendingString: @"..."]]; [o_mi_checkForUpdate setTitle: _NS("Check for Update...")]; [o_mi_prefs setTitle: _NS("Preferences...")]; [o_mi_add_intf setTitle: _NS("Add Interface")]; [o_mu_add_intf setTitle: _NS("Add Interface")]; [o_mi_services setTitle: _NS("Services")]; [o_mi_hide setTitle: _NS("Hide VLC")]; [o_mi_hide_others setTitle: _NS("Hide Others")]; [o_mi_show_all setTitle: _NS("Show All")]; [o_mi_quit setTitle: _NS("Quit VLC")]; [o_mu_file setTitle: _ANS("1:File")]; [o_mi_open_generic setTitle: _NS("Open File...")]; [o_mi_open_file setTitle: _NS("Quick Open File...")]; [o_mi_open_disc setTitle: _NS("Open Disc...")]; [o_mi_open_net setTitle: _NS("Open Network...")]; [o_mi_open_recent setTitle: _NS("Open Recent")]; [o_mi_open_recent_cm setTitle: _NS("Clear Menu")]; [o_mi_open_wizard setTitle: _NS("Streaming/Exporting Wizard...")]; [o_mu_edit setTitle: _NS("Edit")]; [o_mi_cut setTitle: _NS("Cut")]; [o_mi_copy setTitle: _NS("Copy")]; [o_mi_paste setTitle: _NS("Paste")]; [o_mi_clear setTitle: _NS("Clear")]; [o_mi_select_all setTitle: _NS("Select All")]; [o_mu_controls setTitle: _NS("Playback")]; [o_mi_play setTitle: _NS("Play")]; [o_mi_stop setTitle: _NS("Stop")]; [o_mi_faster setTitle: _NS("Faster")]; [o_mi_slower setTitle: _NS("Slower")]; [o_mi_previous setTitle: _NS("Previous")]; [o_mi_next setTitle: _NS("Next")]; [o_mi_random setTitle: _NS("Random")]; [o_mi_repeat setTitle: _NS("Repeat One")]; [o_mi_loop setTitle: _NS("Repeat All")]; [o_mi_fwd setTitle: _NS("Step Forward")]; [o_mi_bwd setTitle: _NS("Step Backward")]; [o_mi_program setTitle: _NS("Program")]; [o_mu_program setTitle: _NS("Program")]; [o_mi_title setTitle: _NS("Title")]; [o_mu_title setTitle: _NS("Title")]; [o_mi_chapter setTitle: _NS("Chapter")]; [o_mu_chapter setTitle: _NS("Chapter")]; [o_mu_audio setTitle: _NS("Audio")]; [o_mi_vol_up setTitle: _NS("Volume Up")]; [o_mi_vol_down setTitle: _NS("Volume Down")]; [o_mi_mute setTitle: _NS("Mute")]; [o_mi_audiotrack setTitle: _NS("Audio Track")]; [o_mu_audiotrack setTitle: _NS("Audio Track")]; [o_mi_channels setTitle: _NS("Audio Channels")]; [o_mu_channels setTitle: _NS("Audio Channels")]; [o_mi_device setTitle: _NS("Audio Device")]; [o_mu_device setTitle: _NS("Audio Device")]; [o_mi_visual setTitle: _NS("Visualizations")]; [o_mu_visual setTitle: _NS("Visualizations")]; [o_mu_video setTitle: _NS("Video")]; [o_mi_half_window setTitle: _NS("Half Size")]; [o_mi_normal_window setTitle: _NS("Normal Size")]; [o_mi_double_window setTitle: _NS("Double Size")]; [o_mi_fittoscreen setTitle: _NS("Fit to Screen")]; [o_mi_fullscreen setTitle: _NS("Fullscreen")]; [o_mi_floatontop setTitle: _NS("Float on Top")]; [o_mi_snapshot setTitle: _NS("Snapshot")]; [o_mi_videotrack setTitle: _NS("Video Track")]; [o_mu_videotrack setTitle: _NS("Video Track")]; [o_mi_aspect_ratio setTitle: _NS("Aspect-ratio")]; [o_mu_aspect_ratio setTitle: _NS("Aspect-ratio")]; [o_mi_crop setTitle: _NS("Crop")]; [o_mu_crop setTitle: _NS("Crop")]; [o_mi_screen setTitle: _NS("Video Device")]; [o_mu_screen setTitle: _NS("Video Device")]; [o_mi_subtitle setTitle: _NS("Subtitles Track")]; [o_mu_subtitle setTitle: _NS("Subtitles Track")]; [o_mi_deinterlace setTitle: _NS("Deinterlace")]; [o_mu_deinterlace setTitle: _NS("Deinterlace")]; [o_mi_ffmpeg_pp setTitle: _NS("Post processing")]; [o_mu_ffmpeg_pp setTitle: _NS("Post processing")]; [o_mu_window setTitle: _NS("Window")]; [o_mi_minimize setTitle: _NS("Minimize Window")]; [o_mi_close_window setTitle: _NS("Close Window")]; [o_mi_controller setTitle: _NS("Controller")]; [o_mi_equalizer setTitle: _NS("Equalizer")]; [o_mi_extended setTitle: _NS("Extended Controls")]; [o_mi_bookmarks setTitle: _NS("Bookmarks")]; [o_mi_playlist setTitle: _NS("Playlist")]; [o_mi_info setTitle: _NS("Information")]; [o_mi_messages setTitle: _NS("Messages")]; [o_mi_bring_atf setTitle: _NS("Bring All to Front")]; [o_mu_help setTitle: _NS("Help")]; [o_mi_readme setTitle: _NS("ReadMe...")]; [o_mi_documentation setTitle: _NS("Online Documentation")]; [o_mi_reportabug setTitle: _NS("Report a Bug")]; [o_mi_website setTitle: _NS("VideoLAN Website")]; [o_mi_license setTitle: _NS("License")]; [o_mi_donation setTitle: _NS("Make a donation")]; [o_mi_forum setTitle: _NS("Online Forum")]; /* dock menu */ [o_dmi_play setTitle: _NS("Play")]; [o_dmi_stop setTitle: _NS("Stop")]; [o_dmi_next setTitle: _NS("Next")]; [o_dmi_previous setTitle: _NS("Previous")]; [o_dmi_mute setTitle: _NS("Mute")]; /* vout menu */ [o_vmi_play setTitle: _NS("Play")]; [o_vmi_stop setTitle: _NS("Stop")]; [o_vmi_prev setTitle: _NS("Previous")]; [o_vmi_next setTitle: _NS("Next")]; [o_vmi_volup setTitle: _NS("Volume Up")]; [o_vmi_voldown setTitle: _NS("Volume Down")]; [o_vmi_mute setTitle: _NS("Mute")]; [o_vmi_fullscreen setTitle: _NS("Fullscreen")]; [o_vmi_snapshot setTitle: _NS("Snapshot")]; /* error panel */ [o_error setTitle: _NS("Error")]; [o_err_lbl setStringValue: _NS("An error has occurred which probably " \ "prevented the proper execution of the program:")]; [o_err_bug_lbl setStringValue: _NS("If you believe that it is a bug, " \ "please follow the instructions at:")]; [o_err_btn_msgs setTitle: _NS("Open Messages Window")]; [o_err_btn_dismiss setTitle: _NS("Dismiss")]; [o_err_ckbk_surpress setTitle: _NS("Do not display further errors")]; [o_info_window setTitle: _NS("Information")];}- (void)applicationWillFinishLaunching:(NSNotification *)o_notification{ o_msg_lock = [[NSLock alloc] init]; o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain]; o_img_play = [[NSImage imageNamed: @"play"] retain]; o_img_play_pressed = [[NSImage imageNamed: @"play_blue"] retain]; o_img_pause = [[NSImage imageNamed: @"pause"] retain]; o_img_pause_pressed = [[NSImage imageNamed: @"pause_blue"] retain]; [p_intf->p_sys->o_sendport setDelegate: self]; [[NSRunLoop currentRunLoop] addPort: p_intf->p_sys->o_sendport forMode: NSDefaultRunLoopMode]; [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self selector: @selector(manageIntf:) userInfo: nil repeats: FALSE]; [NSThread detachNewThreadSelector: @selector(manage) toTarget: self withObject: nil]; [o_controls setupVarMenuItem: o_mi_add_intf target: (vlc_object_t *)p_intf var: "intf-add" selector: @selector(toggleVar:)]; vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );}- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename{ NSDictionary *o_dic = [NSDictionary dictionaryWithObjectsAndKeys: o_filename, @"ITEM_URL", nil]; [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue: NO]; return( TRUE );}- (NSString *)localizedString:(char *)psz{ NSString * o_str = nil; if( psz != NULL ) { o_str = [[[NSString alloc] initWithUTF8String: psz] autorelease]; if ( o_str == NULL ) { msg_Err( VLCIntf, "could not translate: %s", psz ); return( @"" ); } } else { msg_Warn( VLCIntf, "can't translate empty strings" ); return( @"" ); } return( o_str );}/* Listen to the remote in exclusive mode, only when VLC is the active application */- (void)applicationDidBecomeActive:(NSNotification *)aNotification{ [o_remote startListening: self];}- (void)applicationDidResignActive:(NSNotification *)aNotification{ [o_remote stopListening: self];}/* Helper method for the remote control interface in order to trigger forward/backward as long as the user holds the left/right button */- (void) triggerMovieStepForRemoteButton: (NSNumber*) buttonIdentifierNumber { if (b_left_right_remote_button_hold) { switch([buttonIdentifierNumber intValue]) { case kRemoteButtonRight_Hold: [o_controls forward: self]; break; case kRemoteButtonLeft_Hold: [o_controls backward: self]; break; } if (b_left_right_remote_button_hold) { /* trigger event */ [self performSelector:@selector(triggerMovieStepForRemoteButton:) withObject:buttonIdentifierNumber afterDelay:0.25]; } }}/* Apple Remote callback */- (void)appleRemoteButton:(AppleRemoteEventIdentifier)buttonIdentifier pressedDown:(BOOL)pressedDown{ switch( buttonIdentifier ) { case kRemoteButtonPlay: [o_controls play: self]; break; case kRemoteButtonVolume_Plus: /* there are two events when the plus or minus button is pressed one when the button is pressed down and one when the button is released */ if( pressedDown ) { [o_controls volumeUp: self]; } break; case kRemoteButtonVolume_Minus: /* there are two events when the plus or minus button is pressed one when the button is pressed down and one when the button is released */ if( pressedDown ) { [o_controls volumeDown: self]; } break; case kRemoteButtonRight: [o_controls next: self]; break; case kRemoteButtonLeft: [o_controls prev: self]; break; case kRemoteButtonRight_Hold: case kRemoteButtonLeft_Hold: /* simulate an event as long as the user holds the button */ b_left_right_remote_button_hold = pressedDown; if( pressedDown ) { NSNumber* buttonIdentifierNumber = [NSNumber numberWithInt: buttonIdentifier]; [self performSelector:@selector(triggerMovieStepForRemoteButton:) withObject:buttonIdentifierNumber]; } break; case kRemoteButtonMenu: [o_controls windowAction: self]; break; default: /* Add here whatever you want other buttons to do */ break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -