VLCLocalPlexFolderListViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. /*****************************************************************************
  2. * VLCLocalPlexFolderListViewController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2014-2015 VideoLAN. All rights reserved.
  6. *
  7. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  8. * Pierre SAGASPE <pierre.sagaspe # me.com>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCLocalPlexFolderListViewController.h"
  13. #import "VLCPlexMediaInformationViewController.h"
  14. #import "VLCPlexParser.h"
  15. #import "VLCPlexWebAPI.h"
  16. #import "VLCNetworkListCell.h"
  17. #import "VLCPlaybackController.h"
  18. #import "VLCPlaylistViewController.h"
  19. #import "VLCDownloadViewController.h"
  20. #import "NSString+SupportedMedia.h"
  21. #import "VLCStatusLabel.h"
  22. #import "UIDevice+VLC.h"
  23. @interface VLCLocalPlexFolderListViewController () <UITableViewDataSource, UITableViewDelegate, VLCNetworkListCellDelegate, UISearchBarDelegate, UISearchDisplayDelegate>
  24. {
  25. NSArray *_globalObjectList;
  26. NSCache *_imageCache;
  27. NSString *_PlexServerName;
  28. NSString *_PlexServerAddress;
  29. NSString *_PlexServerPort;
  30. NSString *_PlexServerPath;
  31. NSString *_PlexAuthentification;
  32. VLCPlexParser *_PlexParser;
  33. VLCPlexWebAPI *_PlexWebAPI;
  34. NSMutableArray *_searchData;
  35. UISearchBar *_searchBar;
  36. UISearchDisplayController *_searchDisplayController;
  37. UIRefreshControl *_refreshControl;
  38. UIBarButtonItem *_menuButton;
  39. UITapGestureRecognizer *_tapTwiceGestureRecognizer;
  40. }
  41. @end
  42. @implementation VLCLocalPlexFolderListViewController
  43. - (void)dealloc
  44. {
  45. [_tapTwiceGestureRecognizer removeTarget:self action:NULL];
  46. }
  47. - (void)loadView
  48. {
  49. _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
  50. _tableView.backgroundColor = [UIColor VLCDarkBackgroundColor];
  51. _tableView.delegate = self;
  52. _tableView.dataSource = self;
  53. _tableView.rowHeight = [VLCNetworkListCell heightOfCell];
  54. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  55. _tableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
  56. self.view = _tableView;
  57. }
  58. - (id)initWithPlexServer:(NSString *)serverName serverAddress:(NSString *)serverAddress portNumber:(NSString *)portNumber atPath:(NSString *)path authentification:(NSString *)auth
  59. {
  60. self = [super init];
  61. if (self) {
  62. _PlexServerName = serverName;
  63. _PlexServerAddress = serverAddress;
  64. _PlexServerPort = portNumber;
  65. _PlexServerPath = path;
  66. _PlexAuthentification = auth;
  67. _globalObjectList = [[NSArray alloc] init];
  68. _imageCache = [[NSCache alloc] init];
  69. [_imageCache setCountLimit:50];
  70. _PlexParser = [[VLCPlexParser alloc] init];
  71. }
  72. return self;
  73. }
  74. - (void)viewDidLoad
  75. {
  76. [super viewDidLoad];
  77. self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
  78. self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
  79. _PlexWebAPI = [[VLCPlexWebAPI alloc] init];
  80. self.title = _PlexServerName;
  81. _searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
  82. UINavigationBar *navBar = self.navigationController.navigationBar;
  83. _searchBar.barTintColor = navBar.barTintColor;
  84. _searchBar.tintColor = navBar.tintColor;
  85. _searchBar.translucent = navBar.translucent;
  86. _searchBar.opaque = navBar.opaque;
  87. _searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self];
  88. _searchDisplayController.delegate = self;
  89. _searchDisplayController.searchResultsDataSource = self;
  90. _searchDisplayController.searchResultsDelegate = self;
  91. _searchDisplayController.searchBar.searchBarStyle = UIBarStyleBlack;
  92. _searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  93. _searchDisplayController.searchResultsTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
  94. _searchBar.delegate = self;
  95. _searchBar.hidden = YES;
  96. //self.tableView.tableHeaderView = _searchBar;
  97. //self.tableView.contentOffset = CGPointMake(0, CGRectGetHeight(_searchBar.frame)); // -> hide search bar to load
  98. _tapTwiceGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTwiceGestureAction:)];
  99. [_tapTwiceGestureRecognizer setNumberOfTapsRequired:2];
  100. [self.navigationController.navigationBar addGestureRecognizer:_tapTwiceGestureRecognizer];
  101. // Active le Pull down to refresh
  102. _refreshControl = [[UIRefreshControl alloc] init];
  103. _refreshControl.backgroundColor = [UIColor VLCDarkBackgroundColor];
  104. _refreshControl.tintColor = [UIColor whiteColor];
  105. // Call the refresh function
  106. [_refreshControl addTarget:self action:@selector(handleRefresh) forControlEvents:UIControlEventValueChanged];
  107. [self.tableView addSubview:_refreshControl];
  108. _menuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(menuButtonAction:)];
  109. self.navigationItem.rightBarButtonItem = _menuButton;
  110. _globalObjectList = [[NSArray alloc] init];
  111. _searchData = [[NSMutableArray alloc] init];
  112. [self performSelectorInBackground:@selector(loadContents) withObject:nil];
  113. }
  114. - (void)loadContents
  115. {
  116. _globalObjectList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:_PlexServerPath authentification:_PlexAuthentification];
  117. NSDictionary *firstObject = [_globalObjectList firstObject];
  118. if (_globalObjectList.count == 0 || firstObject == nil)
  119. _PlexAuthentification = @"";
  120. else
  121. _PlexAuthentification = [firstObject objectForKey:@"authentification"];
  122. NSString *titleValue;
  123. if ([_PlexServerPath isEqualToString:@""] || _globalObjectList.count == 0 || firstObject == nil)
  124. titleValue = _PlexServerName;
  125. else
  126. titleValue = [firstObject objectForKey:@"libTitle"];
  127. self.title = titleValue;
  128. [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  129. }
  130. - (BOOL)shouldAutorotate
  131. {
  132. UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
  133. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  134. return NO;
  135. return YES;
  136. }
  137. - (IBAction)menuButtonAction:(id)sender
  138. {
  139. [[VLCSidebarController sharedInstance] toggleSidebar];
  140. if (self.isEditing)
  141. [self setEditing:NO animated:YES];
  142. }
  143. #pragma mark - Table view data source
  144. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  145. {
  146. return 1;
  147. }
  148. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  149. {
  150. if (tableView == self.searchDisplayController.searchResultsTableView)
  151. return _searchData.count;
  152. else
  153. return _globalObjectList.count;
  154. }
  155. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  156. {
  157. static NSString *CellIdentifier = @"PlexCellDetail";
  158. VLCNetworkListCell *cell = (VLCNetworkListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  159. if (cell == nil)
  160. cell = [VLCNetworkListCell cellWithReuseIdentifier:CellIdentifier];
  161. NSDictionary *cellObject;
  162. if (tableView == self.searchDisplayController.searchResultsTableView)
  163. cellObject = _searchData[indexPath.row];
  164. else
  165. cellObject = _globalObjectList[indexPath.row];
  166. [cell setTitle:cellObject[@"title"]];
  167. [cell setIcon:[UIImage imageNamed:@"blank"]];
  168. NSString *thumbPath = cellObject[@"thumb"];
  169. if (thumbPath) {
  170. dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
  171. dispatch_async(queue, ^{
  172. UIImage *img = [self getCachedImage:[self _urlAuth:thumbPath]];
  173. dispatch_async(dispatch_get_main_queue(), ^{
  174. if (!img)
  175. [cell setIcon:[UIImage imageNamed:@"blank"]];
  176. else
  177. [cell setIcon:img];
  178. });
  179. });
  180. }
  181. if ([cellObject[@"container"] isEqualToString:@"item"]) {
  182. UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightGestureAction:)];
  183. [swipeRight setDirection:(UISwipeGestureRecognizerDirectionRight)];
  184. [cell addGestureRecognizer:swipeRight];
  185. UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTouchGestureAction:)];
  186. [cell addGestureRecognizer:longPressGestureRecognizer];
  187. NSInteger size = [cellObject[@"size"] integerValue];
  188. NSString *mediaSize = [NSByteCountFormatter stringFromByteCount:size countStyle:NSByteCountFormatterCountStyleFile];
  189. NSString *durationInSeconds = cellObject[@"duration"];
  190. [cell setIsDirectory:NO];
  191. [cell setSubtitle:[NSString stringWithFormat:@"%@ (%@)", mediaSize, durationInSeconds]];
  192. [cell setIsDownloadable:YES];
  193. [cell setDelegate:self];
  194. } else {
  195. [cell setIsDirectory:YES];
  196. if (!thumbPath)
  197. [cell setIcon:[UIImage imageNamed:@"folder"]];
  198. }
  199. return cell;
  200. }
  201. - (UIImage *)getCachedImage:(NSString *)url
  202. {
  203. UIImage *image = [_imageCache objectForKey:url];
  204. if ((image != nil) && [image isKindOfClass:[UIImage class]]) {
  205. return image;
  206. } else {
  207. NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
  208. if (imageData) {
  209. image = [[UIImage alloc] initWithData:imageData];
  210. [_imageCache setObject:image forKey:url];
  211. }
  212. return image;
  213. }
  214. }
  215. #pragma mark - Table view delegate
  216. - (void)tableView:(UITableView *)tableView willDisplayCell:(VLCNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  217. {
  218. UIColor *color = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor VLCDarkBackgroundColor];
  219. cell.contentView.backgroundColor = cell.titleLabel.backgroundColor = cell.folderTitleLabel.backgroundColor = cell.subtitleLabel.backgroundColor = color;
  220. }
  221. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  222. {
  223. NSArray *objectList;
  224. NSString *newPath = nil;
  225. if (tableView == self.searchDisplayController.searchResultsTableView)
  226. objectList = [_searchData copy];
  227. else
  228. objectList = _globalObjectList;
  229. NSDictionary *rowObject = objectList[indexPath.row];
  230. NSString *keyValue = [rowObject objectForKey:@"key"];
  231. if ([keyValue rangeOfString:@"library"].location == NSNotFound)
  232. newPath = [_PlexServerPath stringByAppendingPathComponent:keyValue];
  233. else
  234. newPath = keyValue;
  235. if ([rowObject[@"container"] isEqualToString:@"item"]) {
  236. objectList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
  237. NSString *URLofSubtitle = nil;
  238. NSDictionary *firstObject = [objectList firstObject];
  239. if (!firstObject)
  240. return;
  241. if ([firstObject objectForKey:@"keySubtitle"])
  242. URLofSubtitle = [_PlexWebAPI getFileSubtitleFromPlexServer:firstObject modeStream:YES];
  243. NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:firstObject[@"keyMedia"]]];
  244. if (itemURL) {
  245. VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
  246. [vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
  247. }
  248. } else {
  249. VLCLocalPlexFolderListViewController *targetViewController = [[VLCLocalPlexFolderListViewController alloc] initWithPlexServer:_PlexServerName serverAddress:_PlexServerAddress portNumber:_PlexServerPort atPath:newPath authentification:_PlexAuthentification];
  250. [[self navigationController] pushViewController:targetViewController animated:YES];
  251. }
  252. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  253. }
  254. #pragma mark - Specifics
  255. - (NSString *)_urlAuth:(NSString *)url
  256. {
  257. return [_PlexWebAPI urlAuth:url autentification:_PlexAuthentification];
  258. }
  259. - (void)_playMediaItem:(NSDictionary *)mediaObject
  260. {
  261. NSString *newPath = nil;
  262. NSString *keyValue = [mediaObject objectForKey:@"key"];
  263. if ([keyValue rangeOfString:@"library"].location == NSNotFound)
  264. newPath = [_PlexServerPath stringByAppendingPathComponent:keyValue];
  265. else
  266. newPath = keyValue;
  267. if ([[mediaObject objectForKey:@"container"] isEqualToString:@"item"]) {
  268. NSArray *mediaList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:newPath authentification:_PlexAuthentification];
  269. NSString *URLofSubtitle = nil;
  270. NSDictionary *firstObject = [mediaList firstObject];
  271. if (!firstObject)
  272. return;
  273. if ([firstObject objectForKey:@"keySubtitle"])
  274. URLofSubtitle = [_PlexWebAPI getFileSubtitleFromPlexServer:firstObject modeStream:YES];
  275. NSURL *itemURL = [NSURL URLWithString:[self _urlAuth:[firstObject objectForKey:@"keyMedia"]]];
  276. if (itemURL) {
  277. VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
  278. [vpc playURL:itemURL subtitlesFilePath:URLofSubtitle];
  279. }
  280. }
  281. }
  282. - (void)_downloadFileFromMediaItem:(NSDictionary *)mediaObject
  283. {
  284. if (!mediaObject)
  285. return;
  286. NSURL *itemURL = [NSURL URLWithString:[mediaObject objectForKey:@"keyMedia"]];
  287. if (![[itemURL absoluteString] isSupportedFormat]) {
  288. VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil)
  289. message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), [itemURL absoluteString]]
  290. delegate:self
  291. cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
  292. otherButtonTitles:nil];
  293. [alert show];
  294. } else if (itemURL) {
  295. NSString *fileName = [mediaObject objectForKey:@"namefile"];
  296. [[VLCDownloadViewController sharedInstance] addURLToDownloadList:itemURL fileNameOfMedia:fileName];
  297. }
  298. }
  299. - (void)swipeRightGestureAction:(UIGestureRecognizer *)recognizer
  300. {
  301. NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:[recognizer locationInView:self.tableView]];
  302. UITableViewCell *swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
  303. VLCNetworkListCell *cell = (VLCNetworkListCell *)[[self tableView] cellForRowAtIndexPath:swipedIndexPath];
  304. NSDictionary *cellObject = _globalObjectList[[self.tableView indexPathForCell:swipedCell].row];
  305. NSString *ratingKey = cellObject[@"ratingKey"];
  306. NSString *tag = cellObject[@"state"];
  307. NSString *cellStatusLbl = nil;
  308. NSInteger status = [_PlexWebAPI MarkWatchedUnwatchedMedia:_PlexServerAddress port:_PlexServerPort videoRatingKey:ratingKey state:tag authentification:_PlexAuthentification];
  309. if (status == 200) {
  310. if ([tag isEqualToString:@"watched"]) {
  311. tag = @"unwatched";
  312. cellStatusLbl = NSLocalizedString(@"PLEX_UNWATCHED", nil);
  313. } else if ([tag isEqualToString:@"unwatched"]) {
  314. tag = @"watched";
  315. cellStatusLbl = NSLocalizedString(@"PLEX_WATCHED", nil);
  316. }
  317. } else
  318. cellStatusLbl = NSLocalizedString(@"PLEX_ERROR_MARK", nil);
  319. [cell.statusLabel showStatusMessage:cellStatusLbl];
  320. [_globalObjectList[[self.tableView indexPathForCell:swipedCell].row] setObject:tag forKey:@"state"];
  321. }
  322. - (void)reloadTableViewPlex
  323. {
  324. _globalObjectList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:_PlexServerPath authentification:_PlexAuthentification];
  325. [self.tableView reloadData];
  326. }
  327. #pragma mark - VLCNetworkListCell delegation
  328. - (void)triggerDownloadForCell:(VLCNetworkListCell *)cell
  329. {
  330. NSDictionary *cellObject;
  331. if ([self.searchDisplayController isActive])
  332. cellObject = _searchData[[self.searchDisplayController.searchResultsTableView indexPathForCell:cell].row];
  333. else
  334. cellObject = _globalObjectList[[self.tableView indexPathForCell:cell].row];
  335. NSString *path = cellObject[@"key"];
  336. NSArray *mediaList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:path authentification:_PlexAuthentification];
  337. NSDictionary *firstObject = [mediaList firstObject];
  338. NSInteger size = [[firstObject objectForKey:@"size"] integerValue];
  339. if (size < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
  340. if ([firstObject objectForKey:@"keySubtitle"])
  341. [_PlexWebAPI getFileSubtitleFromPlexServer:firstObject modeStream:NO];
  342. [self _downloadFileFromMediaItem:firstObject];
  343. [cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
  344. } else {
  345. VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil)
  346. message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), [firstObject objectForKey:@"title"], [[UIDevice currentDevice] model]]
  347. delegate:self
  348. cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
  349. otherButtonTitles:nil];
  350. [alert show];
  351. }
  352. }
  353. #pragma mark - Search Display Controller Delegate
  354. - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
  355. {
  356. [_searchData removeAllObjects];
  357. NSUInteger count = _globalObjectList.count;
  358. for (NSUInteger i = 0; i < count; i++) {
  359. NSRange nameRange;
  360. nameRange = [[_globalObjectList[i] objectForKey:@"title"] rangeOfString:searchString options:NSCaseInsensitiveSearch];
  361. if (nameRange.location != NSNotFound)
  362. [_searchData addObject:_globalObjectList[i]];
  363. }
  364. return YES;
  365. }
  366. - (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
  367. {
  368. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
  369. tableView.rowHeight = 80.0f;
  370. else
  371. tableView.rowHeight = 68.0f;
  372. tableView.backgroundColor = [UIColor blackColor];
  373. }
  374. #pragma mark - Refresh
  375. -(void)handleRefresh
  376. {
  377. //set the title while refreshing
  378. _refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:NSLocalizedString(@"LOCAL_SERVER_REFRESH", nil)];
  379. //set the date and time of refreshing
  380. NSDateFormatter *formattedDate = [[NSDateFormatter alloc]init];
  381. [formattedDate setDateFormat:@"MMM d, h:mm a"];
  382. NSString *lastupdated = [NSString stringWithFormat:NSLocalizedString(@"LOCAL_SERVER_LAST_UPDATE", nil),[formattedDate stringFromDate:[NSDate date]]];
  383. NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
  384. _refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:lastupdated attributes:attrsDictionary];
  385. //end the refreshing
  386. [_refreshControl endRefreshing];
  387. [self performSelector:@selector(reloadTableViewPlex) withObject:nil];
  388. }
  389. #pragma mark - Gesture Action
  390. - (void)tapTwiceGestureAction:(UIGestureRecognizer *)recognizer
  391. {
  392. _searchBar.hidden = !_searchBar.hidden;
  393. if (_searchBar.hidden)
  394. self.tableView.tableHeaderView = nil;
  395. else
  396. self.tableView.tableHeaderView = _searchBar;
  397. [self.tableView setContentOffset:CGPointMake(0.0f, -self.tableView.contentInset.top) animated:NO];
  398. }
  399. - (void)longTouchGestureAction:(UIGestureRecognizer *)recognizer
  400. {
  401. if (recognizer.state == UIGestureRecognizerStateBegan) {
  402. NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:[recognizer locationInView:self.tableView]];
  403. UITableViewCell *swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
  404. NSDictionary *cellObject = _globalObjectList[[self.tableView indexPathForCell:swipedCell].row];
  405. VLCPlexMediaInformationViewController *targetViewController = [[VLCPlexMediaInformationViewController alloc] initPlexMediaInformation:cellObject serverAddress:_PlexServerAddress portNumber:_PlexServerPort atPath:_PlexServerPath authentification:_PlexAuthentification];
  406. [[self navigationController] pushViewController:targetViewController animated:YES];
  407. }
  408. }
  409. @end