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

📄 playlist.m

📁 VLC Player Source Code
💻 M
📖 第 1 页 / 共 4 页
字号:
        free( ppsz_services[i] );        free( ppsz_name[i] );    }    free( ppsz_services );    free( ppsz_name );    vlc_object_release( p_playlist );}- (void)searchfieldChanged:(NSNotification *)o_notification{    [o_search_field setStringValue:[[o_notification object] stringValue]];}- (void)initStrings{    [super initStrings];    [o_mi_save_playlist setTitle: _NS("Save Playlist...")];    [o_mi_play setTitle: _NS("Play")];    [o_mi_delete setTitle: _NS("Delete")];    [o_mi_recursive_expand setTitle: _NS("Expand Node")];    [o_mi_selectall setTitle: _NS("Select All")];    [o_mi_info setTitle: _NS("Information...")];    [o_mi_preparse setTitle: _NS("Fetch Meta Data")];    [o_mi_sort_name setTitle: _NS("Sort Node by Name")];    [o_mi_sort_author setTitle: _NS("Sort Node by Author")];    [o_mi_services setTitle: _NS("Services discovery")];    [o_mm_mi_services setTitle: _NS("Services discovery")];    [o_status_field setStringValue: _NS("No items in the playlist")];    [o_search_field setToolTip: _NS("Search in Playlist")];    [o_mi_addNode setTitle: _NS("Add Folder to Playlist")];    [o_save_accessory_text setStringValue: _NS("File Format:")];    [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];    [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];}- (void)playlistUpdated{    /* Clear indications of any existing column sorting */    for( unsigned int i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )    {        [o_outline_view setIndicatorImage:nil inTableColumn:                            [[o_outline_view tableColumns] objectAtIndex:i]];    }    [o_outline_view setHighlightedTableColumn:nil];    o_tc_sortColumn = nil;    // TODO Find a way to keep the dict size to a minimum    //[o_outline_dict removeAllObjects];    [o_outline_view reloadData];    [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView];    [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData];    playlist_t *p_playlist = pl_Yield( VLCIntf );    if( playlist_CurrentSize( p_playlist ) >= 2 )    {        [o_status_field setStringValue: [NSString stringWithFormat:                    _NS("%i items"),                playlist_CurrentSize( p_playlist )]];    }    else    {        if( playlist_IsEmpty( p_playlist ) )            [o_status_field setStringValue: _NS("No items in the playlist")];        else            [o_status_field setStringValue: _NS("1 item")];    }    vlc_object_release( p_playlist );    [self outlineViewSelectionDidChange: nil];}- (void)playModeUpdated{    playlist_t *p_playlist = pl_Yield( VLCIntf );    bool loop = var_GetBool( p_playlist, "loop" );    bool repeat = var_GetBool( p_playlist, "repeat" );    if( repeat )        [[[VLCMain sharedInstance] getControls] repeatOne];    else if( loop )        [[[VLCMain sharedInstance] getControls] repeatAll];    else        [[[VLCMain sharedInstance] getControls] repeatOff];    [[[VLCMain sharedInstance] getControls] shuffle];    vlc_object_release( p_playlist );}- (void)outlineViewSelectionDidChange:(NSNotification *)notification{    // FIXME: unsafe    playlist_item_t * p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];    if( p_item )    {        /* update our info-panel to reflect the new item */        [[[VLCMain sharedInstance] getInfo] updatePanelWithItem:p_item->p_input];    }}- (BOOL)isSelectionEmpty{    return [o_outline_view selectedRow] == -1;}- (void)updateRowSelection{    int i_row;    unsigned int j;    // FIXME: unsafe    playlist_t *p_playlist = pl_Yield( VLCIntf );    playlist_item_t *p_item, *p_temp_item;    NSMutableArray *o_array = [NSMutableArray array];    p_item = p_playlist->status.p_item;    if( p_item == NULL )    {        vlc_object_release(p_playlist);        return;    }    p_temp_item = p_item;    while( p_temp_item->p_parent )    {        [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];        p_temp_item = p_temp_item->p_parent;    }    for( j = 0; j < [o_array count] - 1; j++ )    {        id o_item;        if( ( o_item = [o_outline_dict objectForKey:                            [NSString stringWithFormat: @"%p",                            [[o_array objectAtIndex:j] pointerValue]]] ) != nil )        {            [o_outline_view expandItem: o_item];        }    }    vlc_object_release( p_playlist );}/* Check if p_item is a child of p_node recursively. We need to check the item   existence first since OSX sometimes tries to redraw items that have been   deleted. We don't do it when not required since this verification takes   quite a long time on big playlists (yes, pretty hacky). */- (BOOL)isItem: (playlist_item_t *)p_item                    inNode: (playlist_item_t *)p_node                    checkItemExistence:(BOOL)b_check                    locked:(BOOL)b_locked{    playlist_t * p_playlist = pl_Yield( VLCIntf );    playlist_item_t *p_temp_item = p_item;    if( p_node == p_item )    {        vlc_object_release(p_playlist);        return YES;    }    if( p_node->i_children < 1)    {        vlc_object_release(p_playlist);        return NO;    }    if ( p_temp_item )    {        int i;        if(!b_locked) PL_LOCK;        if( b_check )        {        /* Since outlineView: willDisplayCell:... may call this function with           p_items that don't exist anymore, first check if the item is still           in the playlist. Any cleaner solution welcomed. */            for( i = 0; i < p_playlist->all_items.i_size; i++ )            {                if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;                else if ( i == p_playlist->all_items.i_size - 1 )                {                    if(!b_locked) PL_UNLOCK;                    vlc_object_release( p_playlist );                    return NO;                }            }        }        while( p_temp_item )        {            p_temp_item = p_temp_item->p_parent;            if( p_temp_item == p_node )            {                if(!b_locked) PL_UNLOCK;                vlc_object_release( p_playlist );                return YES;            }        }        if(!b_locked) PL_UNLOCK;    }    vlc_object_release( p_playlist );    return NO;}- (BOOL)isItem: (playlist_item_t *)p_item                    inNode: (playlist_item_t *)p_node                    checkItemExistence:(BOOL)b_check{    [self isItem:p_item inNode:p_node checkItemExistence:b_check locked:NO];}/* This method is usefull for instance to remove the selected children of an   already selected node */- (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes{    unsigned int i, j;    for( i = 0 ; i < [o_items count] ; i++ )    {        for ( j = 0 ; j < [o_nodes count] ; j++ )        {            if( o_items == o_nodes)            {                if( j == i ) continue;            }            if( [self isItem: [[o_items objectAtIndex:i] pointerValue]                    inNode: [[o_nodes objectAtIndex:j] pointerValue]                    checkItemExistence: NO locked:NO] )            {                [o_items removeObjectAtIndex:i];                /* We need to execute the next iteration with the same index                   since the current item has been deleted */                i--;                break;            }        }    }}- (IBAction)savePlaylist:(id)sender{    playlist_t * p_playlist = pl_Yield( VLCIntf );    NSSavePanel *o_save_panel = [NSSavePanel savePanel];    NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];    //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];    [o_save_panel setTitle: _NS("Save Playlist")];    [o_save_panel setPrompt: _NS("Save")];    [o_save_panel setAccessoryView: o_save_accessory_view];    if( [o_save_panel runModalForDirectory: nil            file: o_name] == NSOKButton )    {        NSString *o_filename = [o_save_panel filename];        if( [o_save_accessory_popup indexOfSelectedItem] == 1 )        {            NSString * o_real_filename;            NSRange range;            range.location = [o_filename length] - [@".xspf" length];            range.length = [@".xspf" length];            if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch                                             range: range] != NSOrderedSame )            {                o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];            }            else            {                o_real_filename = o_filename;            }            playlist_Export( p_playlist,                [o_real_filename fileSystemRepresentation],                p_playlist->p_local_category, "export-xspf" );        }        else        {            NSString * o_real_filename;            NSRange range;            range.location = [o_filename length] - [@".m3u" length];            range.length = [@".m3u" length];            if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch                                             range: range] != NSOrderedSame )            {                o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];            }            else            {                o_real_filename = o_filename;            }            playlist_Export( p_playlist,                [o_real_filename fileSystemRepresentation],                p_playlist->p_local_category, "export-m3u" );        }    }    vlc_object_release( p_playlist );}/* When called retrieves the selected outlineview row and plays that node or item */- (IBAction)playItem:(id)sender{    intf_thread_t * p_intf = VLCIntf;    playlist_t * p_playlist = pl_Yield( p_intf );    playlist_item_t *p_item;    playlist_item_t *p_node = NULL;    p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];    if( p_item )    {        if( p_item->i_children == -1 )        {            p_node = p_item->p_parent;        }        else        {            p_node = p_item;            if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )            {                p_item = p_node->pp_children[0];            }            else            {                p_item = NULL;            }        }        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked, p_node, p_item );    }    vlc_object_release( p_playlist );}/* When called retrieves the selected outlineview row and plays that node or item */- (IBAction)preparseItem:(id)sender{    int i_count;    NSMutableArray *o_to_preparse;    intf_thread_t * p_intf = VLCIntf;    playlist_t * p_playlist = pl_Yield( p_intf );     o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];    i_count = [o_to_preparse count];    int i, i_row;    NSNumber *o_number;    playlist_item_t *p_item = NULL;    for( i = 0; i < i_count; i++ )    {        o_number = [o_to_preparse lastObject];        i_row = [o_number intValue];        p_item = [[o_outline_view itemAtRow:i_row] pointerValue];        [o_to_preparse removeObject: o_number];        [o_outline_view deselectRow: i_row];        if( p_item )        {            if( p_item->i_children == -1 )            {                playlist_PreparseEnqueue( p_playlist, p_item->p_input );            }            else            {                msg_Dbg( p_intf, "preparsing nodes not implemented" );            }        }    }    vlc_object_release( p_playlist );    [self playlistUpdated];}- (IBAction)servicesChange:(id)sender{    NSMenuItem *o_mi = (NSMenuItem *)sender;    NSString *o_string = [o_mi representedObject];    playlist_t * p_playlist = pl_Yield( VLCIntf );    if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )        playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );    else        playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );    [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,                                          [o_string UTF8String] ) ? YES : NO];    vlc_object_release( p_playlist );    [self playlistUpdated];    return;}- (IBAction)selectAll:(id)sender{    [o_outline_view selectAll: nil];}- (IBAction)deleteItem:(id)sender{    int i_count, i_row;    NSMutableArray *o_to_delete;    NSNumber *o_number;    playlist_t * p_playlist;    intf_thread_t * p_intf = VLCIntf;

⌨️ 快捷键说明

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