3 static void *sleepForMe(void)
8 @implementation Controller
12 // atexit((void*)sleepForMe); // Only used for memory leak debugging
14 [NSApp setDelegate:self];
16 // Allocate a VLCVideoView instance and tell it what area to occupy.
17 NSRect rect = NSMakeRect(0, 0, 0, 0);
18 rect.size = [videoHolderView frame].size;
20 videoView = [[VLCVideoView alloc] initWithFrame:rect];
21 [videoHolderView addSubview:videoView];
22 [videoView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
24 playlist = [[VLCMediaList alloc] init];
25 [playlist setDelegate:self];
27 player = [[VLCMediaPlayer alloc] initWithVideoView:videoView];
30 [playlistOutline registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, nil]];
31 [playlistOutline setDoubleAction:@selector(changeAndPlay:)];
34 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
38 - (void)applicationWillTerminate:(NSNotification *)aNotification
41 [player setMedia:nil];
48 - (void)changeAndPlay:(id)sender
50 if ([playlistOutline selectedRow] != mediaIndex)
52 [self setMediaIndex:[playlistOutline selectedRow]];
53 if (![player isPlaying])
58 - (void)setMediaIndex:(int)value
60 if ([playlist count] <= 0)
65 if (value > [playlist count] - 1)
66 value = [playlist count] - 1;
69 [player setMedia:[playlist mediaAtIndex:mediaIndex]];
72 - (void)play:(id)sender
74 [self setMediaIndex:mediaIndex+1];
75 if (![player isPlaying])
79 - (void)pause:(id)sender
81 NSLog(@"Sending pause message to media player...");
86 - (void)mediaList:(VLCMediaList *)mediaList mediaAdded:(VLCMedia *)media atIndex:(int)index
88 [playlistOutline reloadData];
91 - (void)mediaList:(VLCMediaList *)mediaList mediaRemoved:(VLCMedia *)media atIndex:(int)index
93 [playlistOutline reloadData];
96 // NSTableView Implementation
97 - (int)numberOfRowsInTableView:(NSTableView *)tableView
99 return [playlist count];
102 - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn
105 return [[playlist mediaAtIndex:row] description];
108 - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info
109 proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op
111 return NSDragOperationEvery; /* This is for now */
114 - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
115 row:(int)row dropOperation:(NSTableViewDropOperation)operation
118 NSArray *droppedItems = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];
120 for (i = 0; i < [droppedItems count]; i++)
122 NSString * filename = [droppedItems objectAtIndex:i];
123 VLCMedia * media = [VLCMedia mediaWithURL:[NSURL fileURLWithPath:filename]];
124 NSLog(@"%@ length = %@", media, [media lengthWaitUntilDate:[NSDate dateWithTimeIntervalSinceNow:60]]);
125 [playlist addMedia:media];