VLCLocalServerListViewController.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /*****************************************************************************
  2. * VLCLocalServerListViewController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2014 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. * Pierre SAGASPE <pierre.sagaspe # me.com>
  10. * Gleb Pinigin <gpinigin # gmail.com>
  11. *
  12. * Refer to the COPYING file of the official project for license.
  13. *****************************************************************************/
  14. #import "VLCLocalServerListViewController.h"
  15. #import "UIBarButtonItem+Theme.h"
  16. #import "VLCAppDelegate.h"
  17. #import "UPnPManager.h"
  18. #import "VLCLocalNetworkListCell.h"
  19. #import "VLCLocalServerFolderListViewController.h"
  20. #import <QuartzCore/QuartzCore.h>
  21. #import "GHRevealViewController.h"
  22. #import "VLCNetworkLoginViewController.h"
  23. #import "UINavigationController+Theme.h"
  24. #import "VLCPlaylistViewController.h"
  25. #import "Reachability.h"
  26. @interface VLCLocalServerListViewController () <UITableViewDataSource, UITableViewDelegate, NSNetServiceBrowserDelegate, VLCNetworkLoginViewController, NSNetServiceDelegate, VLCMediaListDelegate>
  27. {
  28. UIBarButtonItem *_backToMenuButton;
  29. NSArray *_sectionHeaderTexts;
  30. NSNetServiceBrowser *_ftpNetServiceBrowser;
  31. NSMutableArray *_rawNetServices;
  32. NSMutableArray *_ftpServices;
  33. NSArray *_filteredUPNPDevices;
  34. NSArray *_UPNPdevices;
  35. VLCMediaDiscoverer * _sapDiscoverer;
  36. VLCNetworkLoginViewController *_loginViewController;
  37. UIRefreshControl *_refreshControl;
  38. UIActivityIndicatorView *_activityIndicator;
  39. Reachability *_reachability;
  40. BOOL _udnpDiscoveryRunning;
  41. NSTimer *_searchTimer;
  42. }
  43. @end
  44. @implementation VLCLocalServerListViewController
  45. - (void)dealloc
  46. {
  47. [_reachability stopNotifier];
  48. [_ftpNetServiceBrowser stop];
  49. }
  50. - (void)loadView
  51. {
  52. _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
  53. _tableView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  54. _tableView.delegate = self;
  55. _tableView.dataSource = self;
  56. self.view = _tableView;
  57. _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
  58. _activityIndicator.center = _tableView.center;
  59. _activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
  60. _activityIndicator.hidesWhenStopped = YES;
  61. [self.view addSubview:_activityIndicator];
  62. }
  63. - (void)viewDidLoad
  64. {
  65. [super viewDidLoad];
  66. /* if (SYSTEM_RUNS_IOS7_OR_LATER)
  67. _sectionHeaderTexts = @[@"Universal Plug'n'Play (UPNP)", @"File Transfer Protocol (FTP)", @"Network Streams (SAP)"];
  68. else*/
  69. _sectionHeaderTexts = @[@"Universal Plug'n'Play (UPNP)", @"File Transfer Protocol (FTP)"];
  70. _backToMenuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(goBack:)];
  71. self.navigationItem.leftBarButtonItem = _backToMenuButton;
  72. self.tableView.rowHeight = [VLCLocalNetworkListCell heightOfCell];
  73. self.tableView.separatorColor = [UIColor colorWithWhite:.122 alpha:1.];
  74. self.view.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  75. self.title = NSLocalizedString(@"LOCAL_NETWORK", @"");
  76. _ftpServices = [[NSMutableArray alloc] init];
  77. [_ftpServices addObject:NSLocalizedString(@"CONNECT_TO_SERVER", nil)];
  78. _rawNetServices = [[NSMutableArray alloc] init];
  79. _ftpNetServiceBrowser = [[NSNetServiceBrowser alloc] init];
  80. _ftpNetServiceBrowser.delegate = self;
  81. [self _triggerNetServiceBrowser];
  82. _refreshControl = [[UIRefreshControl alloc] init];
  83. [_refreshControl addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];
  84. [self.tableView addSubview:_refreshControl];
  85. if (SYSTEM_RUNS_IOS7_OR_LATER)
  86. _loginViewController = [[VLCNetworkLoginViewController alloc] initWithNibName:@"VLCFutureNetworkLoginViewController" bundle:nil];
  87. else
  88. _loginViewController = [[VLCNetworkLoginViewController alloc] initWithNibName:@"VLCNetworkLoginViewController" bundle:nil];
  89. _loginViewController.delegate = self;
  90. _reachability = [Reachability reachabilityForLocalWiFi];
  91. [_reachability startNotifier];
  92. [self netReachabilityChanged:nil];
  93. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachabilityChanged:) name:kReachabilityChangedNotification object:nil];
  94. }
  95. - (void)viewWillDisappear:(BOOL)animated
  96. {
  97. [super viewWillDisappear:animated];
  98. [_activityIndicator stopAnimating];
  99. [_ftpNetServiceBrowser stop];
  100. }
  101. - (void)viewWillAppear:(BOOL)animated
  102. {
  103. [_activityIndicator stopAnimating];
  104. [super viewWillAppear:animated];
  105. [self netReachabilityChanged:nil];
  106. }
  107. - (void)netReachabilityChanged:(NSNotification *)notification
  108. {
  109. if (_reachability.currentReachabilityStatus == ReachableViaWiFi) {
  110. [self _triggerNetServiceBrowser];
  111. [self performSelectorInBackground:@selector(_startUPNPDiscovery) withObject:nil];
  112. [self performSelectorInBackground:@selector(_startSAPDiscovery) withObject:nil];
  113. } else {
  114. [_ftpNetServiceBrowser stop];
  115. [self _stopUPNPDiscovery];
  116. [self _stopSAPDiscovery];
  117. }
  118. }
  119. - (void)_triggerNetServiceBrowser
  120. {
  121. [_ftpNetServiceBrowser searchForServicesOfType:@"_ftp._tcp." inDomain:@""];
  122. }
  123. - (void)_startUPNPDiscovery
  124. {
  125. if (_reachability.currentReachabilityStatus != ReachableViaWiFi)
  126. return;
  127. UPnPManager *managerInstance = [UPnPManager GetInstance];
  128. _UPNPdevices = [[managerInstance DB] rootDevices];
  129. if (_UPNPdevices.count > 0)
  130. [self UPnPDBUpdated:nil];
  131. [[managerInstance DB] addObserver:self];
  132. //Optional; set User Agent
  133. [[managerInstance SSDP] setUserAgentProduct:[NSString stringWithFormat:@"VLCforiOS/%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] andOS:[NSString stringWithFormat:@"iOS/%@", [[UIDevice currentDevice] systemVersion]]];
  134. //Search for UPnP Devices
  135. [[managerInstance SSDP] startSSDP];
  136. [[managerInstance SSDP] notifySSDPAlive];
  137. _searchTimer = [NSTimer timerWithTimeInterval:10.0 target:self selector:@selector(_performSSDPSearch) userInfo:nil repeats:YES];
  138. [_searchTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
  139. [[NSRunLoop mainRunLoop] addTimer:_searchTimer forMode:NSRunLoopCommonModes];
  140. _udnpDiscoveryRunning = YES;
  141. }
  142. - (void)_performSSDPSearch
  143. {
  144. UPnPManager *managerInstance = [UPnPManager GetInstance];
  145. [[managerInstance SSDP] searchSSDP];
  146. [[managerInstance SSDP] searchForMediaServer];
  147. [[managerInstance SSDP] SSDPDBUpdate];
  148. }
  149. - (void)_stopUPNPDiscovery
  150. {
  151. if (_udnpDiscoveryRunning) {
  152. UPnPManager *managerInstance = [UPnPManager GetInstance];
  153. [[managerInstance SSDP] notifySSDPByeBye];
  154. [_searchTimer invalidate];
  155. _searchTimer = nil;
  156. [[managerInstance DB] removeObserver:self];
  157. [[managerInstance SSDP] stopSSDP];
  158. _udnpDiscoveryRunning = NO;
  159. }
  160. }
  161. - (IBAction)goBack:(id)sender
  162. {
  163. [self _stopUPNPDiscovery];
  164. [self _stopSAPDiscovery];
  165. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  166. }
  167. - (BOOL)shouldAutorotate
  168. {
  169. UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
  170. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  171. return NO;
  172. return YES;
  173. }
  174. #pragma mark - table view handling
  175. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  176. {
  177. return _sectionHeaderTexts.count;
  178. }
  179. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  180. {
  181. if (section == 0)
  182. return _filteredUPNPDevices.count;
  183. else if (section == 1)
  184. return _ftpServices.count;
  185. else if (section == 2)
  186. return _sapDiscoverer.discoveredMedia.count;
  187. return 0;
  188. }
  189. - (void)tableView:(UITableView *)tableView willDisplayCell:(VLCLocalNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  190. {
  191. UIColor *color = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor colorWithWhite:.122 alpha:1.];
  192. cell.contentView.backgroundColor = cell.titleLabel.backgroundColor = cell.folderTitleLabel.backgroundColor = cell.subtitleLabel.backgroundColor = color;
  193. }
  194. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  195. {
  196. static NSString *CellIdentifier = @"LocalNetworkCell";
  197. VLCLocalNetworkListCell *cell = (VLCLocalNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  198. if (cell == nil)
  199. cell = [VLCLocalNetworkListCell cellWithReuseIdentifier:CellIdentifier];
  200. NSUInteger row = indexPath.row;
  201. NSUInteger section = indexPath.section;
  202. [cell setIsDirectory:YES];
  203. [cell setIcon:nil];
  204. if (section == 0) {
  205. UIImage *icon;
  206. if (_filteredUPNPDevices.count > row) {
  207. BasicUPnPDevice *device = _filteredUPNPDevices[row];
  208. [cell setTitle:[device friendlyName]];
  209. icon = [device smallIcon];
  210. }
  211. [cell setIcon:icon != nil ? icon : [UIImage imageNamed:@"serverIcon"]];
  212. } else if (section == 1) {
  213. if (row == 0)
  214. [cell setTitle:_ftpServices[row]];
  215. else {
  216. [cell setTitle:[_ftpServices[row] name]];
  217. [cell setIcon:[UIImage imageNamed:@"serverIcon"]];
  218. }
  219. } else if (section == 2)
  220. [cell setTitle:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] metadataForKey: VLCMetaInformationTitle]];
  221. return cell;
  222. }
  223. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  224. {
  225. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  226. NSUInteger row = indexPath.row;
  227. NSUInteger section = indexPath.section;
  228. if (section == 0) {
  229. if (_filteredUPNPDevices.count < row || _filteredUPNPDevices.count == 0)
  230. return;
  231. [_activityIndicator startAnimating];
  232. BasicUPnPDevice *device = _filteredUPNPDevices[row];
  233. if ([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaServer:1"]) {
  234. MediaServer1Device *server = (MediaServer1Device*)device;
  235. VLCLocalServerFolderListViewController *targetViewController = [[VLCLocalServerFolderListViewController alloc] initWithUPNPDevice:server header:[device friendlyName] andRootID:@"0"];
  236. [self.navigationController pushViewController:targetViewController animated:YES];
  237. }
  238. } else if (section == 1) {
  239. UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_loginViewController];
  240. [navCon loadTheme];
  241. navCon.navigationBarHidden = NO;
  242. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  243. navCon.modalPresentationStyle = UIModalPresentationFormSheet;
  244. [self presentViewController:navCon animated:YES completion:nil];
  245. if (_loginViewController.navigationItem.leftBarButtonItem == nil) {
  246. UIBarButtonItem *doneButton = [UIBarButtonItem themedDoneButtonWithTarget:_loginViewController andSelector:@selector(dismissWithAnimation:)];
  247. _loginViewController.navigationItem.leftBarButtonItem = doneButton;
  248. }
  249. } else
  250. [self.navigationController pushViewController:_loginViewController animated:YES];
  251. if (row != 0 && [_ftpServices[row] hostName].length > 0) // FTP Connect To Server Special Item and hostname is long enough
  252. _loginViewController.hostname = [_ftpServices[row] hostName];
  253. else
  254. _loginViewController.hostname = @"";
  255. } else if (section == 2) {
  256. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  257. [appDelegate openMovieFromURL:[[_sapDiscoverer.discoveredMedia mediaAtIndex:row] url]];
  258. }
  259. }
  260. #pragma mark - Refresh
  261. -(void)handleRefresh
  262. {
  263. UPnPManager *managerInstance = [UPnPManager GetInstance];
  264. [[managerInstance DB] removeObserver:self];
  265. [[managerInstance SSDP] stopSSDP];
  266. //set the title while refreshing
  267. _refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"LOCAL_SERVER_REFRESH",nil)];
  268. //set the date and time of refreshing
  269. NSDateFormatter *formattedDate = [[NSDateFormatter alloc]init];
  270. [formattedDate setDateFormat:@"MMM d, h:mm a"];
  271. NSString *lastupdated = [NSString stringWithFormat:NSLocalizedString(@"LOCAL_SERVER_LAST_UPDATE",nil),[formattedDate stringFromDate:[NSDate date]]];
  272. _refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:lastupdated];
  273. //end the refreshing
  274. [_refreshControl endRefreshing];
  275. [self.tableView reloadData];
  276. [self performSelectorInBackground:@selector(_startUPNPDiscovery) withObject:nil];
  277. [self performSelectorInBackground:@selector(_startSAPDiscovery) withObject:nil];
  278. }
  279. #pragma mark - login panel protocol
  280. - (void)loginToURL:(NSURL *)url confirmedWithUsername:(NSString *)username andPassword:(NSString *)password
  281. {
  282. if ([url.scheme isEqualToString:@"ftp"]) {
  283. if (url.host.length > 0) {
  284. VLCLocalServerFolderListViewController *targetViewController = [[VLCLocalServerFolderListViewController alloc] initWithFTPServer:url.host userName:username andPassword:password atPath:@"/"];
  285. [self.navigationController pushViewController:targetViewController animated:YES];
  286. }
  287. } else
  288. APLog(@"Unsupported URL Scheme requested %@", url.scheme);
  289. }
  290. #pragma mark - custom table view appearance
  291. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  292. {
  293. return 21.f;
  294. }
  295. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  296. {
  297. NSObject *headerText = NSLocalizedString(_sectionHeaderTexts[section], @"");
  298. UIView *headerView = nil;
  299. if (headerText != [NSNull null]) {
  300. headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 21.0f)];
  301. if (!SYSTEM_RUNS_IOS7_OR_LATER) {
  302. CAGradientLayer *gradient = [CAGradientLayer layer];
  303. gradient.frame = headerView.bounds;
  304. gradient.colors = @[
  305. (id)[UIColor colorWithRed:(66.0f/255.0f) green:(66.0f/255.0f) blue:(66.0f/255.0f) alpha:1.0f].CGColor,
  306. (id)[UIColor colorWithRed:(56.0f/255.0f) green:(56.0f/255.0f) blue:(56.0f/255.0f) alpha:1.0f].CGColor,
  307. ];
  308. [headerView.layer insertSublayer:gradient atIndex:0];
  309. } else
  310. headerView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  311. UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectInset(headerView.bounds, 12.0f, 5.0f)];
  312. textLabel.text = (NSString *) headerText;
  313. textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:([UIFont systemFontSize] * 0.8f)];
  314. textLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
  315. textLabel.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.25f];
  316. textLabel.textColor = [UIColor colorWithRed:(118.0f/255.0f) green:(118.0f/255.0f) blue:(118.0f/255.0f) alpha:1.0f];
  317. textLabel.backgroundColor = [UIColor clearColor];
  318. [headerView addSubview:textLabel];
  319. UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
  320. topLine.backgroundColor = [UIColor colorWithRed:(95.0f/255.0f) green:(95.0f/255.0f) blue:(95.0f/255.0f) alpha:1.0f];
  321. [headerView addSubview:topLine];
  322. UIView *bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 21.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
  323. bottomLine.backgroundColor = [UIColor colorWithRed:(16.0f/255.0f) green:(16.0f/255.0f) blue:(16.0f/255.0f) alpha:1.0f];
  324. [headerView addSubview:bottomLine];
  325. }
  326. return headerView;
  327. }
  328. #pragma mark - bonjour discovery
  329. - (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing
  330. {
  331. APLog(@"found bonjour service: %@ (%@)", aNetService.name, aNetService.type);
  332. [_rawNetServices addObject:aNetService];
  333. aNetService.delegate = self;
  334. [aNetService resolveWithTimeout:5.];
  335. }
  336. - (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didRemoveService:(NSNetService *)aNetService moreComing:(BOOL)moreComing
  337. {
  338. APLog(@"bonjour service disappeared: %@ (%i)", aNetService.name, moreComing);
  339. if ([_rawNetServices containsObject:aNetService])
  340. [_rawNetServices removeObject:aNetService];
  341. if ([aNetService.type isEqualToString:@"_ftp._tcp."])
  342. [_ftpServices removeObject:aNetService];
  343. if (!moreComing)
  344. [self.tableView reloadData];
  345. }
  346. - (void)netServiceDidResolveAddress:(NSNetService *)aNetService
  347. {
  348. if ([aNetService.type isEqualToString:@"_ftp._tcp."]) {
  349. if (![_ftpServices containsObject:aNetService])
  350. [_ftpServices addObject:aNetService];
  351. }
  352. [_rawNetServices removeObject:aNetService];
  353. [self.tableView reloadData];
  354. }
  355. - (void)netService:(NSNetService *)aNetService didNotResolve:(NSDictionary *)errorDict
  356. {
  357. APLog(@"failed to resolve: %@", aNetService.name);
  358. [_rawNetServices removeObject:aNetService];
  359. }
  360. #pragma mark - UPNP details
  361. //protocol UPnPDBObserver
  362. - (void)UPnPDBWillUpdate:(UPnPDB*)sender
  363. {
  364. }
  365. - (void)UPnPDBUpdated:(UPnPDB*)sender
  366. {
  367. NSUInteger count = _UPNPdevices.count;
  368. BasicUPnPDevice *device;
  369. NSMutableArray *mutArray = [[NSMutableArray alloc] init];
  370. for (NSUInteger x = 0; x < count; x++) {
  371. device = _UPNPdevices[x];
  372. if ([[device urn] isEqualToString:@"urn:schemas-upnp-org:device:MediaServer:1"])
  373. [mutArray addObject:device];
  374. else
  375. APLog(@"found device '%@' with unsupported urn '%@'", [device friendlyName], [device urn]);
  376. }
  377. _filteredUPNPDevices = nil;
  378. _filteredUPNPDevices = [NSArray arrayWithArray:mutArray];
  379. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES];
  380. }
  381. #pragma mark SAP discovery
  382. - (void)_startSAPDiscovery
  383. {
  384. return;
  385. if (_reachability.currentReachabilityStatus != ReachableViaWiFi)
  386. return;
  387. _sapDiscoverer = [[VLCMediaDiscoverer alloc] initWithName:@"sap"];
  388. _sapDiscoverer.discoveredMedia.delegate = self;
  389. }
  390. - (void)_stopSAPDiscovery
  391. {
  392. return;
  393. _sapDiscoverer = nil;
  394. }
  395. - (void)mediaList:(VLCMediaList *)aMediaList mediaAdded:(VLCMedia *)media atIndex:(NSInteger)index
  396. {
  397. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  398. }
  399. - (void)mediaList:(VLCMediaList *)aMediaList mediaRemovedAtIndex:(NSInteger)index
  400. {
  401. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  402. }
  403. @end