1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2008 the VideoLAN team
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Derk-Jan Hartman <hartman at videola/n dot org>
9 * Benjamin Pracht <bigben at videolab dot org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
27 * add 'icons' for different types of nodes? (http://www.cocoadev.com/index.pl?IconAndTextInTableCell)
28 * reimplement enable/disable item
29 * create a new 'tool' button (see the gear button in the Finder window) for 'actions'
30 (adding service discovery, other views, new node/playlist, save node/playlist) stuff like that
34 /*****************************************************************************
36 *****************************************************************************/
37 #include <stdlib.h> /* malloc(), free() */
38 #include <sys/param.h> /* for MAXPATHLEN */
41 #include <sys/mount.h>
47 #import "playlistinfo.h"
52 #import <vlc_interface.h>
54 /*****************************************************************************
55 * VLCPlaylistView implementation
56 *****************************************************************************/
57 @implementation VLCPlaylistView
59 - (NSMenu *)menuForEvent:(NSEvent *)o_event
61 return( [[self delegate] menuForEvent: o_event] );
64 - (void)keyDown:(NSEvent *)o_event
68 if( [[o_event characters] length] )
70 key = [[o_event characters] characterAtIndex: 0];
75 case NSDeleteCharacter:
76 case NSDeleteFunctionKey:
77 case NSDeleteCharFunctionKey:
78 case NSBackspaceCharacter:
79 [[self delegate] deleteItem:self];
82 case NSEnterCharacter:
83 case NSCarriageReturnCharacter:
84 [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist] playItem:self];
88 [super keyDown: o_event];
95 /*****************************************************************************
96 * VLCPlaylistCommon implementation
98 * This class the superclass of the VLCPlaylist and VLCPlaylistWizard.
99 * It contains the common methods and elements of these 2 entities.
100 *****************************************************************************/
101 @implementation VLCPlaylistCommon
108 o_outline_dict = [[NSMutableDictionary alloc] init];
114 playlist_t * p_playlist = pl_Yield( VLCIntf );
115 [o_outline_view setTarget: self];
116 [o_outline_view setDelegate: self];
117 [o_outline_view setDataSource: self];
118 [o_outline_view setAllowsEmptySelection: NO];
120 vlc_object_release( p_playlist );
126 [[o_tc_name headerCell] setStringValue:_NS("Name")];
127 [[o_tc_author headerCell] setStringValue:_NS("Author")];
128 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
131 - (NSOutlineView *)outlineView
133 return o_outline_view;
136 - (playlist_item_t *)selectedPlaylistItem
138 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
144 @implementation VLCPlaylistCommon (NSOutlineViewDataSource)
146 /* return the number of children for Obj-C pointer item */ /* DONE */
147 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
150 playlist_item_t *p_item = NULL;
151 playlist_t * p_playlist = pl_Yield( VLCIntf );
152 assert( outlineView == o_outline_view );
155 p_item = p_playlist->p_root_category;
157 p_item = (playlist_item_t *)[item pointerValue];
160 i_return = p_item->i_children;
162 pl_Release( VLCIntf );
164 return i_return > 0 ? i_return : 0;
167 /* return the child at index for the Obj-C pointer item */ /* DONE */
168 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
170 playlist_item_t *p_return = NULL, *p_item = NULL;
172 playlist_t * p_playlist = pl_Yield( VLCIntf );
177 p_item = p_playlist->p_root_category;
181 p_item = (playlist_item_t *)[item pointerValue];
183 if( p_item && index < p_item->i_children && index >= 0 )
184 p_return = p_item->pp_children[index];
186 vlc_object_release( p_playlist );
188 o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
192 /* Why is there a warning if that happens all the time and seems
193 * to be normal? Add an assert and fix it.
194 * msg_Warn( VLCIntf, "playlist item misses pointer value, adding one" ); */
195 o_value = [[NSValue valueWithPointer: p_return] retain];
200 /* is the item expandable */
201 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
204 playlist_t *p_playlist = pl_Yield( VLCIntf );
209 if( p_playlist->p_root_category )
211 i_return = p_playlist->p_root_category->i_children;
216 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
218 i_return = p_item->i_children;
220 pl_Release( VLCIntf );
222 return (i_return >= 0);
225 /* retrieve the string values for the cells */
226 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
229 playlist_item_t *p_item;
231 /* For error handling */
232 static BOOL attempted_reload = NO;
234 if( item == nil || ![item isKindOfClass: [NSValue class]] )
236 /* Attempt to fix the error by asking for a data redisplay
237 * This might cause infinite loop, so add a small check */
238 if( !attempted_reload )
240 attempted_reload = YES;
241 [outlineView reloadData];
246 p_item = (playlist_item_t *)[item pointerValue];
247 if( !p_item || !p_item->p_input )
249 /* Attempt to fix the error by asking for a data redisplay
250 * This might cause infinite loop, so add a small check */
251 if( !attempted_reload )
253 attempted_reload = YES;
254 [outlineView reloadData];
259 attempted_reload = NO;
261 if( [[o_tc identifier] isEqualToString:@"name"] )
263 /* sanity check to prevent the NSString class from crashing */
264 char *psz_title = input_item_GetTitle( p_item->p_input );
265 if( !EMPTY_STR( psz_title ) )
267 o_value = [NSString stringWithUTF8String: psz_title];
271 char *psz_name = input_item_GetName( p_item->p_input );
273 o_value = [NSString stringWithUTF8String: psz_name];
278 else if( [[o_tc identifier] isEqualToString:@"artist"] )
280 char *psz_artist = input_item_GetArtist( p_item->p_input );
282 o_value = [NSString stringWithUTF8String: psz_artist];
285 else if( [[o_tc identifier] isEqualToString:@"duration"] )
287 char psz_duration[MSTRTIME_MAX_SIZE];
288 mtime_t dur = input_item_GetDuration( p_item->p_input );
291 secstotimestr( psz_duration, dur/1000000 );
292 o_value = [NSString stringWithUTF8String: psz_duration];
297 else if( [[o_tc identifier] isEqualToString:@"status"] )
299 if( input_item_HasErrorWhenReading( p_item->p_input ) )
301 o_value = [NSImage imageWithWarningIcon];
309 /*****************************************************************************
310 * VLCPlaylistWizard implementation
311 *****************************************************************************/
312 @implementation VLCPlaylistWizard
314 - (IBAction)reloadOutlineView
316 /* Only reload the outlineview if the wizard window is open since this can
317 be quite long on big playlists */
318 if( [[o_outline_view window] isVisible] )
320 [o_outline_view reloadData];
326 /*****************************************************************************
327 * extension to NSOutlineView's interface to fix compilation warnings
328 * and let us access these 2 functions properly
329 * this uses a private Apple-API, but works fine on all current OSX releases
330 * keep checking for compatiblity with future releases though
331 *****************************************************************************/
333 @interface NSOutlineView (UndocumentedSortImages)
334 + (NSImage *)_defaultTableHeaderSortImage;
335 + (NSImage *)_defaultTableHeaderReverseSortImage;
339 /*****************************************************************************
340 * VLCPlaylist implementation
341 *****************************************************************************/
342 @implementation VLCPlaylist
349 o_nodes_array = [[NSMutableArray alloc] init];
350 o_items_array = [[NSMutableArray alloc] init];
357 [o_nodes_array release];
358 [o_items_array release];
364 playlist_t * p_playlist = pl_Yield( VLCIntf );
368 [super awakeFromNib];
370 [o_outline_view setDoubleAction: @selector(playItem:)];
372 [o_outline_view registerForDraggedTypes:
373 [NSArray arrayWithObjects: NSFilenamesPboardType,
374 @"VLCPlaylistItemPboardType", nil]];
375 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
377 /* This uses private Apple API which works fine until 10.5.
378 * We need to keep checking in the future!
379 * These methods are being added artificially to NSOutlineView's interface above */
380 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
381 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
383 o_tc_sortColumn = nil;
386 char ** ppsz_services = services_discovery_GetServicesNames( p_playlist, &ppsz_name );
389 vlc_object_release( p_playlist );
393 for( i = 0; ppsz_services[i]; i++ )
398 char * name = ppsz_name[i] ? ppsz_name[i] : ppsz_services[i];
399 /* Check whether to enable these menuitems */
400 b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, ppsz_services[i] );
402 /* Create the menu entries used in the playlist menu */
403 o_lmi = [[o_mi_services submenu] addItemWithTitle:
404 [NSString stringWithUTF8String: name]
405 action: @selector(servicesChange:)
407 [o_lmi setTarget: self];
408 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
409 if( b_enabled ) [o_lmi setState: NSOnState];
411 /* Create the menu entries for the main menu */
412 o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
413 [NSString stringWithUTF8String: name]
414 action: @selector(servicesChange:)
416 [o_lmi setTarget: self];
417 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
418 if( b_enabled ) [o_lmi setState: NSOnState];
420 free( ppsz_services[i] );
421 free( ppsz_name[i] );
423 free( ppsz_services );
426 vlc_object_release( p_playlist );
429 - (void)searchfieldChanged:(NSNotification *)o_notification
431 [o_search_field setStringValue:[[o_notification object] stringValue]];
438 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
439 [o_mi_play setTitle: _NS("Play")];
440 [o_mi_delete setTitle: _NS("Delete")];
441 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
442 [o_mi_selectall setTitle: _NS("Select All")];
443 [o_mi_info setTitle: _NS("Information...")];
444 [o_mi_preparse setTitle: _NS("Fetch Meta Data")];
445 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
446 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
447 [o_mi_services setTitle: _NS("Services discovery")];
448 [o_mm_mi_services setTitle: _NS("Services discovery")];
449 [o_status_field setStringValue: _NS("No items in the playlist")];
451 [o_search_field setToolTip: _NS("Search in Playlist")];
452 [o_mi_addNode setTitle: _NS("Add Folder to Playlist")];
454 [o_save_accessory_text setStringValue: _NS("File Format:")];
455 [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];
456 [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
459 - (void)playlistUpdated
461 /* Clear indications of any existing column sorting */
462 for( unsigned int i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
464 [o_outline_view setIndicatorImage:nil inTableColumn:
465 [[o_outline_view tableColumns] objectAtIndex:i]];
468 [o_outline_view setHighlightedTableColumn:nil];
469 o_tc_sortColumn = nil;
470 // TODO Find a way to keep the dict size to a minimum
471 //[o_outline_dict removeAllObjects];
472 [o_outline_view reloadData];
473 [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView];
474 [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData];
476 playlist_t *p_playlist = pl_Yield( VLCIntf );
478 if( playlist_CurrentSize( p_playlist ) >= 2 )
480 [o_status_field setStringValue: [NSString stringWithFormat:
482 playlist_CurrentSize( p_playlist )]];
486 if( playlist_IsEmpty( p_playlist ) )
487 [o_status_field setStringValue: _NS("No items in the playlist")];
489 [o_status_field setStringValue: _NS("1 item")];
491 vlc_object_release( p_playlist );
493 [self outlineViewSelectionDidChange: nil];
496 - (void)playModeUpdated
498 playlist_t *p_playlist = pl_Yield( VLCIntf );
500 bool loop = var_GetBool( p_playlist, "loop" );
501 bool repeat = var_GetBool( p_playlist, "repeat" );
503 [[[VLCMain sharedInstance] getControls] repeatOne];
505 [[[VLCMain sharedInstance] getControls] repeatAll];
507 [[[VLCMain sharedInstance] getControls] repeatOff];
509 [[[VLCMain sharedInstance] getControls] shuffle];
511 vlc_object_release( p_playlist );
514 - (void)outlineViewSelectionDidChange:(NSNotification *)notification
517 playlist_item_t * p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
521 /* update our info-panel to reflect the new item */
522 [[[VLCMain sharedInstance] getInfo] updatePanelWithItem:p_item->p_input];
526 - (BOOL)isSelectionEmpty
528 return [o_outline_view selectedRow] == -1;
531 - (void)updateRowSelection
537 playlist_t *p_playlist = pl_Yield( VLCIntf );
538 playlist_item_t *p_item, *p_temp_item;
539 NSMutableArray *o_array = [NSMutableArray array];
541 p_item = p_playlist->status.p_item;
544 vlc_object_release(p_playlist);
548 p_temp_item = p_item;
549 while( p_temp_item->p_parent )
551 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
552 p_temp_item = p_temp_item->p_parent;
555 for( j = 0; j < [o_array count] - 1; j++ )
558 if( ( o_item = [o_outline_dict objectForKey:
559 [NSString stringWithFormat: @"%p",
560 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
562 [o_outline_view expandItem: o_item];
567 vlc_object_release( p_playlist );
571 /* Check if p_item is a child of p_node recursively. We need to check the item
572 existence first since OSX sometimes tries to redraw items that have been
573 deleted. We don't do it when not required since this verification takes
574 quite a long time on big playlists (yes, pretty hacky). */
576 - (BOOL)isItem: (playlist_item_t *)p_item
577 inNode: (playlist_item_t *)p_node
578 checkItemExistence:(BOOL)b_check
579 locked:(BOOL)b_locked
582 playlist_t * p_playlist = pl_Yield( VLCIntf );
583 playlist_item_t *p_temp_item = p_item;
585 if( p_node == p_item )
587 vlc_object_release(p_playlist);
591 if( p_node->i_children < 1)
593 vlc_object_release(p_playlist);
600 if(!b_locked) PL_LOCK;
604 /* Since outlineView: willDisplayCell:... may call this function with
605 p_items that don't exist anymore, first check if the item is still
606 in the playlist. Any cleaner solution welcomed. */
607 for( i = 0; i < p_playlist->all_items.i_size; i++ )
609 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
610 else if ( i == p_playlist->all_items.i_size - 1 )
612 if(!b_locked) PL_UNLOCK;
613 vlc_object_release( p_playlist );
621 p_temp_item = p_temp_item->p_parent;
622 if( p_temp_item == p_node )
624 if(!b_locked) PL_UNLOCK;
625 vlc_object_release( p_playlist );
629 if(!b_locked) PL_UNLOCK;
632 vlc_object_release( p_playlist );
636 - (BOOL)isItem: (playlist_item_t *)p_item
637 inNode: (playlist_item_t *)p_node
638 checkItemExistence:(BOOL)b_check
640 [self isItem:p_item inNode:p_node checkItemExistence:b_check locked:NO];
643 /* This method is usefull for instance to remove the selected children of an
644 already selected node */
645 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
648 for( i = 0 ; i < [o_items count] ; i++ )
650 for ( j = 0 ; j < [o_nodes count] ; j++ )
652 if( o_items == o_nodes)
654 if( j == i ) continue;
656 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
657 inNode: [[o_nodes objectAtIndex:j] pointerValue]
658 checkItemExistence: NO locked:NO] )
660 [o_items removeObjectAtIndex:i];
661 /* We need to execute the next iteration with the same index
662 since the current item has been deleted */
670 - (IBAction)savePlaylist:(id)sender
672 playlist_t * p_playlist = pl_Yield( VLCIntf );
674 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
675 NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
677 //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];
678 [o_save_panel setTitle: _NS("Save Playlist")];
679 [o_save_panel setPrompt: _NS("Save")];
680 [o_save_panel setAccessoryView: o_save_accessory_view];
682 if( [o_save_panel runModalForDirectory: nil
683 file: o_name] == NSOKButton )
685 NSString *o_filename = [o_save_panel filename];
687 if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
689 NSString * o_real_filename;
691 range.location = [o_filename length] - [@".xspf" length];
692 range.length = [@".xspf" length];
694 if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
695 range: range] != NSOrderedSame )
697 o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];
701 o_real_filename = o_filename;
703 playlist_Export( p_playlist,
704 [o_real_filename fileSystemRepresentation],
705 p_playlist->p_local_category, "export-xspf" );
709 NSString * o_real_filename;
711 range.location = [o_filename length] - [@".m3u" length];
712 range.length = [@".m3u" length];
714 if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
715 range: range] != NSOrderedSame )
717 o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
721 o_real_filename = o_filename;
723 playlist_Export( p_playlist,
724 [o_real_filename fileSystemRepresentation],
725 p_playlist->p_local_category, "export-m3u" );
728 vlc_object_release( p_playlist );
731 /* When called retrieves the selected outlineview row and plays that node or item */
732 - (IBAction)playItem:(id)sender
734 intf_thread_t * p_intf = VLCIntf;
735 playlist_t * p_playlist = pl_Yield( p_intf );
737 playlist_item_t *p_item;
738 playlist_item_t *p_node = NULL;
740 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
744 if( p_item->i_children == -1 )
746 p_node = p_item->p_parent;
752 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
754 p_item = p_node->pp_children[0];
761 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked, p_node, p_item );
763 vlc_object_release( p_playlist );
766 /* When called retrieves the selected outlineview row and plays that node or item */
767 - (IBAction)preparseItem:(id)sender
770 NSMutableArray *o_to_preparse;
771 intf_thread_t * p_intf = VLCIntf;
772 playlist_t * p_playlist = pl_Yield( p_intf );
774 o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
775 i_count = [o_to_preparse count];
779 playlist_item_t *p_item = NULL;
781 for( i = 0; i < i_count; i++ )
783 o_number = [o_to_preparse lastObject];
784 i_row = [o_number intValue];
785 p_item = [[o_outline_view itemAtRow:i_row] pointerValue];
786 [o_to_preparse removeObject: o_number];
787 [o_outline_view deselectRow: i_row];
791 if( p_item->i_children == -1 )
793 playlist_PreparseEnqueue( p_playlist, p_item->p_input );
797 msg_Dbg( p_intf, "preparsing nodes not implemented" );
801 vlc_object_release( p_playlist );
802 [self playlistUpdated];
805 - (IBAction)servicesChange:(id)sender
807 NSMenuItem *o_mi = (NSMenuItem *)sender;
808 NSString *o_string = [o_mi representedObject];
809 playlist_t * p_playlist = pl_Yield( VLCIntf );
810 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )
811 playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );
813 playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );
815 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
816 [o_string UTF8String] ) ? YES : NO];
818 vlc_object_release( p_playlist );
819 [self playlistUpdated];
823 - (IBAction)selectAll:(id)sender
825 [o_outline_view selectAll: nil];
828 - (IBAction)deleteItem:(id)sender
831 NSMutableArray *o_to_delete;
834 playlist_t * p_playlist;
835 intf_thread_t * p_intf = VLCIntf;
837 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
838 i_count = [o_to_delete count];
840 p_playlist = pl_Yield( p_intf );
843 for( int i = 0; i < i_count; i++ )
845 o_number = [o_to_delete lastObject];
846 i_row = [o_number intValue];
847 id o_item = [o_outline_view itemAtRow: i_row];
848 playlist_item_t *p_item = [o_item pointerValue];
850 msg_Dbg( p_intf, "deleting item %i (of %i) with id \"%i\", pointerValue \"%p\" and %i children", i+1, i_count,
851 p_item->p_input->i_id, [o_item pointerValue], p_item->i_children +1 );
853 [o_to_delete removeObject: o_number];
854 [o_outline_view deselectRow: i_row];
856 if( p_item->i_children != -1 )
857 //is a node and not an item
859 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
860 [self isItem: p_playlist->status.p_item inNode:
861 ((playlist_item_t *)[o_item pointerValue])
862 checkItemExistence: NO locked:YES] == YES )
863 // if current item is in selected node and is playing then stop playlist
864 playlist_Control(p_playlist, PLAYLIST_STOP, pl_Locked );
866 playlist_NodeDelete( p_playlist, p_item, true, false );
869 playlist_DeleteFromInput( p_playlist, p_item->p_input->i_id, pl_Locked );
873 [self playlistUpdated];
874 vlc_object_release( p_playlist );
877 - (IBAction)sortNodeByName:(id)sender
879 [self sortNode: SORT_TITLE];
882 - (IBAction)sortNodeByAuthor:(id)sender
884 [self sortNode: SORT_ARTIST];
887 - (void)sortNode:(int)i_mode
889 playlist_t * p_playlist = pl_Yield( VLCIntf );
890 playlist_item_t * p_item;
892 if( [o_outline_view selectedRow] > -1 )
894 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]] pointerValue];
897 /*If no item is selected, sort the whole playlist*/
899 p_item = p_playlist->p_root_category;
902 if( p_item->i_children > -1 ) // the item is a node
905 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
911 playlist_RecursiveNodeSort( p_playlist,
912 p_item->p_parent, i_mode, ORDER_NORMAL );
915 vlc_object_release( p_playlist );
916 [self playlistUpdated];
919 - (input_item_t *)createItem:(NSDictionary *)o_one_item
921 intf_thread_t * p_intf = VLCIntf;
922 playlist_t * p_playlist = pl_Yield( p_intf );
924 input_item_t *p_input;
926 BOOL b_rem = FALSE, b_dir = FALSE;
927 NSString *o_uri, *o_name;
932 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
933 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
934 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
936 /* Find the name for a disc entry (i know, can you believe the trouble?) */
937 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
939 int i_count, i_index;
940 struct statfs *mounts = NULL;
942 i_count = getmntinfo (&mounts, MNT_NOWAIT);
943 /* getmntinfo returns a pointer to static data. Do not free. */
944 for( i_index = 0 ; i_index < i_count; i_index++ )
946 NSMutableString *o_temp, *o_temp2;
947 o_temp = [NSMutableString stringWithString: o_uri];
948 o_temp2 = [NSMutableString stringWithUTF8String: mounts[i_index].f_mntfromname];
949 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
950 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ];
951 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ];
953 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
955 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithUTF8String:mounts[i_index].f_mntonname]];
959 /* If no name, then make a guess */
960 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
962 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
963 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
964 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
966 /* All of this is to make sure CD's play when you D&D them on VLC */
967 /* Converts mountpoint to a /dev file */
970 NSMutableString *o_temp;
972 buf = (struct statfs *) malloc (sizeof(struct statfs));
973 statfs( [o_uri fileSystemRepresentation], buf );
974 psz_dev = strdup(buf->f_mntfromname);
975 o_temp = [NSMutableString stringWithUTF8String: psz_dev ];
976 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
977 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
978 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
982 p_input = input_item_New( p_playlist, [o_uri fileSystemRepresentation], [o_name UTF8String] );
988 for( i = 0; i < (int)[o_options count]; i++ )
990 input_item_AddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
994 /* Recent documents menu */
995 o_true_file = [NSURL fileURLWithPath: o_uri];
996 if( o_true_file != nil && (BOOL)config_GetInt( p_playlist, "macosx-recentitems" ) == YES )
998 [[NSDocumentController sharedDocumentController]
999 noteNewRecentDocumentURL: o_true_file];
1002 vlc_object_release( p_playlist );
1006 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
1009 playlist_t * p_playlist = pl_Yield( VLCIntf );
1012 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1014 input_item_t *p_input;
1015 NSDictionary *o_one_item;
1018 o_one_item = [o_array objectAtIndex: i_item];
1019 p_input = [self createItem: o_one_item];
1026 /* FIXME: playlist_AddInput() can fail */
1028 playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
1029 i_position == -1 ? PLAYLIST_END : i_position + i_item, true,
1032 if( i_item == 0 && !b_enqueue )
1034 playlist_item_t *p_item;
1035 p_item = playlist_ItemGetByInput( p_playlist, p_input, pl_Locked );
1036 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, NULL, p_item );
1038 vlc_gc_decref( p_input );
1042 [self playlistUpdated];
1043 vlc_object_release( p_playlist );
1046 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
1049 playlist_t * p_playlist = pl_Yield( VLCIntf );
1051 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1053 input_item_t *p_input;
1054 NSDictionary *o_one_item;
1057 o_one_item = [o_array objectAtIndex: i_item];
1058 p_input = [self createItem: o_one_item];
1060 if( !p_input ) continue;
1063 /* FIXME: playlist_BothAddInput() can fail */
1065 playlist_BothAddInput( p_playlist, p_input, p_node,
1068 PLAYLIST_END : i_position + i_item,
1069 NULL, NULL, pl_Locked );
1072 if( i_item == 0 && !b_enqueue )
1074 playlist_item_t *p_item;
1075 p_item = playlist_ItemGetByInput( p_playlist, p_input, pl_Locked );
1076 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, NULL, p_item );
1079 vlc_gc_decref( p_input );
1081 [self playlistUpdated];
1082 vlc_object_release( p_playlist );
1085 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
1087 playlist_t *p_playlist = pl_Yield( VLCIntf );
1088 playlist_item_t *p_selected_item;
1089 int i_current, i_selected_row;
1091 i_selected_row = [o_outline_view selectedRow];
1092 if (i_selected_row < 0)
1095 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
1096 i_selected_row] pointerValue];
1098 for( i_current = 0; i_current < p_item->i_children ; i_current++ )
1101 NSString *o_current_name, *o_current_author;
1104 o_current_name = [NSString stringWithUTF8String:
1105 p_item->pp_children[i_current]->p_input->psz_name];
1106 psz_temp = input_item_GetInfo( p_item->p_input ,
1107 _("Meta-information"),_("Artist") );
1108 o_current_author = [NSString stringWithUTF8String: psz_temp];
1112 if( p_selected_item == p_item->pp_children[i_current] &&
1113 b_selected_item_met == NO )
1115 b_selected_item_met = YES;
1117 else if( p_selected_item == p_item->pp_children[i_current] &&
1118 b_selected_item_met == YES )
1120 vlc_object_release( p_playlist );
1123 else if( b_selected_item_met == YES &&
1124 ( [o_current_name rangeOfString:[o_search_field
1125 stringValue] options:NSCaseInsensitiveSearch].length ||
1126 [o_current_author rangeOfString:[o_search_field
1127 stringValue] options:NSCaseInsensitiveSearch].length ) )
1129 vlc_object_release( p_playlist );
1130 /*Adds the parent items in the result array as well, so that we can
1132 return [NSMutableArray arrayWithObject: [NSValue
1133 valueWithPointer: p_item->pp_children[i_current]]];
1135 if( p_item->pp_children[i_current]->i_children > 0 )
1137 id o_result = [self subSearchItem:
1138 p_item->pp_children[i_current]];
1139 if( o_result != NULL )
1141 vlc_object_release( p_playlist );
1142 [o_result insertObject: [NSValue valueWithPointer:
1143 p_item->pp_children[i_current]] atIndex:0];
1148 vlc_object_release( p_playlist );
1152 - (IBAction)searchItem:(id)sender
1154 playlist_t * p_playlist = pl_Yield( VLCIntf );
1160 b_selected_item_met = NO;
1162 /*First, only search after the selected item:*
1163 *(b_selected_item_met = NO) */
1164 o_result = [self subSearchItem:p_playlist->p_root_category];
1165 if( o_result == NULL )
1167 /* If the first search failed, search again from the beginning */
1168 o_result = [self subSearchItem:p_playlist->p_root_category];
1170 if( o_result != NULL )
1173 if( [[o_result objectAtIndex: 0] pointerValue] ==
1174 p_playlist->p_local_category )
1179 for( i = i_start ; i < [o_result count] - 1 ; i++ )
1181 [o_outline_view expandItem: [o_outline_dict objectForKey:
1182 [NSString stringWithFormat: @"%p",
1183 [[o_result objectAtIndex: i] pointerValue]]]];
1185 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1186 [NSString stringWithFormat: @"%p",
1187 [[o_result objectAtIndex: [o_result count] - 1 ]
1192 [o_outline_view selectRow:i_row byExtendingSelection: NO];
1193 [o_outline_view scrollRowToVisible: i_row];
1195 vlc_object_release( p_playlist );
1198 - (IBAction)recursiveExpandNode:(id)sender
1200 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1201 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1203 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1204 isItemExpandable: o_item] )
1206 o_item = [o_outline_dict objectForKey: [NSString
1207 stringWithFormat: @"%p", p_item->p_parent]];
1210 /* We need to collapse the node first, since OSX refuses to recursively
1211 expand an already expanded node, even if children nodes are collapsed. */
1212 [o_outline_view collapseItem: o_item collapseChildren: YES];
1213 [o_outline_view expandItem: o_item expandChildren: YES];
1216 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1222 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1224 int row = [o_outline_view rowAtPoint:pt];
1226 [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
1228 b_item_sel = ( row != -1 && [o_outline_view selectedRow] != -1 );
1229 b_rows = [o_outline_view numberOfRows] != 0;
1231 [o_mi_play setEnabled: b_item_sel];
1232 [o_mi_delete setEnabled: b_item_sel];
1233 [o_mi_selectall setEnabled: b_rows];
1234 [o_mi_info setEnabled: b_item_sel];
1235 [o_mi_preparse setEnabled: b_item_sel];
1236 [o_mi_recursive_expand setEnabled: b_item_sel];
1237 [o_mi_sort_name setEnabled: b_item_sel];
1238 [o_mi_sort_author setEnabled: b_item_sel];
1240 return( o_ctx_menu );
1243 - (void)outlineView: (NSTableView*)o_tv
1244 didClickTableColumn:(NSTableColumn *)o_tc
1246 int i_mode = 0, i_type;
1247 intf_thread_t *p_intf = VLCIntf;
1249 playlist_t *p_playlist = pl_Yield( p_intf );
1251 /* Check whether the selected table column header corresponds to a
1252 sortable table column*/
1253 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1255 vlc_object_release( p_playlist );
1259 if( o_tc_sortColumn == o_tc )
1261 b_isSortDescending = !b_isSortDescending;
1265 b_isSortDescending = false;
1268 if( o_tc == o_tc_name )
1270 i_mode = SORT_TITLE;
1272 else if( o_tc == o_tc_author )
1274 i_mode = SORT_ARTIST;
1277 if( b_isSortDescending )
1279 i_type = ORDER_REVERSE;
1283 i_type = ORDER_NORMAL;
1286 vlc_object_lock( p_playlist );
1287 playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
1288 vlc_object_unlock( p_playlist );
1290 vlc_object_release( p_playlist );
1291 [self playlistUpdated];
1293 o_tc_sortColumn = o_tc;
1294 [o_outline_view setHighlightedTableColumn:o_tc];
1296 if( b_isSortDescending )
1298 [o_outline_view setIndicatorImage:o_descendingSortingImage
1299 inTableColumn:o_tc];
1303 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1304 inTableColumn:o_tc];
1309 - (void)outlineView:(NSOutlineView *)outlineView
1310 willDisplayCell:(id)cell
1311 forTableColumn:(NSTableColumn *)tableColumn
1314 playlist_t *p_playlist = pl_Yield( VLCIntf );
1318 o_playing_item = [o_outline_dict objectForKey:
1319 [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
1321 if( [self isItem: [o_playing_item pointerValue] inNode:
1322 [item pointerValue] checkItemExistence: YES]
1323 || [o_playing_item isEqual: item] )
1325 [cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toHaveTrait:NSBoldFontMask]];
1329 [cell setFont: [[NSFontManager sharedFontManager] convertFont:[cell font] toNotHaveTrait:NSBoldFontMask]];
1331 vlc_object_release( p_playlist );
1334 - (IBAction)addNode:(id)sender
1336 /* we have to create a new thread here because otherwise we would block the
1337 * interface since the interaction-stuff and this code would run in the same
1339 [NSThread detachNewThreadSelector: @selector(addNodeThreadedly)
1340 toTarget: self withObject:nil];
1341 [self playlistUpdated];
1344 - (void)addNodeThreadedly
1346 NSAutoreleasePool * ourPool = [[NSAutoreleasePool alloc] init];
1348 /* simply adds a new node to the end of the playlist */
1349 playlist_t * p_playlist = pl_Yield( VLCIntf );
1350 vlc_thread_set_priority( p_playlist, VLC_THREAD_PRIORITY_LOW );
1353 char *psz_name = NULL;
1354 ret_v = intf_UserStringInput( p_playlist, _("New Node"),
1355 _("Please enter a name for the new node."), &psz_name );
1358 if( ret_v != DIALOG_CANCELLED && psz_name )
1360 playlist_NodeCreate( p_playlist, psz_name,
1361 p_playlist->p_local_category, 0, NULL );
1363 else if(! config_GetInt( p_playlist, "interact" ) )
1365 /* in case that the interaction is disabled, just give it a bogus name */
1366 playlist_NodeCreate( p_playlist, _("Empty Folder"),
1367 p_playlist->p_local_category, 0, NULL );
1372 pl_Release( VLCIntf );
1378 @implementation VLCPlaylist (NSOutlineViewDataSource)
1380 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1382 id o_value = [super outlineView: outlineView child: index ofItem: item];
1383 playlist_t *p_playlist = pl_Yield( VLCIntf );
1385 if( playlist_CurrentSize( p_playlist ) >= 2 )
1387 [o_status_field setStringValue: [NSString stringWithFormat:
1389 playlist_CurrentSize( p_playlist )]];
1393 if( playlist_IsEmpty( p_playlist ) )
1395 [o_status_field setStringValue: _NS("No items in the playlist")];
1399 [o_status_field setStringValue: _NS("1 item")];
1402 vlc_object_release( p_playlist );
1404 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
1405 [o_value pointerValue]]];
1410 /* Required for drag & drop and reordering */
1411 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1414 playlist_t *p_playlist = pl_Yield( VLCIntf );
1416 /* First remove the items that were moved during the last drag & drop
1418 [o_items_array removeAllObjects];
1419 [o_nodes_array removeAllObjects];
1421 for( i = 0 ; i < [items count] ; i++ )
1423 id o_item = [items objectAtIndex: i];
1425 /* Refuse to move items that are not in the General Node
1426 (Service Discovery) */
1427 if( ![self isItem: [o_item pointerValue] inNode:
1428 p_playlist->p_local_category checkItemExistence: NO] &&
1429 ( var_CreateGetBool( p_playlist, "media-library" ) &&
1430 ![self isItem: [o_item pointerValue] inNode:
1431 p_playlist->p_ml_category checkItemExistence: NO]) )
1433 vlc_object_release(p_playlist);
1436 /* Fill the items and nodes to move in 2 different arrays */
1437 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1438 [o_nodes_array addObject: o_item];
1440 [o_items_array addObject: o_item];
1443 /* Now we need to check if there are selected items that are in already
1444 selected nodes. In that case, we only want to move the nodes */
1445 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1446 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1448 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1449 a Drop operation coming from the playlist. */
1451 [pboard declareTypes: [NSArray arrayWithObjects:
1452 @"VLCPlaylistItemPboardType", nil] owner: self];
1453 [pboard setData:[NSData data] forType:@"VLCPlaylistItemPboardType"];
1455 vlc_object_release(p_playlist);
1459 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1461 playlist_t *p_playlist = pl_Yield( VLCIntf );
1462 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1464 if( !p_playlist ) return NSDragOperationNone;
1466 /* Dropping ON items is not allowed if item is not a node */
1469 if( index == NSOutlineViewDropOnItemIndex &&
1470 ((playlist_item_t *)[item pointerValue])->i_children == -1 )
1472 vlc_object_release( p_playlist );
1473 return NSDragOperationNone;
1477 /* Don't allow on drop on playlist root element's child */
1478 if( !item && index != NSOutlineViewDropOnItemIndex)
1480 vlc_object_release( p_playlist );
1481 return NSDragOperationNone;
1484 /* We refuse to drop an item in anything else than a child of the General
1485 Node. We still accept items that would be root nodes of the outlineview
1486 however, to allow drop in an empty playlist. */
1487 if( !( ([self isItem: [item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] ||
1488 ( var_CreateGetBool( p_playlist, "media-library" ) && [self isItem: [item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO] ) ) || item == nil ) )
1490 vlc_object_release( p_playlist );
1491 return NSDragOperationNone;
1494 /* Drop from the Playlist */
1495 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1498 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1500 /* We refuse to Drop in a child of an item we are moving */
1501 if( [self isItem: [item pointerValue] inNode:
1502 [[o_nodes_array objectAtIndex: i] pointerValue]
1503 checkItemExistence: NO] )
1505 vlc_object_release( p_playlist );
1506 return NSDragOperationNone;
1509 vlc_object_release( p_playlist );
1510 return NSDragOperationMove;
1513 /* Drop from the Finder */
1514 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1516 vlc_object_release( p_playlist );
1517 return NSDragOperationGeneric;
1519 vlc_object_release( p_playlist );
1520 return NSDragOperationNone;
1523 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1525 playlist_t * p_playlist = pl_Yield( VLCIntf );
1526 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1528 /* Drag & Drop inside the playlist */
1529 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1531 int i_row, i_removed_from_node = 0;
1533 playlist_item_t *p_new_parent, *p_item = NULL;
1534 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1536 /* If the item is to be dropped as root item of the outline, make it a
1537 child of the General node.
1538 Else, choose the proposed parent as parent. */
1539 if( item == nil ) p_new_parent = p_playlist->p_local_category;
1540 else p_new_parent = [item pointerValue];
1542 /* Make sure the proposed parent is a node.
1543 (This should never be true) */
1544 if( p_new_parent->i_children < 0 )
1546 vlc_object_release( p_playlist );
1550 for( i = 0; i < [o_all_items count]; i++ )
1552 playlist_item_t *p_old_parent = NULL;
1553 int i_old_index = 0;
1555 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1556 p_old_parent = p_item->p_parent;
1559 /* We may need the old index later */
1560 if( p_new_parent == p_old_parent )
1563 for( j = 0; j < p_old_parent->i_children; j++ )
1565 if( p_old_parent->pp_children[j] == p_item )
1574 // Actually detach the item from the old position
1575 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1579 /* Calculate the new index */
1582 /* If we move the item in the same node, we need to take into
1583 account that one item will be deleted */
1586 if ((p_new_parent == p_old_parent &&
1587 i_old_index < index + (int)i) )
1589 i_removed_from_node++;
1591 i_new_index = index + i - i_removed_from_node;
1593 // Reattach the item to the new position
1594 playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1598 [self playlistUpdated];
1599 i_row = [o_outline_view rowForItem:[o_outline_dict
1600 objectForKey:[NSString stringWithFormat: @"%p",
1601 [[o_all_items objectAtIndex: 0] pointerValue]]]];
1605 i_row = [o_outline_view rowForItem:[o_outline_dict
1606 objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1609 [o_outline_view deselectAll: self];
1610 [o_outline_view selectRow: i_row byExtendingSelection: NO];
1611 [o_outline_view scrollRowToVisible: i_row];
1613 vlc_object_release( p_playlist );
1617 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1620 playlist_item_t *p_node = [item pointerValue];
1622 NSArray *o_array = [NSArray array];
1623 NSArray *o_values = [[o_pasteboard propertyListForType:
1624 NSFilenamesPboardType]
1625 sortedArrayUsingSelector:
1626 @selector(caseInsensitiveCompare:)];
1628 for( i = 0; i < (int)[o_values count]; i++)
1630 NSDictionary *o_dic;
1631 o_dic = [NSDictionary dictionaryWithObject:[o_values
1632 objectAtIndex:i] forKey:@"ITEM_URL"];
1633 o_array = [o_array arrayByAddingObject: o_dic];
1638 [self appendArray:o_array atPos:index enqueue: YES];
1642 assert( p_node->i_children != -1 );
1643 [self appendNodeArray:o_array inNode: p_node
1644 atPos:index enqueue:YES];
1646 vlc_object_release( p_playlist );
1649 vlc_object_release( p_playlist );