123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /*****************************************************************************
- * VLCDiscoveryListViewController.m
- * VLC for iOS
- *****************************************************************************
- * Copyright (c) 2015 VideoLAN. All rights reserved.
- * $Id$
- *
- * Author: Felix Paul Kühne <fkuehne # videolan.org>
- *
- * Refer to the COPYING file of the official project for license.
- *****************************************************************************/
- #import "VLCDiscoveryListViewController.h"
- #import "VLCNetworkListCell.h"
- @interface VLCDiscoveryListViewController () <VLCNetworkListCellDelegate, UITableViewDataSource, UITableViewDelegate, VLCMediaDelegate>
- {
- VLCMediaList *_mediaList;
- VLCMedia *rootMedia;
- }
- @end
- @implementation VLCDiscoveryListViewController
- - (instancetype)initWithMedia:(VLCMedia *)media
- {
- self = [super init];
- if (!self)
- return self;
- _mediaList = [media subitems];
- self.title = [media metadataForKey:VLCMetaInformationTitle];
- NSLog(@"media meta %@", media.metaDictionary);
- NSLog(@"count %lu", _mediaList.count);
- rootMedia = media;
- return self;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [self.tableView reloadData];
- [rootMedia setDelegate:self];
- [rootMedia parseWithOptions:VLCMediaParseNetwork | VLCMediaFetchNetwork];
- }
- #pragma mark - media delegate
- - (void)mediaDidFinishParsing:(VLCMedia *)aMedia
- {
- NSLog(@"finished parsing %@, sub items %@", aMedia, [aMedia subitems]);
- }
- - (void)mediaMetaDataDidChange:(VLCMedia *)aMedia
- {
- NSLog(@"metadata changed %@, meta %@", aMedia, [aMedia metaDictionary]);
- }
- #pragma mark - table view data source, for more see super
- - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return _mediaList.count;
- }
- - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"DiscoveryCell";
- VLCNetworkListCell *cell = (VLCNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier
- forIndexPath:indexPath];
- if (cell == nil)
- cell = [VLCNetworkListCell cellWithReuseIdentifier:CellIdentifier];
- VLCMedia *cellObject = [_mediaList mediaAtIndex:indexPath.row];
- cell.isDirectory = cellObject.mediaType == VLCMediaTypeDirectory;
- cell.isDownloadable = NO;
- cell.title = [cellObject metadataForKey:VLCMetaInformationTitle];
- cell.subtitle = cellObject.url.absoluteString;
- return cell;
- }
- - (void)triggerDownloadForCell:(VLCNetworkListCell *)cell
- {
- NSLog(@"downloads not implemented");
- }
- @end
|