⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controls.m

📁 VLC Player Source Code
💻 M
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * controls.m: MacOS X interface module ***************************************************************************** * Copyright (C) 2002-2007 the VideoLAN team * $Id: 826d89a852a5dad3329a409d7f7a79e0a7123a22 $ * * Authors: Jon Lech Johansen <jon-vl@nanocrew.net> *          Christophe Massiot <massiot@via.ecp.fr> *          Derk-Jan Hartman <hartman at videolan dot org> *          Benjamin Pracht <bigben at videolan doit org> *          Felix Kühne <fkuehne 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <stdlib.h>                                      /* malloc(), free() */#include <sys/param.h>                                    /* for MAXPATHLEN */#include <string.h>#import "intf.h"#import "vout.h"#import "open.h"#import "controls.h"#import "playlist.h"#include <vlc_osd.h>#include <vlc_keys.h>/***************************************************************************** * VLCControls implementation *****************************************************************************/@implementation VLCControls- (id)init{    [super init];    o_fs_panel = [[VLCFSPanel alloc] init];    return self;}- (void)awakeFromNib{    [o_specificTime_mi setTitle: _NS("Jump To Time")];    [o_specificTime_cancel_btn setTitle: _NS("Cancel")];    [o_specificTime_ok_btn setTitle: _NS("OK")];    [o_specificTime_sec_lbl setStringValue: _NS("sec.")];    [o_specificTime_goTo_lbl setStringValue: _NS("Jump to time")];    o_repeat_off = [NSImage imageNamed:@"repeat_embedded"];    [self controlTintChanged];    [[NSNotificationCenter defaultCenter] addObserver: self                                             selector: @selector( controlTintChanged )                                                 name: NSControlTintDidChangeNotification                                               object: nil];}- (void)controlTintChanged{    int i_repeat = 0;    if( [o_btn_repeat image] == o_repeat_single )        i_repeat = 1;    else if( [o_btn_repeat image] == o_repeat_all )        i_repeat = 2;    if( [NSColor currentControlTint] == NSGraphiteControlTint )    {        o_repeat_single = [NSImage imageNamed:@"repeat_single_embedded_graphite"];        o_repeat_all = [NSImage imageNamed:@"repeat_embedded_graphite"];                [o_btn_shuffle setAlternateImage: [NSImage imageNamed: @"shuffle_embedded_graphite"]];        [o_btn_addNode setAlternateImage: [NSImage imageNamed: @"add_embedded_graphite"]];    }    else    {        o_repeat_single = [NSImage imageNamed:@"repeat_single_embedded_blue"];        o_repeat_all = [NSImage imageNamed:@"repeat_embedded_blue"];                [o_btn_shuffle setAlternateImage: [NSImage imageNamed: @"shuffle_embedded_blue"]];        [o_btn_addNode setAlternateImage: [NSImage imageNamed: @"add_embedded_blue"]];    }        /* update the repeat button, but keep its state */    if( i_repeat == 1 )        [self repeatOne];    else if( i_repeat == 2 )        [self repeatAll];    else        [self repeatOff];}- (void)dealloc{    [[NSNotificationCenter defaultCenter] removeObserver: self];        [o_repeat_single release];    [o_repeat_all release];    [o_repeat_off release];        [super dealloc];}- (IBAction)play:(id)sender{    intf_thread_t * p_intf = VLCIntf;    playlist_t * p_playlist = pl_Yield( p_intf );    vlc_object_lock( p_playlist );    if( playlist_IsEmpty( p_playlist ) )    {        vlc_object_unlock( p_playlist );        vlc_object_release( p_playlist );        [o_main intfOpenFileGeneric: (id)sender];    }    else    {        vlc_object_unlock( p_playlist );        vlc_object_release( p_playlist );    }    var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );}/* Small helper method */-(id) getVoutView{    id o_window;    id o_vout_view = nil;    id o_embedded_vout_list = [[VLCMain sharedInstance] getEmbeddedList];    NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];    while( !o_vout_view && ( o_window = [o_enumerator nextObject] ) )    {        /* We have an embedded vout */        if( [o_embedded_vout_list windowContainsEmbedded: o_window] )        {            o_vout_view = [o_embedded_vout_list getViewForWindow: o_window];        }        /* We have a detached vout */        else if( [[o_window className] isEqualToString: @"VLCVoutWindow"] )        {            msg_Dbg( VLCIntf, "detached vout controls.m call getVoutView" );            o_vout_view = [o_window getVoutView];        }    }    return o_vout_view;}- (IBAction)stop:(id)sender{    intf_thread_t * p_intf = VLCIntf;    var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_STOP );    /* Close the window directly, because we do know that there     * won't be anymore video. It's currently waiting a bit. */    [[[self getVoutView] window] orderOut:self];}- (IBAction)faster:(id)sender{    intf_thread_t * p_intf = VLCIntf;    var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_FASTER );}- (IBAction)slower:(id)sender{    intf_thread_t * p_intf = VLCIntf;    var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_SLOWER );}- (IBAction)prev:(id)sender{    intf_thread_t * p_intf = VLCIntf;    var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PREV );}- (IBAction)next:(id)sender{    intf_thread_t * p_intf = VLCIntf;    var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_NEXT );}- (IBAction)random:(id)sender{    vlc_value_t val;    intf_thread_t * p_intf = VLCIntf;    playlist_t * p_playlist = pl_Yield( p_intf );    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" ) );        config_PutInt( p_playlist, "random", 1 );    }    else    {        vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );        config_PutInt( p_playlist, "random", 0 );    }    p_intf->p_sys->b_playmode_update = true;    p_intf->p_sys->b_intf_update = true;    vlc_object_release( p_playlist );}/* three little ugly helpers */- (void)repeatOne{    [o_btn_repeat setImage: o_repeat_single];    [o_btn_repeat setAlternateImage: o_repeat_all];}- (void)repeatAll{    [o_btn_repeat setImage: o_repeat_all];    [o_btn_repeat setAlternateImage: o_repeat_off];}- (void)repeatOff{    [o_btn_repeat setImage: o_repeat_off];    [o_btn_repeat setAlternateImage: o_repeat_single];}- (void)shuffle{    vlc_value_t val;    playlist_t *p_playlist = pl_Yield( VLCIntf );    var_Get( p_playlist, "random", &val );    [o_btn_shuffle setState: val.b_bool];    vlc_object_release( p_playlist );}- (IBAction)repeatButtonAction:(id)sender{    vlc_value_t looping,repeating;    intf_thread_t * p_intf = VLCIntf;    playlist_t * p_playlist = pl_Yield( p_intf );    var_Get( p_playlist, "repeat", &repeating );    var_Get( p_playlist, "loop", &looping );    if( !repeating.b_bool && !looping.b_bool )    {        /* was: no repeating at all, switching to Repeat One */         /* set our button's look */        [self repeatOne];         /* prepare core communication */        repeating.b_bool = true;        looping.b_bool = false;        config_PutInt( p_playlist, "repeat", 1 );        config_PutInt( p_playlist, "loop", 0 );         /* show the change */        vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );    }    else if( repeating.b_bool && !looping.b_bool )    {        /* was: Repeat One, switching to Repeat All */         /* set our button's look */        [self repeatAll];         /* prepare core communication */        repeating.b_bool = false;        looping.b_bool = true;        config_PutInt( p_playlist, "repeat", 0 );        config_PutInt( p_playlist, "loop", 1 );         /* show the change */        vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );    }    else    {        /* was: Repeat All or bug in VLC, switching to Repeat Off */         /* set our button's look */        [self repeatOff];         /* prepare core communication */        repeating.b_bool = false;        looping.b_bool = false;        config_PutInt( p_playlist, "repeat", 0 );        config_PutInt( p_playlist, "loop", 0 );         /* show the change */        vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );    }    /* communicate with core and the main intf loop */    var_Set( p_playlist, "repeat", repeating );    var_Set( p_playlist, "loop", looping );    p_intf->p_sys->b_playmode_update = true;    p_intf->p_sys->b_intf_update = true;    vlc_object_release( p_playlist );}- (IBAction)repeat:(id)sender{    vlc_value_t val;    intf_thread_t * p_intf = VLCIntf;    playlist_t * p_playlist = pl_Yield( p_intf );    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" ) );        config_PutInt( p_playlist, "repeat", 1 );    }    else    {        vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );        config_PutInt( p_playlist, "repeat", 0 );    }     p_intf->p_sys->b_playmode_update = true;    p_intf->p_sys->b_intf_update = true;    vlc_object_release( p_playlist );}- (IBAction)loop:(id)sender{    vlc_value_t val;    intf_thread_t * p_intf = VLCIntf;    playlist_t * p_playlist = pl_Yield( p_intf );    var_Get( p_playlist, "loop", &val );    if (!val.b_bool)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -