intf.m
来自「VLC媒体播放程序」· M 代码 · 共 1,410 行 · 第 1/4 页
M
1,410 行
return (unsigned int)i_key;}unsigned int VLCModifiersToCocoa( unsigned int i_key ){ unsigned int new = 0; if( i_key & KEY_MODIFIER_COMMAND ) new |= NSCommandKeyMask; if( i_key & KEY_MODIFIER_ALT ) new |= NSAlternateKeyMask; if( i_key & KEY_MODIFIER_SHIFT ) new |= NSShiftKeyMask; if( i_key & KEY_MODIFIER_CTRL ) new |= NSControlKeyMask; return new;}/***************************************************************************** * VLCMain implementation *****************************************************************************/@implementation VLCMain- (void)awakeFromNib{ unsigned int i_key = 0; intf_thread_t * p_intf = [NSApp getIntf]; vlc_value_t val; [self initStrings]; [o_window setExcludedFromWindowsMenu: TRUE]; [o_msgs_panel setExcludedFromWindowsMenu: TRUE]; [o_msgs_panel setDelegate: self]; i_key = config_GetInt( p_intf, "key-quit" ); [o_mi_quit setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_quit setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-play-pause" ); [o_mi_play setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_play setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-stop" ); [o_mi_stop setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_stop setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-faster" ); [o_mi_faster setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_faster setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-slower" ); [o_mi_slower setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_slower setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; i_key = config_GetInt( p_intf, "key-prev" ); [o_mi_previous setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_previous setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)]; 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+10sec" ); [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-10sec" ); [o_mi_bwd setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]]; [o_mi_bwd 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)]; var_Create (p_intf, "fullscreen", VLC_VAR_BOOL ); var_Change (p_intf, "fullscreen", VLC_VAR_INHERITVALUE, &val, NULL ); [o_btn_fullscreen setState: val.b_bool]; var_Create(p_intf,"intf-change",VLC_VAR_BOOL ); [self setSubmenusEnabled: FALSE]; [self manageVolumeSlider];}- (void)initStrings{ [o_window setTitle: _NS("VLC - Controller")]; [o_scrollfield setStringValue: _NS("VLC media player")]; /* 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")]; /* 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")]; [o_mi_prefs setTitle: _NS("Preferences...")]; [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_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("Controls")]; [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_videotrack setTitle: _NS("Video Track")]; [o_mu_videotrack setTitle: _NS("Video Track")]; [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_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_playlist setTitle: _NS("Playlist")]; [o_mi_info setTitle: _NS("Info")]; [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")]; /* 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")]; /* error panel */ [o_error setTitle: _NS("Error")]; [o_err_lbl setStringValue: _NS("An error has occurred which probably prevented the execution of your request:")]; [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("Surpress further errors")]; [o_info_window setTitle: _NS("Info")];}- (void)applicationWillFinishLaunching:(NSNotification *)o_notification{ intf_thread_t * p_intf = [NSApp getIntf]; 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]; 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 );}- (id)getControls{ if ( o_controls ) { return o_controls; } return nil;}- (id)getPlaylist{ if ( o_playlist ) { return o_playlist; } return nil;}- (void)manage{ NSDate * o_sleep_date; intf_thread_t * p_intf = [NSApp getIntf]; NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); while( !p_intf->b_die ) { playlist_t * p_playlist; vlc_value_t val; vlc_mutex_lock( &p_intf->change_lock ); 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, "playlist-current", PlaylistChanged, self );#define p_input p_playlist->p_input if( p_input ) { if( !p_input->b_die ) { vlc_value_t val; /* New input or stream map change */ if( p_input->stream.b_changed ) { msg_Dbg( p_intf, "stream has changed, refreshing interface" ); p_intf->p_sys->b_playing = TRUE; p_intf->p_sys->b_current_title_update = 1; p_input->stream.b_changed = 0; p_intf->p_sys->b_intf_update = TRUE; } if( var_Get( (vlc_object_t *)p_input, "intf-change", &val ) >= 0 && val.b_bool ) { p_intf->p_sys->b_input_update = TRUE; } } } else if( p_intf->p_sys->b_playing && !p_intf->b_die ) { p_intf->p_sys->b_playing = FALSE; } #undef p_input vlc_object_release( p_playlist ); if( var_Get( p_intf, "intf-change", &val ) >= 0 && val.b_bool ) { p_intf->p_sys->b_fullscreen_update = TRUE; } val.b_bool = VLC_FALSE; var_Set( p_intf,"intf-change",val); } vlc_mutex_unlock( &p_intf->change_lock ); o_sleep_date = [NSDate dateWithTimeIntervalSinceNow: .5]; [NSThread sleepUntilDate: o_sleep_date]; } [self terminate]; [o_pool release];}- (void)manageIntf:(NSTimer *)o_timer{ intf_thread_t * p_intf = [NSApp getIntf]; if( p_intf->p_vlc->b_die == VLC_TRUE ) { [o_timer invalidate]; return; } playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?