controls.m
来自「VLC媒体播放程序」· M 代码 · 共 798 行 · 第 1/2 页
M
798 行
/***************************************************************************** * controls.m: MacOS X interface module ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN * $Id: controls.m,v 1.61 2004/02/17 03:12:00 hartman Exp $ * * 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; playlist_t * p_playlist; intf_thread_t * p_intf = [NSApp getIntf]; input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); val.i_int = PLAYING_S; if( p_input ) { var_Get( p_input, "state", &val ); } if( p_input && val.i_int != PAUSE_S ) { vout_OSDMessage( p_intf, _( "Pause" ) ); val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else { 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 ) { vlc_mutex_unlock( &p_playlist->object_lock ); vout_OSDMessage( p_intf, _( "Play" ) ); playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } else { vlc_mutex_unlock( &p_playlist->object_lock ); vlc_object_release( p_playlist ); [o_open openFileGeneric: nil]; } } } if( p_input ) vlc_object_release( p_input );}- (IBAction)stop:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist != NULL ) { vout_OSDMessage( p_intf, _( "Stop" ) ); playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); }}- (IBAction)faster:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input != NULL ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-faster", val ); vout_OSDMessage( p_intf, _( "Faster" ) ); vlc_object_release( p_input ); }}- (IBAction)slower:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input != NULL ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-slower", val ); vout_OSDMessage( p_intf, _( "Slower" ) ); vlc_object_release( p_input ); }}- (IBAction)prev:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Prev( p_playlist ); vlc_object_release( p_playlist ); vout_OSDMessage( p_intf, _( "Previous" ) ); }}- (IBAction)next:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Next( p_playlist ); vlc_object_release( p_playlist ); vout_OSDMessage( p_intf, _( "Next" ) ); }}- (IBAction)random:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; vlc_value_t val; 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, _( "Random On" ) ); } else { vout_OSDMessage( p_intf, _( "Random Off" ) ); } p_intf->p_sys->b_playlist_update = VLC_TRUE; p_intf->p_sys->b_intf_update = VLC_TRUE; vlc_object_release( p_playlist );}- (IBAction)repeat:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; vlc_value_t val; 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 ); val.b_bool = !val.b_bool; var_Set( p_playlist, "repeat", val ); if( val.b_bool ) { vout_OSDMessage( p_intf, _( "Repeat All" ) ); } else { vout_OSDMessage( p_intf, _( "Repeat Off" ) ); } p_intf->p_sys->b_playlist_update = VLC_TRUE; p_intf->p_sys->b_intf_update = VLC_TRUE; vlc_object_release( p_playlist );}- (IBAction)loop:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; vlc_value_t val; 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 ); val.b_bool = !val.b_bool; var_Set( p_playlist, "loop", val ); if( val.b_bool ) { vout_OSDMessage( p_intf, _( "Repeat One" ) ); } else { vout_OSDMessage( p_intf, _( "Repeat Off" ) ); } p_intf->p_sys->b_playlist_update = VLC_TRUE; p_intf->p_sys->b_intf_update = VLC_TRUE; vlc_object_release( p_playlist );}- (IBAction)forward:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input != NULL ) { vlc_value_t time; time.i_time = 10 * 1000000; var_Set( p_input, "time-offset", time ); vlc_object_release( p_input ); }}- (IBAction)backward:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input != NULL ) { vlc_value_t time; time.i_time = -10 * 1000000; var_Set( p_input, "time-offset", time ); vlc_object_release( p_input ); }}- (IBAction)volumeUp:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; if( p_intf->p_sys->b_mute ) { [self mute: nil]; } aout_VolumeUp( p_intf, 1, NULL ); [self updateVolumeSlider];}- (IBAction)volumeDown:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; if( p_intf->p_sys->b_mute ) { [self mute: nil]; } aout_VolumeDown( p_intf, 1, NULL ); [self updateVolumeSlider];}- (IBAction)mute:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; audio_volume_t i_volume; aout_VolumeMute( p_intf, &i_volume ); p_intf->p_sys->b_mute = ( i_volume == 0 ); [self updateVolumeSlider];}- (IBAction)volumeSliderUpdated:(id)sender{ intf_thread_t * p_intf = [NSApp getIntf]; audio_volume_t i_volume = (audio_volume_t)[sender intValue]; aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP );}- (void)updateVolumeSlider{ intf_thread_t * p_intf = [NSApp getIntf]; audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)]; vout_OSDMessage( p_intf, "Vol %d%%", i_volume*100/AOUT_VOLUME_MAX );}- (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( [NSApp getIntf], 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 { [o_window toggleFullscreen]; } break; } } vlc_object_release( (vlc_object_t *)p_vout ); }}- (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: [NSApp localizedString: text.psz_string ?
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?