1 /*****************************************************************************
2 * applescript.m: MacOS X AppleScript support
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
5 * $Id: applescript.m,v 1.1 2003/03/06 11:43:07 hartman Exp $
7 * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include "applescript.h"
33 /*****************************************************************************
34 * VLGetURLScriptCommand implementation
35 *****************************************************************************/
36 @implementation VLGetURLScriptCommand
38 - (id)performDefaultImplementation {
39 NSString *o_command = [[self commandDescription] commandName];
40 NSString *o_urlString = [self directParameter];
42 if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] )
44 intf_thread_t * p_intf = [NSApp getIntf];
45 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
47 if( p_playlist == NULL )
56 int i_mode = PLAYLIST_INSERT | PLAYLIST_GO;
58 playlist_Add( p_playlist, [o_urlString fileSystemRepresentation],
59 i_mode, PLAYLIST_END );
61 o_url = [NSURL fileURLWithPath: o_urlString];
64 [[NSDocumentController sharedDocumentController]
65 noteNewRecentDocumentURL: o_url];
68 vlc_object_release( p_playlist );
76 /*****************************************************************************
77 * VLControlScriptCommand implementation
78 *****************************************************************************/
80 * This entire control command needs a better design. more object oriented.
81 * Applescript developers would be very welcome (hartman)
83 @implementation VLControlScriptCommand
85 - (id)performDefaultImplementation {
86 NSString *o_command = [[self commandDescription] commandName];
88 intf_thread_t * p_intf = [NSApp getIntf];
89 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
91 if( p_playlist == NULL )
96 VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls];
100 if ( [o_command isEqualToString:@"play"] )
102 [o_controls play:self];
105 else if ( [o_command isEqualToString:@"stop"] )
107 [o_controls stop:self];
110 else if ( [o_command isEqualToString:@"previous"] )
112 [o_controls prev:self];
115 else if ( [o_command isEqualToString:@"next"] )
117 [o_controls next:self];
120 else if ( [o_command isEqualToString:@"fullscreen"] )
122 [o_controls fullscreen:self];
125 else if ( [o_command isEqualToString:@"mute"] )
127 [o_controls mute:self];
130 else if ( [o_command isEqualToString:@"volumeUp"] )
132 [o_controls volumeUp:self];
135 else if ( [o_command isEqualToString:@"volumeDown"] )
137 [o_controls volumeDown:self];
141 vlc_object_release( p_playlist );