📄 controls.m
字号:
/***************************************************************************** * controls.m: MacOS X interface module ***************************************************************************** * Copyright (C) 2002-2005 VideoLAN * $Id: controls.m 11398 2005-06-10 19:54:49Z hartman $ * * Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Christophe Massiot <massiot@via.ecp.fr> * Derk-Jan Hartman <hartman at videolan dot org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <stdlib.h> /* malloc(), free() */#include <sys/param.h> /* for MAXPATHLEN */#include <string.h>#include "intf.h"#include "vout.h"#include "open.h"#include "controls.h"#include <osd.h>/***************************************************************************** * VLCControls implementation *****************************************************************************/@implementation VLCControls- (IBAction)play:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { vlc_mutex_lock( &p_playlist->object_lock ); if( p_playlist->i_size <= 0 ) { vlc_mutex_unlock( &p_playlist->object_lock ); vlc_object_release( p_playlist ); [o_main intfOpenFileGeneric: (id)sender]; } else { vlc_mutex_unlock( &p_playlist->object_lock ); vlc_object_release( p_playlist ); } } val.i_int = config_GetInt( p_intf, "key-play-pause" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)stop:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-stop" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)faster:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-faster" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)slower:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-slower" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)prev:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-prev" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)next:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-next" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)random:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return; } var_Get( p_playlist, "random", &val ); val.b_bool = !val.b_bool; var_Set( p_playlist, "random", val ); if( val.b_bool ) { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) ); } else { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) ); } p_intf->p_sys->b_playmode_update = VLC_TRUE; p_intf->p_sys->b_intf_update = VLC_TRUE; vlc_object_release( p_playlist );}- (IBAction)repeat:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return; } var_Get( p_playlist, "repeat", &val ); if (!val.b_bool) { var_Set( p_playlist, "loop", val ); } val.b_bool = !val.b_bool; var_Set( p_playlist, "repeat", val ); if( val.b_bool ) { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) ); } else { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) ); } p_intf->p_sys->b_playmode_update = VLC_TRUE; p_intf->p_sys->b_intf_update = VLC_TRUE; vlc_object_release( p_playlist );}- (IBAction)loop:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) { return; } var_Get( p_playlist, "loop", &val ); if (!val.b_bool) { var_Set( p_playlist, "repeat", val ); } val.b_bool = !val.b_bool; var_Set( p_playlist, "loop", val ); if( val.b_bool ) { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) ); } else { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) ); } p_intf->p_sys->b_playmode_update = VLC_TRUE; p_intf->p_sys->b_intf_update = VLC_TRUE; vlc_object_release( p_playlist );}- (IBAction)forward:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-jump+10sec" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)backward:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-jump-10sec" ); var_Set( p_intf->p_vlc, "key-pressed", val );}- (IBAction)volumeUp:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-vol-up" ); var_Set( p_intf->p_vlc, "key-pressed", val ); /* Manage volume status */ [o_main manageVolumeSlider];}- (IBAction)volumeDown:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-vol-down" ); var_Set( p_intf->p_vlc, "key-pressed", val ); /* Manage volume status */ [o_main manageVolumeSlider];}- (IBAction)mute:(id)sender{ vlc_value_t val; intf_thread_t * p_intf = VLCIntf; val.i_int = config_GetInt( p_intf, "key-vol-mute" ); var_Set( p_intf->p_vlc, "key-pressed", val ); /* Manage volume status */ [o_main manageVolumeSlider];}- (IBAction)volumeSliderUpdated:(id)sender{ intf_thread_t * p_intf = VLCIntf; audio_volume_t i_volume = (audio_volume_t)[sender intValue]; aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP ); /* Manage volume status */ [o_main manageVolumeSlider];}- (IBAction)windowAction:(id)sender{ id o_window = [NSApp keyWindow]; NSString *o_title = [sender title]; NSArray *o_windows = [NSApp orderedWindows]; NSEnumerator *o_enumerator = [o_windows objectEnumerator]; vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); if( p_vout != NULL ) { while ((o_window = [o_enumerator nextObject])) { if( [[o_window className] isEqualToString: @"VLCWindow"] ) { if( [o_title isEqualToString: _NS("Half Size") ] ) [o_window scaleWindowWithFactor: 0.5]; else if( [o_title isEqualToString: _NS("Normal Size") ] ) [o_window scaleWindowWithFactor: 1.0]; else if( [o_title isEqualToString: _NS("Double Size") ] ) [o_window scaleWindowWithFactor: 2.0]; else if( [o_title isEqualToString: _NS("Float on Top") ] ) [o_window toggleFloatOnTop]; else if( [o_title isEqualToString: _NS("Fit to Screen") ] ) { if( ![o_window isZoomed] ) [o_window performZoom:self]; } else if( [o_title isEqualToString: _NS("Snapshot") ] ) { [o_window snapshot]; } else { [o_window toggleFullscreen]; } break; } } vlc_object_release( (vlc_object_t *)p_vout ); } else { playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist && ( [o_title isEqualToString: _NS("Fullscreen")] || [sender isKindOfClass:[NSButton class]] ) ) { vlc_value_t val; var_Get( p_playlist, "fullscreen", &val ); var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool ); } if( p_playlist ) vlc_object_release( (vlc_object_t *)p_playlist ); }}- (void)setupVarMenuItem:(NSMenuItem *)o_mi target:(vlc_object_t *)p_object var:(const char *)psz_variable selector:(SEL)pf_callback{ vlc_value_t val, text; int i_type = var_Type( p_object, psz_variable ); switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: break; default: /* Variable doesn't exist or isn't handled */ return; } /* Make sure we want to display the variable */ if( i_type & VLC_VAR_HASCHOICE ) { var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return; if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) return; } /* Get the descriptive name of the variable */ var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL ); [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ? text.psz_string : strdup( psz_variable ) ]]; var_Get( p_object, psz_variable, &val ); if( i_type & VLC_VAR_HASCHOICE ) { NSMenu *o_menu = [o_mi submenu]; [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object var:psz_variable selector:pf_callback]; if( text.psz_string ) free( text.psz_string );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -