VLCPlaylistViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. //
  2. // VLCMasterViewController.m
  3. // AspenProject
  4. //
  5. // Created by Felix Paul Kühne on 27.02.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCPlaylistViewController.h"
  11. #import "VLCMovieViewController.h"
  12. #import "VLCPlaylistTableViewCell.h"
  13. #import "VLCPlaylistGridView.h"
  14. #import "UINavigationController+Theme.h"
  15. #import "NSString+SupportedMedia.h"
  16. #import "VLCBugreporter.h"
  17. #import "VLCAppDelegate.h"
  18. #import "UIBarButtonItem+Theme.h"
  19. #ifndef UIStatusBarStyleLightContent
  20. #define UIStatusBarStyleLightContent 1
  21. #endif
  22. @implementation EmptyLibraryView
  23. @end
  24. @interface VLCPlaylistViewController () <AQGridViewDataSource, AQGridViewDelegate, UITableViewDataSource, UITableViewDelegate, MLMediaLibrary> {
  25. NSMutableArray *_foundMedia;
  26. NSUInteger _libraryMode;
  27. UIBarButtonItem *_menuButton;
  28. }
  29. @end
  30. @implementation VLCPlaylistViewController
  31. - (void)loadView {
  32. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  33. _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
  34. _tableView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  35. _tableView.delegate = self;
  36. _tableView.dataSource = self;
  37. self.view = _tableView;
  38. } else {
  39. _gridView = [[AQGridView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  40. _gridView.delegate = self;
  41. _gridView.dataSource = self;
  42. _gridView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"libraryBackground"]];
  43. self.view = _gridView;
  44. }
  45. _libraryMode = kVLCLibraryModeAllFiles;
  46. self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
  47. self.emptyLibraryView = [[[NSBundle mainBundle] loadNibNamed:@"VLCEmptyLibraryView" owner:self options:nil] lastObject];
  48. }
  49. #pragma mark -
  50. - (void)viewDidLoad
  51. {
  52. [super viewDidLoad];
  53. _menuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(leftButtonAction:)];
  54. /* After day 354 of the year, the usual VLC cone is replaced by another cone
  55. * wearing a Father Xmas hat.
  56. * Note: this icon doesn't represent an endorsement of The Coca-Cola Company
  57. * and should not be confused with the idea of religious statements or propagation there off
  58. */
  59. NSCalendar *gregorian =
  60. [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  61. NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:[NSDate date]];
  62. if (dayOfYear >= 354)
  63. _menuButton.image = [UIImage imageNamed:@"vlc-xmas"];
  64. self.navigationItem.leftBarButtonItem = _menuButton;
  65. if (SYSTEM_RUNS_IN_THE_FUTURE)
  66. self.editButtonItem.tintColor = [UIColor whiteColor];
  67. else {
  68. [self.editButtonItem setBackgroundImage:[UIImage imageNamed:@"button"]
  69. forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  70. [self.editButtonItem setBackgroundImage:[UIImage imageNamed:@"buttonHighlight"]
  71. forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  72. }
  73. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  74. _gridView.separatorStyle = AQGridViewCellSeparatorStyleEmptySpace;
  75. _gridView.alwaysBounceVertical = YES;
  76. _gridView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
  77. } else {
  78. _tableView.rowHeight = [VLCPlaylistTableViewCell heightOfCell];
  79. _tableView.separatorColor = [UIColor colorWithWhite:.122 alpha:1.];
  80. }
  81. self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
  82. _emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", @"");
  83. _emptyLibraryView.emptyLibraryLongDescriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
  84. _emptyLibraryView.emptyLibraryLongDescriptionLabel.numberOfLines = 0;
  85. _emptyLibraryView.emptyLibraryLongDescriptionLabel.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", @"");
  86. [_emptyLibraryView.emptyLibraryLongDescriptionLabel sizeToFit];
  87. }
  88. - (void)viewWillAppear:(BOOL)animated
  89. {
  90. [super viewWillAppear:animated];
  91. [self _displayEmptyLibraryViewIfNeeded];
  92. }
  93. - (void)viewDidAppear:(BOOL)animated
  94. {
  95. [super viewDidAppear:animated];
  96. if ([[MLMediaLibrary sharedMediaLibrary] libraryNeedsUpgrade]) {
  97. self.navigationItem.rightBarButtonItem = nil;
  98. self.navigationItem.leftBarButtonItem = nil;
  99. self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"UPGRADING_LIBRARY", @"");
  100. self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = YES;
  101. [self.emptyLibraryView.activityIndicator startAnimating];
  102. self.emptyLibraryView.frame = self.view.frame;
  103. self.title = @"";
  104. [self.view addSubview:self.emptyLibraryView];
  105. [[MLMediaLibrary sharedMediaLibrary] setDelegate: self];
  106. [[MLMediaLibrary sharedMediaLibrary] performSelectorInBackground:@selector(upgradeLibrary) withObject:nil];
  107. return;
  108. }
  109. if (_foundMedia.count < 1)
  110. [self performSelector:@selector(reloadContents) withObject:nil afterDelay:.0];
  111. [[MLMediaLibrary sharedMediaLibrary] performSelector:@selector(libraryDidAppear) withObject:nil afterDelay:1.];
  112. if (SYSTEM_RUNS_IN_THE_FUTURE)
  113. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  114. }
  115. - (void)viewDidDisappear:(BOOL)animated
  116. {
  117. [super viewDidDisappear:animated];
  118. [[MLMediaLibrary sharedMediaLibrary] libraryDidDisappear];
  119. }
  120. - (BOOL)canBecomeFirstResponder
  121. {
  122. return YES;
  123. }
  124. - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
  125. {
  126. if (motion == UIEventSubtypeMotionShake)
  127. [[VLCBugreporter sharedInstance] handleBugreportRequest];
  128. }
  129. - (void)removeMediaObject:(MLFile *)mediaObject
  130. {
  131. NSFileManager *fileManager = [NSFileManager defaultManager];
  132. NSString *folderLocation = [[[NSURL URLWithString:mediaObject.url] path] stringByDeletingLastPathComponent];
  133. NSArray *allfiles = [fileManager contentsOfDirectoryAtPath:folderLocation error:nil];
  134. NSString *fileName = [[[[NSURL URLWithString:mediaObject.url] path] lastPathComponent] stringByDeletingPathExtension];
  135. NSIndexSet *indexSet = [allfiles indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
  136. return ([obj rangeOfString:fileName].location != NSNotFound);
  137. }];
  138. unsigned int count = indexSet.count;
  139. NSString *additionalFilePath;
  140. NSUInteger currentIndex = [indexSet firstIndex];
  141. for (unsigned int x = 0; x < count; x++) {
  142. additionalFilePath = allfiles[currentIndex];
  143. if ([additionalFilePath isSupportedSubtitleFormat])
  144. [fileManager removeItemAtPath:[folderLocation stringByAppendingPathComponent:additionalFilePath] error:nil];
  145. currentIndex = [indexSet indexGreaterThanIndex:currentIndex];
  146. }
  147. [fileManager removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil];
  148. [[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
  149. [self reloadContents];
  150. }
  151. - (void)_displayEmptyLibraryViewIfNeeded
  152. {
  153. if (_foundMedia.count > 0) {
  154. if (self.emptyLibraryView.superview)
  155. [self.emptyLibraryView removeFromSuperview];
  156. } else {
  157. self.emptyLibraryView.frame = self.view.frame;
  158. [self.view addSubview:self.emptyLibraryView];
  159. }
  160. if (_libraryMode == kVLCLibraryModeAllFiles && _foundMedia.count > 0)
  161. self.navigationItem.rightBarButtonItem = self.editButtonItem;
  162. else
  163. self.navigationItem.rightBarButtonItem = nil;
  164. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  165. _tableView.separatorStyle = (_foundMedia.count > 0)? UITableViewCellSeparatorStyleSingleLine:
  166. UITableViewCellSeparatorStyleNone;
  167. }
  168. }
  169. - (void)libraryUpgradeComplete
  170. {
  171. self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = NO;
  172. self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", @"");
  173. [self.emptyLibraryView.activityIndicator stopAnimating];
  174. self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
  175. self.navigationItem.leftBarButtonItem = _menuButton;
  176. [self.emptyLibraryView removeFromSuperview];
  177. [self reloadContents];
  178. }
  179. - (void)reloadContents
  180. {
  181. if (_libraryMode == kVLCLibraryModeAllAlbums) {
  182. NSArray *rawAlbums = [MLAlbum allAlbums];
  183. _foundMedia = [[NSMutableArray alloc] init];
  184. NSUInteger count = rawAlbums.count;
  185. MLAlbum *album;
  186. for (NSUInteger x = 0; x < count; x++) {
  187. album = rawAlbums[x];
  188. if (album.name.length > 0 && album.tracks.count > 0)
  189. [_foundMedia addObject:album];
  190. }
  191. rawAlbums = nil;
  192. } else if (_libraryMode == kVLCLibraryModeAllSeries) {
  193. NSArray *rawShows = [MLShow allShows];
  194. _foundMedia = [[NSMutableArray alloc] init];
  195. NSUInteger count = rawShows.count;
  196. MLShow *show;
  197. for (NSUInteger x = 0; x < count; x++) {
  198. show = rawShows[x];
  199. if (show.name.length > 0 && show.episodes.count > 0)
  200. [_foundMedia addObject:show];
  201. }
  202. rawShows = nil;
  203. } else
  204. _foundMedia = [NSMutableArray arrayWithArray:[MLFile allFiles]];
  205. [self updateViewContents];
  206. }
  207. - (void)updateViewContents
  208. {
  209. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  210. [self.tableView reloadData];
  211. else {
  212. [self.gridView reloadData];
  213. [self.gridView setNeedsLayout];
  214. }
  215. [self _displayEmptyLibraryViewIfNeeded];
  216. }
  217. #pragma mark - Table View
  218. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  219. {
  220. return 1;
  221. }
  222. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  223. {
  224. return _foundMedia.count;
  225. }
  226. // Customize the appearance of table view cells.
  227. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  228. {
  229. static NSString *CellIdentifier = @"PlaylistCell";
  230. VLCPlaylistTableViewCell *cell = (VLCPlaylistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  231. if (cell == nil)
  232. cell = [VLCPlaylistTableViewCell cellWithReuseIdentifier:CellIdentifier];
  233. NSInteger row = indexPath.row;
  234. cell.mediaObject = _foundMedia[row];
  235. return cell;
  236. }
  237. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  238. {
  239. cell.backgroundColor = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor colorWithWhite:.122 alpha:1.];
  240. }
  241. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  242. {
  243. return YES;
  244. }
  245. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  246. {
  247. if (editingStyle == UITableViewCellEditingStyleDelete)
  248. [self removeMediaObject: _foundMedia[indexPath.row]];
  249. }
  250. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  251. {
  252. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  253. NSManagedObject *currentObject = _foundMedia[indexPath.row];
  254. if ([currentObject isKindOfClass:[MLAlbum class]]) {
  255. _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
  256. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  257. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
  258. self.title = [(MLAlbum*)currentObject name];
  259. [self updateViewContents];
  260. } else if ([currentObject isKindOfClass:[MLShow class]]) {
  261. _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
  262. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  263. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
  264. self.title = [(MLShow*)currentObject name];
  265. [self updateViewContents];
  266. } else {
  267. if (!self.movieViewController)
  268. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  269. if ([currentObject isKindOfClass:[MLFile class]])
  270. self.movieViewController.mediaItem = (MLFile *)currentObject;
  271. else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
  272. self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
  273. else if ([currentObject isKindOfClass:[MLShowEpisode class]])
  274. self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
  275. [self.navigationController pushViewController:self.movieViewController animated:YES];
  276. }
  277. }
  278. #pragma mark - AQGridView
  279. - (NSUInteger)numberOfItemsInGridView:(AQGridView *)gridView
  280. {
  281. return _foundMedia.count;
  282. }
  283. - (AQGridViewCell *)gridView:(AQGridView *)gridView cellForItemAtIndex:(NSUInteger)index
  284. {
  285. static NSString *AQCellIdentifier = @"AQPlaylistCell";
  286. VLCPlaylistGridView *cell = (VLCPlaylistGridView *)[gridView dequeueReusableCellWithIdentifier:AQCellIdentifier];
  287. if (cell == nil) {
  288. cell = [[[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistGridView" owner:self options:nil] lastObject];
  289. cell.selectionStyle = AQGridViewCellSelectionStyleNone;
  290. cell.gridView = gridView;
  291. }
  292. cell.mediaObject = _foundMedia[index];
  293. return cell;
  294. }
  295. - (CGSize)portraitGridCellSizeForGridView:(AQGridView *)gridView
  296. {
  297. return [VLCPlaylistGridView preferredSize];
  298. }
  299. - (void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index
  300. {
  301. [self.gridView deselectItemAtIndex:index animated:YES];
  302. NSManagedObject *currentObject = _foundMedia[index];
  303. if ([currentObject isKindOfClass:[MLAlbum class]]) {
  304. _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
  305. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  306. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
  307. self.title = [(MLAlbum*)currentObject name];
  308. [self updateViewContents];
  309. } else if ([currentObject isKindOfClass:[MLShow class]]) {
  310. _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
  311. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  312. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
  313. self.title = [(MLShow*)currentObject name];
  314. [self updateViewContents];
  315. } else {
  316. if (!self.movieViewController)
  317. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  318. if ([currentObject isKindOfClass:[MLFile class]])
  319. self.movieViewController.mediaItem = (MLFile *)currentObject;
  320. else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
  321. self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
  322. else if ([currentObject isKindOfClass:[MLShowEpisode class]])
  323. self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
  324. [self.navigationController pushViewController:self.movieViewController animated:YES];
  325. }
  326. }
  327. - (void)gridView:(AQGridView *)aGridView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndex:(NSUInteger)index
  328. {
  329. if (editingStyle == UITableViewCellEditingStyleDelete)
  330. [self removeMediaObject: _foundMedia[index]];
  331. }
  332. #pragma mark - UI implementation
  333. - (void)setEditing:(BOOL)editing animated:(BOOL)animated
  334. {
  335. if (_libraryMode != kVLCLibraryModeAllFiles)
  336. return;
  337. [super setEditing:editing animated:animated];
  338. UIBarButtonItem *editButton = self.editButtonItem;
  339. NSString *editImage = editing? @"doneButton": @"button";
  340. NSString *editImageHighlight = editing? @"doneButtonHighlight": @"buttonHighlight";
  341. if (SYSTEM_RUNS_IN_THE_FUTURE)
  342. editButton.tintColor = [UIColor whiteColor];
  343. else {
  344. [editButton setBackgroundImage:[UIImage imageNamed:editImage] forState:UIControlStateNormal
  345. barMetrics:UIBarMetricsDefault];
  346. [editButton setBackgroundImage:[UIImage imageNamed:editImageHighlight]
  347. forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  348. [editButton setTitleTextAttributes: editing ? @{UITextAttributeTextShadowColor : [UIColor whiteColor], UITextAttributeTextColor : [UIColor blackColor]} : @{UITextAttributeTextShadowColor : [UIColor colorWithWhite:0. alpha:.37], UITextAttributeTextColor : [UIColor whiteColor]} forState:UIControlStateNormal];
  349. }
  350. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  351. [self.gridView setEditing:editing];
  352. else
  353. [self.tableView setEditing:editing animated:YES];
  354. }
  355. - (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
  356. {
  357. if (_libraryMode != kVLCLibraryModeAllFiles)
  358. return UITableViewCellEditingStyleNone;
  359. return UITableViewCellEditingStyleDelete;
  360. }
  361. - (IBAction)leftButtonAction:(id)sender
  362. {
  363. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  364. }
  365. - (IBAction)backToAllItems:(id)sender
  366. {
  367. self.navigationItem.leftBarButtonItem = _menuButton;
  368. [self setLibraryMode:_libraryMode];
  369. }
  370. /* deprecated in iOS 6 */
  371. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  372. {
  373. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  374. return YES;
  375. return (_foundMedia.count > 0) || toInterfaceOrientation == UIInterfaceOrientationPortrait;
  376. }
  377. // RootController is responsible for supporting interface orientation(iOS6.0+), i.e. navigation controller
  378. // so this will not work as intended without "voodoo magic"(UINavigationController category, subclassing, etc)
  379. /* introduced in iOS 6 */
  380. - (NSUInteger)supportedInterfaceOrientations {
  381. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  382. return UIInterfaceOrientationMaskAll;
  383. return (_foundMedia.count > 0)? UIInterfaceOrientationMaskAllButUpsideDown:
  384. UIInterfaceOrientationMaskPortrait;
  385. }
  386. /* introduced in iOS 6 */
  387. - (BOOL)shouldAutorotate {
  388. return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (_foundMedia.count > 0);
  389. }
  390. #pragma mark - coin coin
  391. - (void)openMovieFromURL:(NSURL *)url
  392. {
  393. if (!self.movieViewController)
  394. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  395. if (self.navigationController.topViewController != self.movieViewController)
  396. [self.navigationController pushViewController:self.movieViewController animated:YES];
  397. self.movieViewController.url = url;
  398. }
  399. - (void)setLibraryMode:(NSUInteger)mode
  400. {
  401. _libraryMode = mode;
  402. if (_libraryMode == kVLCLibraryModeAllAlbums)
  403. self.title = NSLocalizedString(@"LIBRARY_MUSIC", @"");
  404. else if( _libraryMode == kVLCLibraryModeAllSeries)
  405. self.title = NSLocalizedString(@"LIBRARY_SERIES", @"");
  406. else
  407. self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
  408. [self reloadContents];
  409. }
  410. @end