1 /*****************************************************************************
2 * intf_controller.c: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: intf_controller.m,v 1.1 2002/05/12 20:56:33 massiot Exp $
7 * Authors: Florian G. Pflug <fgp@phlo.org>
8 * Jon Lech Johansen <jon-vl@nanocrew.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 #import <ApplicationServices/ApplicationServices.h>
27 #include <videolan/vlc.h>
29 #include "interface.h"
30 #include "intf_playlist.h"
33 #include "intf_controller.h"
35 @implementation Intf_Controller
37 /* Initialization & Event-Management */
41 NSString *pTitle = [NSString
42 stringWithCString: VOUT_TITLE " (Cocoa)"];
44 [o_window setTitle: pTitle];
47 - (void)applicationDidFinishLaunching:(NSNotification *)o_notification
49 o_intf = [[Intf_VLCWrapper instance] retain];
50 o_vout = [[Vout_VLCWrapper instance] retain];
52 f_slider = f_slider_old = 0.0;
53 o_slider_lock = [[NSLock alloc] init];
55 [NSThread detachNewThreadSelector: @selector(manage)
56 toTarget: self withObject: nil];
62 NSAutoreleasePool *o_pool;
64 o_pool = [[NSAutoreleasePool alloc] init];
66 while( ![o_intf manage] )
68 if( [o_intf playlistPlaying] )
70 [o_time setStringValue: [o_intf getTimeAsString]];
72 if( f_slider == f_slider_old )
74 float f_updated = [o_intf getTimeAsFloat];
76 if( f_updated != f_slider )
78 if( [o_slider_lock tryLock] )
80 [o_timeslider setFloatValue: f_updated];
81 [o_slider_lock unlock];
87 [o_intf setTimeAsFloat: f_slider];
88 f_slider_old = f_slider;
91 UpdateSystemActivity( UsrActivity );
94 sleepDate = [NSDate dateWithTimeIntervalSinceNow: 0.5];
95 [NSThread sleepUntilDate: sleepDate];
112 /* send a dummy event to break out of the event loop */
113 pEvent = [NSEvent mouseEventWithType: NSLeftMouseDown
114 location: NSMakePoint( 1, 1 ) modifierFlags: 0
115 timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
116 context: [NSGraphicsContext currentContext] eventNumber: 1
117 clickCount: 1 pressure: 0.0];
118 [NSApp postEvent: pEvent atStart: YES];
121 /* Functions attached to user interface */
123 - (IBAction)pause:(id)sender
125 [o_intf playlistPause];
128 - (IBAction)play:(id)sender
130 [o_intf playlistPlay];
133 - (IBAction)stop:(id)sender
135 [o_intf playlistStop];
138 - (IBAction)faster:(id)sender
143 - (IBAction)slower:(id)sender
148 - (IBAction)prev:(id)sender
150 [o_intf playlistPrev];
153 - (IBAction)next:(id)sender
155 [o_intf playlistNext];
158 - (IBAction)mute:(id)sender
160 NSMenuItem * item = (NSMenuItem *)sender;
164 if( p_main->p_intf->p_sys->b_mute )
166 [item setState:NSOnState];
170 [item setState:NSOffState];
174 - (IBAction)fullscreen:(id)sender
179 - (IBAction)eject:(id)sender
184 - (IBAction)timesliderUpdate:(id)slider
186 switch( [[NSApp currentEvent] type] )
188 case NSLeftMouseDown:
189 [o_slider_lock lock];
193 f_slider = [o_timeslider floatValue];
194 [o_slider_lock unlock];
202 - (IBAction)quit:(id)sender
209 @implementation Intf_PlaylistDS
213 if( [super init] == nil )
223 o_playlist = [[[Intf_VLCWrapper instance] playlistAsArray] retain];
226 - (int)numberOfRowsInTableView:(NSTableView*)o_table
229 return( [o_playlist count] );
232 - (id)tableView:(NSTableView *)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row
234 return( [o_playlist objectAtIndex: i_row] );
237 - (void)tableView:(NSTableView *)o_table setObjectValue:o_value forTableColumn:(NSTableColumn *)o_column row:(int)i_index