VLCDiscoveryListViewController.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // VLCDiscoveryListViewController.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 15/06/15.
  6. // Copyright © 2015 VideoLAN. All rights reserved.
  7. //
  8. #import "VLCDiscoveryListViewController.h"
  9. #import "VLCNetworkListCell.h"
  10. @interface VLCDiscoveryListViewController () <VLCNetworkListCellDelegate, UITableViewDataSource, UITableViewDelegate, VLCMediaDelegate>
  11. {
  12. VLCMediaList *_mediaList;
  13. VLCMedia *rootMedia;
  14. }
  15. @end
  16. @implementation VLCDiscoveryListViewController
  17. - (instancetype)initWithMedia:(VLCMedia *)media
  18. {
  19. self = [super init];
  20. if (!self)
  21. return self;
  22. _mediaList = [media subitems];
  23. self.title = [media metadataForKey:VLCMetaInformationTitle];
  24. NSLog(@"media meta %@", media.metaDictionary);
  25. NSLog(@"count %lu", _mediaList.count);
  26. rootMedia = media;
  27. return self;
  28. }
  29. - (void)viewWillAppear:(BOOL)animated
  30. {
  31. [self.tableView reloadData];
  32. [rootMedia setDelegate:self];
  33. [rootMedia parseWithOptions:VLCMediaParseNetwork | VLCMediaFetchNetwork];
  34. }
  35. #pragma mark - media delegate
  36. - (void)mediaDidFinishParsing:(VLCMedia *)aMedia
  37. {
  38. NSLog(@"finished parsing %@, sub items %@", aMedia, [aMedia subitems]);
  39. }
  40. - (void)mediaMetaDataDidChange:(VLCMedia *)aMedia
  41. {
  42. NSLog(@"metadata changed %@, meta %@", aMedia, [aMedia metaDictionary]);
  43. }
  44. #pragma mark - table view data source, for more see super
  45. - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  46. {
  47. return _mediaList.count;
  48. }
  49. - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
  50. {
  51. static NSString *CellIdentifier = @"DiscoveryCell";
  52. VLCNetworkListCell *cell = (VLCNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier
  53. forIndexPath:indexPath];
  54. if (cell == nil)
  55. cell = [VLCNetworkListCell cellWithReuseIdentifier:CellIdentifier];
  56. VLCMedia *cellObject = [_mediaList mediaAtIndex:indexPath.row];
  57. cell.isDirectory = cellObject.mediaType == VLCMediaTypeDirectory;
  58. cell.isDownloadable = NO;
  59. cell.title = [cellObject metadataForKey:VLCMetaInformationTitle];
  60. cell.subtitle = cellObject.url.absoluteString;
  61. return cell;
  62. }
  63. - (void)triggerDownloadForCell:(VLCNetworkListCell *)cell
  64. {
  65. NSLog(@"downloads not implemented");
  66. }
  67. @end